








			     Linux ½׼

     :Mendel Leo Cooper1  http://personal.riverusers.com/~thegrendel/

				:J.S.Lin2

			    v1.52, 27 December 1997



				   Abstract

     Ƿݹ㷺ָļ,"һ" UNIX 巢׼ Linux .



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,õгԭµԭʼĲ,

____________________

1. <URL:mailto:thegrendel@theriver.com>

2. <URL:mailto:r6921068@ms.cc.ntu.edu.tw>

 Linux ½׼ 						      1





 Linux ½׼ 						      2



(bug)δ(unarchived)ԭʼ.  doc/ README
֪㲻.  ʹ Larry Wall ǿ ޲(patch)
֮﷨(syntax) patch < patchfile.

ڿԿʼ  ̽׶.


3.  ʹ Make

Makefile ǽ̵ص. 򵥵ʽ, Makefile Ǹ script
,"Ԫ",׼Ŀִв.  Make
fileҲṩ׼Ĺ,Ҫ±ÿһ׼еԭʼ,
вͬ(ǲͬԼ).

ĳЩص, Makefile  cc  gcc.  ʵǸǰ, C (or C++) ,
 , Ǹ˳.  תԭʼ(source)ΪȥִеĶԪ(bina
ries).

ָ 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  config
ure  script, ҲᵽĿ.  עҪִ	configure, Ҫָ
./configure ȷĿǰĿ¼ȷ script configure Ǳ.
ڴ󲿷ֵ, ڷ׼е README ˵װ.

ͨһõķǴۼһ Makefile  xmkmf  һװ scripts
.  Makefile »Ϊϵͳ,
żҪ"Ť(tweak)"ֶ.

һ㰲װ轫:










 Linux ½׼ 						      3



    һ README õļ.

    ִ xmkmf -a,  INSTALL  configure script.

    һ Makefile.

    Ҫ, ִһ make clean, make Makefiles, make includes, and make
     depend.

    ִ make.

    һȨ.

    Ҫ, ִһ make install.


4.  ˷

 xmkmf / make ܳɹûд,  next section (section 5.,
page 5).  Ȼ, ʵ, ڵһξȷĹ.
ǵĻǷḻʱ,Ҫ춳.

4.1  

     make ʧܶ Link error: -lX11: No such file or directory,
     ʹ xmkmf .  ζ Imake ûʵװ.   Make
     file ĵһûļ:


	  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 sym
     bolic links). ²Ҫ.

    Ŀǰһ xmkmf ʧ,  script:

		   make -DUseInstalled -I/usr/X386/lib/X11/config



    ʱԭʼҪʹþɰ X11R5 libraries .   R5 libs 
     /usr/X11R6/lib (ڰװ Linux ʱ, ѡǷװǵ),
     ȻֻҪȷ,ᵽҪĵط.  R5 libs 








 Linux ½׼ 						      4



     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) Sunsite3 .

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
     Ļ (Ȼ Lesstif4  ĳЩҲܹ).  Ҫ 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), һرõ(noto
     rious)ģ(emulation)׼.  ʽ root ִ, һʹһ
     access denied ĴѶϢ, ɵ.


____________________

3. <URL:ftp://sunsite.unc.edu>

4. <URL:http://www.lesstif.org/>







 Linux ½׼ 						      5



     : һ setuid  root ĳʽϵͳаȫϵķ.
     ʽ root ȨܶĳЩƺǱ.  趨 setuid bit ǰ,
     ȷ֪óʽʲ, Ҫʱһԭʼ.

4.3  Ť΢

ϣ Makefile ȷѡöϵͳѱѡ.  ˵, 趨 -O2
ѡ߲㼶ѻ -fomit-frame-pointer СԪ (Ȼ debug
ging ûд). ֪ʲ, κ,
ǼཨĹ, ҪЩ.

4.4  ȥȡýһЭ

ҵľ, 25%Ӧóʽ"ȫû".  Լ50%"˵"Ľ,
ҪŬġΧĵΪ.  ȻʾĳЩ׼ζ޷.
ʹ, Щ Intel ELF / a.out Ԫ, Ҳ Sunsite5 , TSX-11
archive6  طҵ.  Ҳ,
Ĵ߿ṩõĶԪرĻʹ.

