
                             Linux ½׼
                                       
: [1]Mendel Leo Cooper [2]http://personal.riverusers.com/~thegrendel/
: [3]J.S.Lin

   v1.52, 27 December 1997
     _________________________________________________________________
   
   Ƿݹ㷺ָļ,"һ" UNIX 巢׼ Linux . 
     _________________________________________________________________
   
1. 

2. ȡÿʼ

3. ʹ Make

4. ˷

     * 4.1 
     * 4.2 
     * 4.3 Ť΢
     * 4.4 ȥȡýһЭ
       
5. Ჽ

6. һ: Xscrabble

7. ڶ: Xloadimage

8. : Fortune

9. ġҵԭʼ뵵

10. 

11. οһĶ
     _________________________________________________________________
   
1. 

   ܶ׼ṩʽ UNIX,  Linux, ǽԭʼ뵵ѹɵ
   (archives)е. ͬ׼ԽԱڲͬĻִ, 
   ɽʡЩƷ춱ַа汾. ׼ĵһа汾
   ִڸʽʵ(incarnations),  Intel , DEC Alpha, RISC
   վ, ǵ. ҵ, ⽫""ĹƸʹ
   (end user), ʵ"ϵͳ", ڼǰͬ־.... Ȼ,
   ˵̲»򲻿˼, ָ˵һ
   .
   
2. ȡÿʼ

   ػʽȡһ׼.  (tarred)
   ұѹ (gzipped), Ϊ .tar.gz  .tgz ʽ. ȽƵһĿ
   ¼. Ȼ untar  gunzip . ʺϵ tar xzvf
   filename,  filename Ȼ嵵. ֽ⿪򳣳ᰲװʵ
   Ŀ¼. ע׼ .Z β, ǽҪʹ
   uncompress PACKAGENAME, Ȼ tar xvf PACKAGENAME Ҫ֮ǰĲ
   .
   
   ʱĵ untarred ҰװʹߵļĿ¼(home
   directory), ҲĳĿ¼, ׼趨ָ. 
   跨Ҫ untar õǴѶϢ, Ҳԭ. һ׼ļ, ر
    README / Install , , ༭趨/ Makefiles 
   Ҫ, 밲װָʾ. עͨ  ȥ Imake , Ϊ
   δԤڵĽ. ĳЩ׼Զװ,ǽִ make
   install öԪʵϵͳλ.
   
   ż, Ҫʹ patch,õгԭµԭʼĲ,
   (bug)δ(unarchived)ԭʼ. doc/
   README ֪㲻. ʹ Larry Wall ǿ 
   (patch) ֮﷨(syntax) patch < patchfile.
   
   ڿԿʼ  ̽׶.
   
