








			    b Linux Uإ߳nM

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

				Ķ:J.S.Lin2

			    v1.52, 27 December 1997



				   Abstract

     oOsxޤ,iΨӫإ"@" UNIX noMb Linux U.



1.  ²

ܦhnM󴣨ѵU UNIX, ]A Linux,
ONlXɮYɮ(archives)ӵo檺.
ۦPMiHإߥHKbPHW,
åBoi`٨ǳn馨~ӧK󥲶syUصo檩.
nM󪺳@o檩GbU(incarnations), Ob Intel ,
DEC Alpha, RISC u@, ƦܬOqD.  O,
oN"إ"n骺u@F̲רϥΪ(end user), ڤWO"tκ޲z",
YbLeP...A.  Mo,
{uӻoL{äOݰ_ӨiȩΤiĳ, NoީҸѻ@.


2.  qo}l

AUΨ䥦覡o@ӳnM. ̱`pOQ]_ (tarred)
ӥBQY (gzipped),  .tar.gz   .tgz Φ.  Nƻs@u@ؿ.
M untar M gunzip Bz.	Bz̾AXROO tar xzvf filename, oت
filename MOnɦW.  oظѶ}{Ǳ``|w˾AɮצbҶ}Ҫlؿ.
`NOpGMW٦ .Z , Nnϥ uncompress PACKAGENAME, MA tar
xvf PACKAGENAME ӤnΤeBJ.

ɥ]_Ӫɮץ untarred Bw˦ۨϥΪ̪aؿ(home directory),
Ϊ̤]\ObYӨ䥦ؿ, OM]wƩҫw.  YA]kn untar
ӱo쪺O~T, ]\NO].  Ū@UM, SOO README M/
Install ɮ, pGsb, s]wɮשM/ Makefiles pһݭn,
YPw˫ܲŦX.  `NOq`  h Imake ɮ, ]oi঳wG.
YǳnM󤹳\۰ʦw˵{,OǥѰ make install
өmGXbAtΦm.

, Aiݭnϥ patchɮ,ɮצCX쥻Pslɮתt,

____________________

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

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

b Linux Uإ߳nM 						      1





b Linux Uإ߳nM 						      2



ӤɯũΥ[J(bug)ץܥ](unarchived)lɮ.  docɮ׻P/ README
ɮ׷|iAo⤣ӱp.  ϥ Larry Wall jO ׸(patch)
u㤧`yk(syntax)O patch < patchfile.

A{biH}li إ L{qF.


3.  ϥ Make

Makefile Oإ߹L{I. b²檺Φ, Makefile NO script
,OΨӽsĶΫإ"GX",M󪺥i泡.  Make
file]iHѳnMɯŪu,ӤݭnssĶC@ӦbM󤤪lɮ,
䦳Pp(άOPw).

YǯSIO, Makefile } cc  gcc.  oڤWOӫeBz, C (or C++) sĶ,
M s, ӨӶ.  oL{ഫlX(source)iuh檺GX(bina
ries).

UO make q`unJ make.	oq`إ߰QפMҦݭni.
M, make ]Lu@,OwɮצܦXAؿ (make install) ӥBRª
object ɮ (make clean).   make -n \wإ߹L{, NOCXҦ make
ҳ_(triggered)ҦRO, Suh楦.

ub²檺nϥΤ@ʪ Makefile. w˻ݭnھڨ禡w(libraries),
include ɮץHΧAӧO귽ҦbؿӶqws.  oSOOݭn X11 libraries
Ӧw˫إ߮.  Imake M xmkmf io˪u@.

ޥΦ man page,Imakefile O"ҪO(template)" Makefile.  imake uѦ
Imakefile ھڧAtγyXXA Makefile.  M,XGbҦpU,An
xmkmf, OnU imake OΪ shell script, ]NOӫeݤ(front end).
\@Ubnɮ׶ README  INSTALL ɮץHoSO.
ܩԲӪBJR,о\Ū imake M xmkmf  man pages.