עȡԤȱõĶԪ, ҪǷϵͳ:

    Ԫ Ӳ (i.e., Intel x86).

    Ԫĺ(kernel) (i.e., a.out  ELF).

    ĺʽ(libraries)µ.

ȫʧ, ںʵ ȺѰæ, comp.os.linux.x 
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)

____________________

5. <URL:ftp://sunsite.unc.edu>

6. <URL:ftp://tsx-11.mit.edu>







 Linux ½׼ 						      6



usr/local/bin Ŀ¼ֶװԪ(binaries).

עĳЩȫ,ڴ󲿷,Ӧû make install Զ.
, README  INSTALL ļᵽ.


6.  һ: Xscrabble

Matt Chapman Xscrabble ƺǸȤĳʽ, ΪǸ̰ Scrab
ble[TM](ƴϷ).,ѹ, ҽ 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...

 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









 Linux ½׼ 						      7



Ǹ! ʧ 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 Matt Chapman7 , Ҵ home  page8	 Xscrabble.

	    Scrabble  Milton Bradley Co., Inc. ע̱.


7.  ڶ: Xloadimage

ϼ򵥵. xloadimage ʽ뵽ҵͼιƺǺ.
Ҵһ Mui  Quercia ĺ X User Tools (section 11., page 10) 
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>



____________________

7. <URL:mailto:matt@belgarath.demon.co.uk>

8. <URL:http://www.belgarath.demon.co.uk/programs/index.html>







 Linux ½׼ 						      8



!  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 ʱĬ "for
tune 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.















 Linux ½׼ 						      9



     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.  ġҵԭʼ뵵

ܿʹ»õ֪ʶһЩߺöϵͳ,
ҵ, Linux Applications and Utilities Page9 ,
ںܺλ CD ROM ĵ,  Red Hat10 , InfoMagic11 , Լ.

һڶԭʼı comp sources UNIX archive12 .

ܶ UNIX ԭʼ뷢 alt.sources Ⱥ. Ҫرԭʼװ,
ص alt.sources.wanted Ⱥ.  һĵطǲ鿴
comp.os.linux.announce Ⱥ. Ҫȡ Unix sources13  ̳ͨ, ĸ
subscribe ѶϢ.

alt.sources Ⱥĵ ftp վ:

    ftp.sterling.com/usenet/alt.sources/14

    wuarchive.wustl.edu/usenet/alt.sources/articles15


____________________

9. <URL:http://www.redhat.com/linux-info/linux-app-list/linapps.html>

10.<URL:http://www.redhat.com/>

11.<URL:mailto:orders@infomagic.com>

12.<URL:ftp://ftp.vix.com/pub/usenet/comp.sources.unix/>

13.<URL:mailto:unix-sources@pa.dec.com>

14.<URL:ftp://ftp.sterling.com/usenet/alt.sources/>

15.<URL:ftp://wuarchive.wustl.edu/usenet/alt.sources/articles>







 Linux ½׼ 						     10



    src.doc.ic.ac.uk/usenet/alt.sources/articles16


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.




____________________

16.<URL:ftp://src.doc.ic.ac.uk/usenet/alt.sources/articles>







 Linux ½׼ 						     11





































































				   CONTENTS



1.    ................................................................... 1

2.  ȡÿʼ .............................................................. 1

3.  ʹ Make ............................................................... 2

4.  ˷ ................................................................ 3
    4.1  ............................................................ 3
    4.2  ............................................................ 4
    4.3 Ť΢ .......................................................... 5
    4.4 ȥȡýһЭ  ............................................... 5

5.  Ჽ ................................................................ 5

6.  һ: Xscrabble ................................................... 6

7.  ڶ: Xloadimage .................................................. 7

8.  : Fortune ..................................................... 8

9.  ġҵԭʼ뵵  ................................................... 9

10.   .................................................................. 10

11. οһĶ ................................................... 10



























				       i