3. ʹ Make

   Makefile ǽ̵ص. 򵥵ʽ, Makefile Ǹ script
   ,"Ԫ",׼Ŀִв. MakefileҲṩ
   Ĺ,Ҫ±ÿһ׼еԭʼ, вͬ
   (ǲͬԼ).
   
   ĳЩص, Makefile  cc  gcc. ʵǸǰ, C (or C++)
   ,  , Ǹ˳. תԭʼ(source)Ϊȥִ
   ĶԪ(binaries).
   
   ָ make ֻͨҪ make. ͨе׼ҪĿִ
   . Ȼ, make Ҳ,ǰװʵĿ¼ (make install) 
   ɾɵ object  (make clean). ִ make -n Ԥ, 
   г make (triggered), ûȥִ.
   
   ֻ򵥵ʹһԵ Makefile. ϸӵİװҪݺʽ
   (libraries), include ԼԴĿ¼. ر
   ǵҪ X11 libraries װʱ. Imake  xmkmf Ĺ.
   
    man page,Imakefile Ǹ"ģ(template)" Makefile. imake ߲
    Imakefile ϵͳʵ Makefile. Ȼ,е,
   Ҫִ xmkmf, Ҫ imake ָõ shell script, ҲǸǰ˽
   (front end). һڸ嵵 README  INSTALL ȡ
   رָʾ. 춸ϸĲ,Ķ imake  xmkmf  man pages.
   
   Ҫ֪ xmkmf  make Ҫ root ָ, رǵ make
   install ƶԪ뵽 /usr/bin  /usr/local/bin Ŀ¼. һʹߵ
   ֶ root Ȩ ʹ make ܻᵼ write access denied Ĵ
   ѶϢ, Ϊȱд(write)ϵͳĿ¼Ȩ. Ҳһ, Ķ
   Ԫκõʹʺϵִ(execute)Ȩ.
   
   ָ xmkmf ʹ Imake , һµĶʺϵͳ Makefile.
   ָ xmkmf ḽ -a , Զ make Makefiles, make
   includes,  make depend Ķ. 趨(variables)͸ʽ
   (library) λø. ʱû Imake , ֮
   INSTALL  configure  script, ҲᵽĿ. עҪִ
   configure, Ҫָ ./configure ȷĿǰĿ¼ȷ script
   configure Ǳ. ڴ󲿷ֵ, ڷ׼е README ˵
   װ.
   
   ͨһõķǴۼһ Makefile  xmkmf  һװ
   scripts . Makefile »Ϊϵͳ, ż
   Ҫ"Ť(tweak)"ֶ.
   
   һ㰲װ轫:
     * һ README õļ.
     * ִ xmkmf -a,  INSTALL  configure script.
     * һ Makefile.
     * Ҫ, ִһ make clean, make Makefiles, make includes, and
       make depend.
     * ִ make.
     * һȨ.
     * Ҫ, ִһ make install.
       
4. ˷

    xmkmf / make ܳɹûд,  [4]next section.
   Ȼ, ʵ, ڵһξȷĹ. ǵĻǷḻ
   ʱ,Ҫ춳.
   
4.1 

     *  make ʧܶ Link error: -lX11: No such file or
       directory, ʹ xmkmf . ζ Imake ûʵ
       װ.  Makefile ĵһûļ:
       
LIB=            -L/usr/X11/lib
INCLUDE=        -I/usr/X11/include/X11
LIBS=           -lX11 -lc -lm

       -L  -I л(switches)ֱͨȥġѰ
       library  include . , X11 libraries Ӧ
       /usr/X11/lib Ŀ¼,  X11 include  Ӧ
       /usr/X11/include/X11Ŀ¼. ĻǲԵ, ı
       Makefile  make.
       
     * ڷǳٵ,  root һ ldconfig ҲǸ: #
       /etc/ldconfig -n /lib ¹ʽʽ (shared library
       symbolic links). ²Ҫ.
       
     * Ŀǰһ xmkmf ʧ,  script:
       
         make -DUseInstalled -I/usr/X386/lib/X11/config

     * ʱԭʼҪʹþɰ X11R5 libraries .  R5 libs
        /usr/X11R6/lib (ڰװ Linux ʱ, ѡǷװ
       ), ȻֻҪȷ,ᵽҪĵط. R5 libs 
       libX11.so.3.1.0, libXaw.so.3.1.0,  libXt.so.3.1.0. һҪ
       ,  libX11.so.3 -> libX11.so.3.1.0. ҲҪʽ
       libX11.so -> libX11.so.3.1.0. Ȼ, Ҫ"ϵ(missing)"Ὠ
       , Ҫ root ʹָ ln -s libX11.so.3.1.0 libX11.so.
       
     * ĳЩ׼Ҫȥװһϵ汾. , StarDivision
       GmbH  StarOffice (suite)Ƕ(notorious)Ҫ libc
       version 5.4.4 .  root, Ҫһϵĺʽ
       (libraries)ʵĿ¼, ɾȥɵĺʽ(libraries),Ȼ
       . С: Ҫע, ΪŪ, ܻḶϵͳ
       Ĵ. ͨҵĺʽ(libraries) [5]Sunsite.
       
4.2 

     * ڰװõ Perl  shell script һ No such file or directory
       ѶϢ. ,鵵Ȩȷִ Լ鵵ͷ
       ʹ shell ʽ, ָ script ڵط. , script 
       ʼ:
       