nDO xmkmf M make iݭnH root ӤUO, SOO make install
ӷhGX /usr/bin  /usr/local/bin ؿ. H@ϥΪ̪Ӥ root
vO Өϥ make Ni|ɭP write access denied ~T,
]AʤּgJ(write)ܨtΥؿv. ]ˬd@U,
ҳyXӪGXAPLAΪϥΪ̦AX(execute)v.

UO xmkmf Өϥ Imake ɮ, إߤ@ӷsӥBAXAtΪ Makefile.
`aUO xmkmf |[ -a ޼, ]Ӧ۰ʦa make Makefiles, make
includes, M make depend ʧ@. o|]wܼ(variables)Mw禡w(library)
msĶMs. ɷ|S Imake ɮ, ަӥNO INSTALL M config
ure  script, ]|o˪ت.  `NOpGAn	configure, nUO
./configure HTObثeؿUT script configure OQIs.
bjp, boM󤤪 README ɮ׷|w˨BJ.

q`@ӦnkOq~[˵@U Makefile O xmkmf  䤤@Ӧw˪ scripts
ҳyXӪ.  Makefile `U|AtΦӭץ,
Aӥiݭn"ۧ(tweak)"Τʦaץ~.

A@w˨BJN|O:










b Linux Uإ߳nM 						      3



    Ū@U README ɮשM䥦XΪ.

     xmkmf -a, ٬O INSTALL  configure script.

    ˬd@U Makefile.

    pGݭn, @U make clean, make Makefiles, make includes, and make
     depend.

     make.

    ˬd@Uv.

    pGݭn, @U make install.


4.  JAx

pG xmkmf M/ make ܦ\S~, AiHۤ next section (section 5.,
page 5).  M, buͬ, ܤ֨ƱbĤ@NTu@.
oNOA״I,ni.

4.1  s~

    pG make ѦӥX{ Link error: -lX11: No such file or directory,
     ƦܬObϥ xmkmf .  oiN Imake ɮרSAa˦n.  ˬd Make
     file Ĥ@So˪X:


	  LIB=		  -L/usr/X11/lib
	  INCLUDE=	  -I/usr/X11/include/X11
	  LIBS= 	  -lX11 -lc -lm



     -L M -I (switches)|qisĶMsOhشM library M
     include ɮ.  boҤl,  X11 libraries ӬOb /usr/X11/lib ؿ, 
     X11 include ɮ ӬOb /usr/X11/include/X11ؿ.
     pGobAWO諸,  Makefile ӥBAո make.

    bD`֪p, H root ]@U ldconfig ]\Oӵ:

     # /etc/ldconfig -n /lib N|s@ɦ禡wŸs (shared library sym
     bolic links). ob`ΤUOݭn.

    ثet@ƬOpG xmkmf , hոդUC script:

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



    ɭlXݭnϥª X11R5 libraries ӫإ.  pGA R5 libs b
     /usr/X11R6/lib (Abw Linux , AOܬO_w˥̪),
     MAuݭnTw,Asnһݭnإߪa.  R5 libs O








b Linux Uإ߳nM 						      4



     libX11.so.3.1.0, libXaw.so.3.1.0, M libXt.so.3.1.0. @Aݭns,
     O libX11.so.3 -> libX11.so.3.1.0.  jn]ݭnoӧΦs libX11.so
     -> libX11.so.3.1.0.  M, nNo"_(missing)"sئn, nH root
     ϥγoO ln -s libX11.so.3.1.0 libX11.so.

    YǮM|nDAhwˤ@өΥHWɯŪ. |ҦӨ, StarDivision GmbH 
     StarOffice ե(suite)OcWL(notorious)nD libc version 5.4.4
     Χs. H root, Aݭnƻs@өΥHW禡w(libraries)ܦXAؿ,
     Rhª禡w(libraries),M᭫]Ÿs.

     p: bon~`N, ]pGAV, Ai|IXAtΤB@N.

     Aq`iHɯŪ禡w(libraries)b Sunsite3 .