#!/usr/local/bin/perl

        Perl ʵװ /usr/bin Ŀ¼,  /usr/local/bin Ŀ¼,
        script ޷ִ. ޸. script ͷĳ
       #!/usr/bin/perl, ÷ȷĿ¼, ln -s /usr/bin/perl
       /usr/local/bin/perl.
       
     * ĳЩ X11 Ҫ Motif ʽ(libraries)ܽ. ׼
       Linux ׼ûаװ Motif libraries, Ŀǰ Motif Ҫ
       $100-$200 Ļ (Ȼ [6]Lesstif ĳЩҲܹ). 
       Ҫ Motif ĳһ׼, ȱ Motif libraries, Ҳȡ
        ̬ĶԪ(statically linked binaries). ̬ڶԪ뱾
       뺯ʽг(library routines). ɶԪ뵵, 
       ȱٸúʽϵͳִ.
       
     * ִ configure script ᴴֵ Makefile, Ҫ跨
       ׼. ʾ configure, ҵ path ĳ
        configure. Ҫ configure ָ ӦҪ³ ./configure 
       ĿǰĿ¼µ.
       
     * ĳЩʽҪ setuid root, ΪҪ root Ȩ ִ. Ҫ
       Ŀ¼ָ root ָ chmod u+s filename. (עʽѾ
        root ӵ). 趨Ȩе setuid bit . 
       ʽڴȡϵͳӲ, modem  CD ROM drive,  SVGA libs 
       ʹ̨ģʽ(console mode), һر
       (notorious)ģ(emulation)׼. ʽ root ִ, һ
       ʹһ access denied ĴѶϢ, ɵ.
       : һ setuid  root ĳʽϵͳаȫϵķ
       . ʽ root ȨܶĳЩƺǱ. 趨
       setuid bit ǰ, ȷ֪óʽʲ, Ҫʱһԭʼ.
       
4.3 Ť΢

   ϣ Makefile ȷѡöϵͳѱѡ. ˵, 
    -O2 ѡ߲㼶ѻ -fomit-frame-pointer СԪ
    (Ȼ debugging ûд). ֪ʲ, κ
   , ǼཨĹ, ҪЩ.
   
4.4 ȥȡýһЭ

   ҵľ, 25%Ӧóʽ"ȫû". Լ50%"˵"
   Ľ, ҪŬġΧĵΪ. ȻʾĳЩ׼
   ޷. ʹ, Щ Intel ELF / a.out Ԫ, Ҳ
   [7]Sunsite, [8]TSX-11 archive طҵ. Ҳ, Ĵ߿
   õĶԪرĻʹ.
   
   עȡԤȱõĶԪ, ҪǷϵͳ:
     * Ԫ Ӳ (i.e., Intel x86).
     * Ԫĺ(kernel) (i.e., a.out  ELF).
     * ĺʽ(libraries)µ.
       
   ȫʧ, ںʵ ȺѰæ, 
   [9]comp.os.linux.x  [10]comp.os.linux.development. һֻǲ
   Ļ, , ҲȤ.
   
5. Ჽ

   һ׼ļǷĳЩҪ ( .bashrc 
   .cshrc) Լ Ƿ .Xdefaults  .Xresources Ҫ.
   
   иӦóʽڶĵ, ͨ Xfoo.ad ԭ Xfoo ׼. 
   , ༭ Xfoo.ad ʺĻ, Ȼ (mv)  Xfoo  
    root  װ /usr/lib/X11/app-defaults Ŀ¼, ûܻ
   Ϊ, ִܾ.
   
   ׼һϵĸʽ man pages.  root , 
   Xfoo.man ʵ /usr/man Ŀ¼ (man1 - man9), .
   ,  Xfoo.man  /usr/man/man4, ӦΪ Xfoo.4
   (mv Xfoo.man Xfoo.4). һԼʹߵ man1, Ϸ
   man6, ׼ man8 (һ man ļ ȡøϸ).Ȼ,
   ϵͳԲԼ, ֻҪϲ.
   
   ĳЩ׼ᰲװԪ(binaries)ںʵϵͳĿ¼, 仰˵, û
   install ѡ Makefile . ,  root ָƶԪ
   (binaries) usr/local/bin Ŀ¼ֶװԪ(binaries).
   
   עĳЩȫ,ڴ󲿷,Ӧû make install Զ
   . , README  INSTALL ļᵽ.
   