4.2  䥦D

    bw˦n Perl  shell script A@ No such file or directory
     ~T. bop,ˬdɮvӽTwɮץi
     Hˬdɮ׼YO_tϥ shell ε{,  script Ҧba.
     |ҦӨ, script }lp:

	  #!/usr/local/bin/perl


     pG Perl ڸ˦bA /usr/bin ؿ, ӤO /usr/local/bin ؿ, 
     script Lk.  Ӥkӭק. script ɮ׼Y令 #!/usr/bin/perl,
     ΥβŸsܥTؿ, ln -s /usr/bin/perl /usr/local/bin/perl.

    Y X11 nnD Motif 禡w(libraries)~إ.  ӼзǪ Linux
     oMèSw Motif libraries, ӥBثe Motif ٭nB~ $100-$200
     O (MKOn Lesstif4  bYǳX]).  pGAݭn Motif
     ӫإ߬Y@M, ʤ Motif libraries, ]\iHo
     RAsGX(statically linked binaries).
     RAsbGXǤJ禡w{(library routines).
     oyGXɮפjF\h, OXibʤָӨ禡wtΤW.

     configure script |гy_Ǫ Makefile,
     OPAҭn]kإߪM󭽤ۤz. oܶ]ۿ~ configure,
     A path WYBL configure. ҥHnU configure O ӭnU
     ./configure YثeؿU.

    Yǵ{|nD setuid root, FnH root vO Ӱ.
     nFoؿOO Hroot UO chmod u+s filename.
     (`NOo{wgO root Ҿ֦F).  ob]wɮv setuid bit
     ܦ.  o˥Φb{bstεw,O modem  CD ROM drive, η
     SVGA libs QϦbDxҦ(console mode), Ob@ӯSOcWL(noto
     rious)(emulation)M.  pG{Q root , @ϥΪ̤@
     access denied ~T, QNOo˳y.


____________________

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

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







b Linux Uإ߳nM 						      5



     ĵi: @Ӧ setuid  root {iണXAtΦwWI.
     oӵ{iH root vOӶ]өҥHYǯ}`b.  b]w setuid bit e,
     TwADӵ{b, nɬݤ@UlX.

4.3  ۧPL

AiƱˬd Makefile ӽTwιAtγ̨νsĶﶵ.  |Ҩӻ, ]w -O2
XШӿ̰hŲ̄ΤƦ -fomit-frame-pointer XШӳy̤pGX (M debug
ging |S}). DADAb, ӥBb󱡪pU,
D}Wإߪu@w, _hno.

4.4  hoi@BU

bڪg, j25%ε{إ"Sx".  t~j50%"QA"إ,
nIXVOdqL췥x.  MܦYǮMLצp󳣵Lkإ.
YϨ,  Intel ELF M/ a.out GX, ]ib Sunsite5 , TSX-11
archive6  Ψ䥦a.  ]\,
n骺гy̥iHѽsĶnGXASOϥ.

`NOpGAowsĶnGX, A|ݭnˬdO_PAtάۮe:

    oGXbA wW] (i.e., Intel x86).

    oGXPA֤(kernel)ۮe (i.e., a.out  ELF).

    A禡w(libraries)O̷s.

pG, AiHbXA sDsմMD, Obcomp.os.linux.x 
comp.os.linux.development. U@AuOB, K, ոդ]O쪺.


5.  ̫BJ

Ū@UnM󪺤ӨMwO_Yܼƻݭn] (b .bashrc  .cshrc) H
O_ .Xdefaults M .Xresources ɮ׻ݭnվ.

i঳ε{wɮ, q`s Xfoo.ad b쥻 Xfoo oM.  pGo,
s Xfoo.ad ɮ׾AXA, M᭫sRW (mv)  Xfoo ӥB H root 
w˥ /usr/lib/X11/app-defaults ؿ, So˰i|yn欰ܩ_,
Ʀܩڵ.

jhƪnM@өΥHW榡 man pages.  H root , ƻs Xfoo.man
ɮרXA /usr/man ؿ (man1 - man9), ӮھڨAsRW. |ҦӨ, pG
Xfoo.man GOb /usr/man/man4, өRW Xfoo.4 (mv Xfoo.man Xfoo.4).
ھڤ@wϥΪ̪RO\b man1, COb man6, Ӻ޲zMOb man8 (ݤ@U
man  HoԲӸ).M,bAtΧAiHӳoӬw, unAw.