6. һ: Xscrabble

   Matt Chapman Xscrabble ƺǸȤĳʽ, ΪǸ̰
   Scrabble&trade;(ƴϷ).,ѹ, ҽ README 
   в:
   
     xmkmf
     make Makefiles
     make includes
     make

   Ȼ...
     _________________________________________________________________
   
gcc -o xscrab -O2 -O -L/usr/X11R6/lib
init.o xinit.o misc.o moves.o cmove.o main.o xutils.o mess.o popup.o
widgets.o display.o user.o CircPerc.o
-lXaw -lXmu -lXExExt -lXext -lX11 -lXt -lSM -lICE -lXExExt -lXext -lX11
-lXpm -L../Xc -lXc

BarGraf.o(.text+0xe7): undefined reference to `XtAddConverter'
BarGraf.o(.text+0x29a): undefined reference to `XSetClipMask'
BarGraf.o(.text+0x2ff): undefined reference to `XSetClipRectangles'
BarGraf.o(.text+0x375): undefined reference to `XDrawString'
BarGraf.o(.text+0x3e7): undefined reference to `XDrawLine'
etc.
etc.
etc...
     _________________________________________________________________
   
    [11]comp.os.linux.x Ⱥѯʹ, Щ˺ĵָƺ
   Xt, Xaw, Xmu,  X11 libs û(linker)ҵõ. ...
   
   Ҫ Makefiles,  src Ŀ¼µǸҸȤ.  Makefile
   һж LOCAL_LIBS : LOCAL_LIBS = $(XAWLIB) $(XMULIB) $(XTOOLLIB)
   $(XLIB) ָ libs ûбҵ.
   
   ¸ָ LOCAL_LIBS ĵط, ҿ Makerfile 495:
   
      $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LOCAL_LIBS) $(LDLIBS)
$(EXTRA_LOAD_FLAGS)

    LDLIBS ʲ?
   
      LDLIBS = $(LDPOSTLIB) $(THREADS_LIBS) $(SYS_LIBRARIES)
$(EXTRA_LIBRARIES)

   SYS_LIBRARIES :
   
 SYS_LIBRARIES = -lXpm -L../Xc -lXc

   Ǹ! ʧ libraries.
   
   Ҫ LOCAL_LIBS ֮ǰ LDLIBS... , һҪȥ
    Makefile Ǹд495е $(LOCAL_LIBS)  $(LDLIBS) , ڱ
   :
   
        $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LDLIBS) $(LOCAL_LIBS)
$(EXTRA_LOAD_FLAGS)                          ^^^^^^^^^^^^^^^^^^^^^^^

   ĸ,ٴִ make , , ο. Ȼ,
   Xscrabble ȻҪһЩ΢(fine tuning]Ū(twiddling), 
   ֵԼעĳЩԭʼ뵵֮һ, Ϊ,ѸҺü
   Сʱǲ.
   
   Լ e-mail [12]Matt Chapman, Ҵ [13]home page 
   Xscrabble.
     _________________________________________________________________
   
       Scrabble  Milton Bradley Co., Inc. ע̱.
     _________________________________________________________________
   
7. ڶ: Xloadimage

   ϼ򵥵. xloadimage ʽ뵽ҵͼιƺǺ
   . Ҵһ Mui  Quercia ĺ [14]X User Tools  CD 
   ԭʼĿ¼(source directory), ֱӸ xloadi41.gz . Ԥ
   ,  tar xzvf ⿪е. Ȼ, make Ĵж.
     _________________________________________________________________
   
gcc -c -O -fstrength-reduce -finline-functions -fforce-mem
-fforce-addr -DSYSV  -I/usr/X11R6/include
-DSYSPATHFILE=\"/usr/lib/X11/Xloadimage\" mcidas.c

In file included from /usr/include/stdlib.h:32,
                 from image.h:23,
                 from xloadimage.h:15,
                 from mcidas.c:7:
/usr/lib/gcc-lib/i486-linux/2.6.3/include/stddef.h:215:
conflicting types for `wchar_t'
/usr/X11R6/include/X11/Xlib.h:74: previous declaration of
`wchar_t'
make[1]: *** [mcidas.o] Error 1
make[1]: Leaving directory
`/home/thegrendel/tst/xloadimage.4.1'
make: *** [default] Error 2
     _________________________________________________________________
   
   ѶϢ.
   
   һµ image.h 23.
     _________________________________________________________________
   
       #include <stdlib.h>
     _________________________________________________________________
   
   !  xloadimage, wchar_t ԭʼĳѾظڱ׼ include
    stdlib.h ѶĶ. Խ image.h 23бע(commenting
   out), Ҳ stdlib.h include ǲҪ.
   
   ʱ, build ûκش. xloadimage ʽڹܶ.
   