YǮM󤣷|wˤGX(binaries)bXAtΥؿ, yܻ, L̨S install
ﶵb Makefile . pGOop, AiH root ƻsGX(binaries)

____________________

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

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







b Linux Uإ߳nM 						      6



usr/local/bin ؿӤʦwˤGX(binaries).

`NOYǩΥWzBJ,bjΤU,ӷ| make install Ӧ۰ʾާ@.
pGOo, README  INSTALL ɷ|o.


6.  Ĥ@ӨҤl: Xscrabble

Matt Chapman Xscrabble GOӻᦳ쪺{, ]ڴOӳg Scrab
ble[TM](rC)a.ڤUU,, ӥBإߥH README ɮפUCBJ:

	  xmkmf
	  make Makefiles
	  make includes
	  make

Mॿ`B@...

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

ڦb comp.os.linux.x sDsո߰ݹL, ӥBǤHnߪXG Xt, Xaw, Xmu,
M X11 libs Ss(linker)o. ...

ӥDn Makefiles, ӥBb src ؿUڷP.  b Makefile
@榳wq LOCAL_LIBS : LOCAL_LIBS = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
oҫ libs èSQs.

Uӫ LOCAL_LIBS a, ڬݨӦb Makerfile 495:

	   $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LOCAL_LIBS) $(LDLIBS)
     $(EXTRA_LOAD_FLAGS)

Ӳ{b LDLIBS OO?

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

SYS_LIBRARIES O:

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









b Linux Uإ߳nM 						      7



O! NOo˿ libraries.

jsݭnb LOCAL_LIBS eݨ LDLIBS...	ҥH, Ĥ@ƭnեhק
Makefile NOgb495檺 $(LOCAL_LIBS) M $(LDLIBS) , ҥH{bܦ:

	     $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LDLIBS) $(LOCAL_LIBS)
     $(EXTRA_LOAD_FLAGS)			  ^^^^^^^^^^^^^^^^^^^^^^^

bW,ڸյۦA make , @, oi`]F.  M, Xscrabble
Mݭn@ǷL(fine tuning]P(twiddling),
OsRWrHμеYǻUԭzblXɮפ@,
],wڦnXӤpɪ.

AiHH e-mail Matt Chapman7 , ӥBqL home  page8	U Xscrabble.

	    Scrabble O Milton Bradley Co., Inc. UӼ.


7.  ĤGӨҤl: Xloadimage

oӨҤlX²檺D. xloadimage {[JڪϧΤu@զGOܦ.
ڱq@ Mui M Quercia ҵ۪n X User Tools (section 11., page 10) Ҫ
CD WlXؿ(source directory), ƻs xloadi41.gz ɮפU. pw,
 tar xzvf Ѷ}Ҧɮ. M, make X{FOHQ~ӥB_.

     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

o~Tt̮ڥu.

ݤ@Uɮ 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>







b Linux Uإ߳nM 						      8



ګ! b xloadimage, wchar_t lXYBwgƩwqFbз include ɮ
stdlib.h wwqF.	ոձNb image.h 23е(commenting out)_,
]\ stdlib.h include Ojݭn.

, build L{S󭫤j~.  xloadimage {{b\ೣ`.


8.  ĤTӨҤl: Fortune

̫ҤlݭnY C {]p. j Linux nO C g, ӥBܤ־I C
㪺Qnw˪H|Uq.

cWL(notorious) fortune {bC Linux }_ӮɨqXqλy "for
tune cookie".  a (N䪺), ]kb Red Hat oM 2.0.30
֤ߤUإ,X{F @Y~.

     ~/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

ݤ@U fortune.c, pXbo.

	if (dirent->d_namlen == 0)
		 continue;
	     name = copy(dirent->d_name, dirent->d_namlen);

ڭ̻ݭnX dirent  structure, Sŧi(declared)b fortune.c ɮפ,
Q grep dirent ӨqXO_b䥦lXɮפ, ]S. M, b fortune.c
ɪ̤W観UCo.

     #include <dirent.h>

oGOtΨ禡w include ɮ, ҥHn dirent.h XzmOb
/usr/include. ƹW, dirent.h Tb /usr/include , ɨS]t dirent
 structure. M, Ѧҥt@ dirent.h .

     #include <linux/dirent.h>

̫, h /usr/include/linux/dirent.h, ڭ̥iڭ̩һݭnŧi structure.















b Linux Uإ߳nM 						      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! */
     };


aTw, o structure ŧiS]t d_namelen, @P۷.
䤤̥i઺O d_reclen, ] o structure member ܬY˪F誺 length
ӥBO short integer.  Lj, d_ino, iO inode number, P_ name M
type.  ƹW, ڭ̤jOBz "directory entry" structure, Ӥɮݩ,
W, inode, M length (H blocks @). oGڭ̪qQܦXz.

ڭ̽sɮ fortune.c, ӥBܦb551M553檺 d_namelen ܦ d_reclen.
Aո make all. Success.  oإߨS~. ڭ̲{bq fortune o "cheap
thrills"


9.  إilXɮ

{bAܴ檺ϥΧA̷soѨӥ[J@ǤuM䥦nFAt,
AiHbuW쥦, Linux Applications and Utilities Page9 ,
Ϊ̦bܦXz쪺 CD ROM ɮ, ǥ Red Hat10 , InfoMagic11 , HΨ䥦.

@ӲhlX_wOb comp sources UNIX archive12 .

ܦh UNIX lXob alt.sources sDs. pGAnSOlX]˪,
AiHKb alt.sources.wanted sDs.  t~@ӤaOd
comp.os.linux.announce sDs. nob Unix sources13  qH׾, бH
subscribe T쨺.

ܩalt.sources sDsժɮ׬ObU 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>







b Linux Uإ߳nM 						     10



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


10.  y

`, ʧ餣|Ϥܦ@ (ӥB׮e|U).
ϥXO,qѤoǲߧOn. bCӹLB, CӥѳyNFx
إ߳nN ѭ.


11.  ѦһPi@BŪ

     BORLAND C++ TOOLS AND UTILITIES GUIDE, Borland International, 1992,
     pp. 9-42.
     [Borland C++, ver. 3.1. oU@. FܦnЦbykMW,
     ϥ Borland b DOS Uݾl@.]

     DuBois, Paul: SOFTWARE PORTABILITY WITH IMAKE, O'Reilly and Associates,
     1996, ISBN 1-56592-226-3.
     [oڻO㪺 imake ѦҸ, Mڦbg,٥o.]

     Frisch, Aeleen: ESSENTIAL SYSTEM ADMINISTRATION, O'Reilly and
     Associates, 1995, ISBN 1-56592-127-5.
     [oO䥦Vtκ޲zUwghͨإ߳n.]

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

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

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

     Peek, Jerry M Tim O'Reilly P Mike Loukides: UNIX POWER TOOLS,
     O'Reilly and Associates / Random House, 1997, ISBN 1-56592-260-3.
     [ܴΪӷ, ӥBjqϥΤuAiqlXӫإ,
     ϥΦb夤Qתk.]

     Stallman, Richard M. M Roland McGrath: GNU MAKE, Free Software
     Foundation, 1995, ISBN 1-882114-78-7.
     [ӬOݭn\Ū.]

     Welsh, Matt M Lar Kaufman: RUNNING LINUX, O'Reilly and Associates,
     1996, ISBN 1-56592-151-8.
     [MO Linux ѦҸƳ̦n, MbYǦaʤ֤`JQ.]

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




____________________

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







b Linux Uإ߳nM 						     11





































































				   CONTENTS



1.  ²  ................................................................... 1

2.  qo}l .............................................................. 1

3.  ϥ Make ............................................................... 2

4.  JAx ................................................................ 3
    4.1 s~ ............................................................ 3
    4.2 䥦D ............................................................ 4
    4.3 ۧPL .......................................................... 5
    4.4 hoi@BU  ............................................... 5

5.  ̫BJ ................................................................ 5

6.  Ĥ@ӨҤl: Xscrabble ................................................... 6

7.  ĤGӨҤl: Xloadimage .................................................. 7

8.  ĤTӨҤl: Fortune ..................................................... 8

9.  إilXɮ  ................................................... 9

10. y  .................................................................. 10

11. ѦһPi@BŪ .................................................... 10



























				       i