8. : Fortune

   ҪĳЩ C ʽ֪ʶ. 󲿷ֵ Linux  C д, 
   ѧ C ԵĶκ尲װ˻.
   
   õ(notorious) fortune ʽÿ Linux ʱĬ
   "fortune cookie". ҵ (˫˼), 跨 Red Hat ׼
   2.0.30 ĺ½, һصĴ.
     _________________________________________________________________
   
~/fortune# make all


gcc -O2 -Wall -fomit-frame-pointer -pipe   -c fortune.c -o
fortune.o
fortune.c: In function `add_dir':
fortune.c:551: structure has no member named `d_namlen'
fortune.c:553: structure has no member named `d_namlen'
make[1]: *** [fortune.o] Error 1
make[1]: Leaving directory `/home/thegrendel/for/fortune/fortune'
make: *** [fortune-bin] Error 2
     _________________________________________________________________
   
   һ fortune.c, йļ.
     _________________________________________________________________
   
   if (dirent->d_namlen == 0)
            continue;
        name = copy(dirent->d_name, dirent->d_namlen);
     _________________________________________________________________
   
   Ҫҳ dirent  structure, û(declared) fortune.c 
   ,  grep dirent Ƿԭʼĵ, Ҳû. Ȼ,
    fortune.c Ϸ.
     _________________________________________________________________
   
#include <dirent.h>
     _________________________________________________________________
   
   ƺϵͳʽ include , Ҫ dirent.h ĺλ
   /usr/include. ʵ, dirent.h ȷ /usr/include , õûа
   dirent  structure. Ȼ, οһ dirent.h .
     _________________________________________________________________
   
#include <linux/dirent.h>
     _________________________________________________________________
   
   , ȥ /usr/include/linux/dirent.h, ǿҵҪ
   structure.
     _________________________________________________________________
   
struct dirent {
        long            d_ino;
        __kernel_off_t  d_off;
        unsigned short  d_reclen;
        char            d_name[256]; /* We must not include
limits.h! */
};
     _________________________________________________________________
   
   㹻ȷ,  structure ûа d_namelen, һ൱ѡ
   . ܵ d_reclen, Ϊ  structure member ʾĳ
   length  short integer. , d_ino,  inode number, 
    name  type. ʵ, ǴǴ "directory entry"
   structure, Ԫرʾ, , inode,  length ( blocks 
   λ). ƺǵĲܺ.
   
   Ǳ༭ fortune.c, Ҹı551к553е d_namelen 
   d_reclen.  make all. Success. νûд. ܹ
   fortune  "cheap thrills"
   
9. ġҵԭʼ뵵

   ܿʹ»õ֪ʶһЩߺöϵ
   ͳ, ҵ, [15]Linux Applications and Utilities Page, 
   ںܺλ CD ROM ĵ,  [16]Red Hat, [17]InfoMagic, Լ
   .
   
   һڶԭʼı [18]comp sources UNIX archive.
   
   ܶ UNIX ԭʼ뷢 [19]alt.sources Ⱥ. Ҫرԭʼ
   װ, ص [20]alt.sources.wanted Ⱥ. һ
   ĵطǲ鿴 [21]comp.os.linux.announce Ⱥ. Ҫȡ [22]Unix
   sources ̳ͨ, ĸ subscribe ѶϢ.
   
    [23]alt.sources Ⱥĵ ftp վ:
   
     * [24]ftp.sterling.com/usenet/alt.sources/
     * [25]wuarchive.wustl.edu/usenet/alt.sources/articles
     * [26]src.doc.ic.ac.uk/usenet/alt.sources/articles
       
10. 

   ܽ, ۲ӻʹʲᶼɲһ (ҸѶȴżԻа). ʹ
   ȫ,ʧлѧϰҪ. ÿʧĲ, ÿʧܹ
     ֪ʶ.
   
11. οһĶ

BORLAND C++ TOOLS AND UTILITIES GUIDE, Borland International, 1992,
pp. 9-42.
[Borland C++, ver. 3.1. ķֲ֮һ. ˺ܺý﷨͸,
ʹ Borland  DOS ²ŵʵ.]

DuBois, Paul: SOFTWARE PORTABILITY WITH IMAKE, O'Reilly and Associates,
1996, ISBN 1-56592-226-3.
[˵ imake ο, Ȼдʱ,δȡ.]

Frisch, Aeleen: ESSENTIAL SYSTEM ADMINISTRATION, O'Reilly and
Associates, 1995, ISBN 1-56592-127-5.
[׿ԽϵͳֲѾиԲ̸.]

Lehey, Greg: PORTING UNIX SOFTWARE, O'Reilly and Associates, 1995, ISBN
1-56592-126-7.

Mui, Linda  Valerie Quercia: X USER TOOLS, O'Reilly and Associates,
1994, ISBN 1-56592-019-8, pp. 734-760.

Oram, Andrew  Steve Talbott: MANAGING PROJECTS WITH MAKE, O'Reilly
and Associates, 1991, ISBN 0-937175-90-0.

Peek, Jerry  Tim O'Reilly  Mike Loukides: UNIX POWER TOOLS,
O'Reilly and Associates / Random House, 1997, ISBN 1-56592-260-3.
[ܰĸԴ, дʹùܴԭʼ,
ʹڱ۵ķ.]

Stallman, Richard M.  Roland McGrath: GNU MAKE, Free Software
Foundation, 1995, ISBN 1-882114-78-7.
[ӦҪĶ.]

Welsh, Matt  Lar Kaufman: RUNNING LINUX, O'Reilly and Associates,
1996, ISBN 1-56592-151-8.
[Ȼȫ Linux οõ, ȻĳЩطȱٱȽ.]

   Ȼ make, imake, xmkmf, gcc, ldconfig, gzip, tar,  patch  man
   pages.

References

   1. mailto:thegrendel@theriver.com
   2. http://personal.riverusers.com/~thegrendel/
   3. mailto:r6921068@ms.cc.ntu.edu.tw
   4. file://localhost/tmp/zh-sgmltools.18133/Software-Building-HOWTO.txt.html#finalsteps
   5. ftp://sunsite.unc.edu/
   6. http://www.lesstif.org/
   7. ftp://sunsite.unc.edu/
   8. ftp://tsx-11.mit.edu/
   9. news://comp.os.linux.x/
  10. news://comp.os.linux.development/
  11. news://comp.os.linux.x/
  12. mailto:matt@belgarath.demon.co.uk
  13. http://www.belgarath.demon.co.uk/programs/index.html
  14. file://localhost/tmp/zh-sgmltools.18133/Software-Building-HOWTO.txt.html#refs
  15. http://www.redhat.com/linux-info/linux-app-list/linapps.html
  16. http://www.redhat.com/
  17. mailto:orders@infomagic.com
  18. ftp://ftp.vix.com/pub/usenet/comp.sources.unix/
  19. news://alt.sources/
  20. news://alt.sources.wanted/
  21. news://comp.os.linux.announce/
  22. mailto:unix-sources@pa.dec.com
  23. news://alt.sources/
  24. ftp://ftp.sterling.com/usenet/alt.sources/
  25. ftp://wuarchive.wustl.edu/usenet/alt.sources/articles
  26. ftp://src.doc.ic.ac.uk/usenet/alt.sources/articles
