\documentclass[letterpaper]{article}
\nonstopmode
\akai
\usepackage{linuxdoc-sgml}
\usepackage{qwertz}
\usepackage{url}
\usepackage[latin1]{inputenc}
\usepackage{t1enc}
\usepackage[english]{babel}
\usepackage{epsfig}
\usepackage{null}
\def\addbibtoc{
\addcontentsline{toc}{section}{\numberline{\mbox{}}\relax\bibname}
}%end-preamble
\setcounter{page}{1}
\title{ÔÚ Linux ÏÂ½¨Á¢ÈíÌåÌ×¼þ}
\author{{\ttfamily ×÷Õß:\nameurl{mailto:thegrendel@theriver.com}{Mendel Leo Cooper}}
{\ttfamily \onlynameurl{http://personal.riverusers.com/\~{}thegrendel/}}\\ 
{\ttfamily ÒëÕß:\nameurl{mailto:r6921068@ms.cc.ntu.edu.tw}{J.S.Lin}} }
\date{v1.52, 27 December 1997}
\abstract{ÕâÊÇ·Ý¹ã·ºÖ¸ÒýÎÄ¼þ,¿ÉÓÃÀ´½¨Á¢"Ò»°ãÐÔ" UNIX ÈíÌå·¢ÐÐÌ×¼þÔÚ Linux ÏÂ. }


\begin{document}
\maketitle
\tableofcontents

\section{¼ò½é}

ºÜ¶àÈíÌåÌ×¼þÌá¹©¸ø¸÷Ê½ UNIX, °üÀ¨ Linux, 
ÊÇ½«Ô­Ê¼Âëµµ°¸Ñ¹Ëõ³Éµµ°¸(archives)¶ø·¢ÐÐµÄ.
ÏàÍ¬µÄÌ×¼þ¿ÉÒÔ½¨Á¢ÒÔ±ãÔÚ²»Í¬¶ÔÏóµÄ»úÆ÷ÉÏÖ´ÐÐ,
²¢ÇÒÕâ¿É½ÚÊ¡Ð©ÈíÌå³ÉÆ·¶øÃâì¶±ØÐëÖÆÔì¸÷ÖÖ·¢ÐÐ°æ±¾.
ÈíÌåÌ×¼þµÄµ¥Ò»·¢ÐÐ°æ±¾½á¹ûÄÜÖ´ÐÐÔÚ¸÷Ê½ÊµÌå(incarnations),
ÏñÊÇÔÚ Intel »úÆ÷, DEC Alpha, RISC ¹¤×÷Õ¾, ÉõÖÁÊÇµçËãÖ÷»ú.
µ«²»ÐÒµÄÊÇ, Õâ½«"½¨Á¢"ÈíÌåµÄ¹¤×÷ÍÆ¸øÁË×îÖÕÊ¹ÓÃÕß(end user),
Êµ¼ÊÉÏÊÇ"ÏµÍ³¹ÜÀíÕß", ¼´×øÔÚ¼üÅÌÇ°µÄÍ¬Ö¾...Äã.
ËäÈ»ÕâÑù, ÈÏÕæÀ´ËµÕâ¹ý³Ì²¢²»ÊÇÏñËü¿´ÆðÀ´ÄÇ÷á¿ÉÅÂ»ò²»¿ÉË¼Òé,
¾ÍÏñÕâÖ¸ÒýËù½âËµÒ»Ñù.










\section{´ÓÈ¡µÃ¿ªÊ¼}

ÄãÓÐÏÂÔØ»òÆäËü·½Ê½È¡µÃÒ»¸öÈíÌåÌ×¼þ. ×î³£¼ûÇé¿öÊÇËü±»´ò°üÆðÀ´ ({\itshape tarred\/})
¶øÇÒ±»Ñ¹Ëõ ({\itshape gzipped\/}), ³ÉÎª {\ttfamily .tar.gz} »ò  {\ttfamily .tgz} ÐÎÊ½.
Ê×ÏÈ½«Ëü¸´ÖÆµ½Ò»¹¤×÷Ä¿Â¼. È»ááÓÃ {\itshape untar\/} ºÍ {\itshape gunzip\/} ´¦ÀíËü.
´¦ÀíËü×îÊÊºÏµÄÃüÁîÊÇ {\bfseries tar xzvf {\itshape filename\/}}, Õâ¡õµÄ 
{\itshape filename\/} µ±È»ÊÇÈíÌåµµÃû. 
ÕâÖÖ½â¿ª³ÌÐò³£³£»á°²×°ÊÊµ±µµ°¸ÔÚËüËù¿ªÆôµÄ×ÓÄ¿Â¼ÖÐ.
×¢ÒâµÄÊÇÈç¹ûÌ×¼þÃû³ÆÓÐ {\itshape .Z\/} ½áÎ², ÄÇ½«ÒªÊ¹ÓÃ
{\bfseries uncompress PACKAGENAME}, È»ááÔÙÓÃ {\bfseries tar xvf PACKAGENAME}
¶ø²»ÒªÓÃÖ®Ç°µÄ²½Öè.  

ÓÐÊ±´ò°üÆðÀ´µÄµµ°¸±ØÐë {\itshape untarred\/} 
ÇÒ°²×°×ÔÊ¹ÓÃÕßµÄ¼ÒÄ¿Â¼(home directory),
»òÕßÒ²ÐíÊÇÔÚÄ³¸öÆäËüÄ¿Â¼, ÏñÊÇÌ×¼þÉè¶¨×ÊÁÏËùÖ¸¶¨µÄ. 
¼ÙÈôÄãÉè·¨Òª {\itshape untar\/} Ëü¶øµÃµ½µÄÊÇ´íÎóÑ¶Ï¢, Ò²Ðí¾ÍÊÇÄÇÔ­Òò.
¶ÁÒ»ÏÂÌ×¼þÎÄ¼þ, ÌØ±ðÊÇ {\ttfamily README} ºÍ/»ò {\ttfamily Install} µµ°¸,
Èç¹û´æÔÚ, ±à¼­Éè¶¨µµ°¸ºÍ/»ò {\ttfamily Makefiles} ÈçËùÐèÒªµÄ, ¼´Óë°²×°Ö¸Ê¾·ûºÏ.
×¢ÒâµÄÊÇÍ¨³£ {\bfseries ²»} È¥¸ü¸Ä {\ttfamily Imake} µµ°¸, ÒòÎªÕâ¿ÉÄÜÓÐÎ´Ô¤ÆÚµÄ½á¹û.
Ä³Ð©ÈíÌåÌ×¼þÔÊÐí×Ô¶¯°²×°³ÌÐò,ËüÊÇ½åÓÉÖ´ÐÐ {\bfseries make install} 
À´·ÅÖÃ¶þÔªÂëÔÚÊÊµ±ÏµÍ³Î»ÖÃ.

Å¼¶ø, Äã¿ÉÄÜÐèÒªÊ¹ÓÃ {\ttfamily patchµµ°¸},¸Ãµµ°¸ÓÐÁÐ³öÔ­±¾µÄÓëÐÂµÄÔ­Ê¼µµ°¸µÄ²îÒì,
À´Éý¼¶»ò¼ÓÈë³ô¡õ(bug)µÄÐÞÕýÖÁÎ´´ò°ü(unarchived)µÄÔ­Ê¼µµ°¸.
docµµ°¸Óë/»ò {\ttfamily README} µµ°¸»á¸æÖªÄãÕâËã²»Ëã¸ÃÇé¿ö. 
¶Ôì¶Ê¹ÓÃ Larry Wall µÄÇ¿Á¦ {\ttfamily ÐÞ²¹(patch)} ¹¤¾ßÖ®Õý³£µÄÓï·¨(syntax)ÊÇ
{\bfseries patch {$<$} patchfile}.

ÄãÏÖÔÚ¿ÉÒÔ¿ªÊ¼½øÐÐ {\itshape ½¨Á¢\/} ¹ý³Ì½×¶ÎÁË.










\section{Ê¹ÓÃ Make}

{\ttfamily Makefile} ÊÇ½¨Á¢¹ý³ÌµÄÖØµã. ÔÚËüµÄ×î¼òµ¥µÄÐÎÊ½, Makefile 
¾ÍÊÇ¸ö script ,ËüÊÇÓÃÀ´±àÒë»ò½¨Á¢"¶þÔªÂë",Ì×¼þµÄ¿ÉÖ´ÐÐ²¿·Ö.
MakefileÒ²¿ÉÒÔÌá¹©ÈíÌåÌ×¼þÉý¼¶µÄ¹¤¾ß,¶ø²»ÐèÒªÖØÐÂ±àÒëÃ¿Ò»¸öÔÚÌ×¼þÖÐµÄÔ­Ê¼µµ°¸,
µ«ÆäÓÐ²»Í¬µÄÇé¿ö(»òÊÇ²»Í¬µÄÔ¼¶¨).

Ä³Ð©ÌØµãÊÇ, Makefile ¿ªÆô {\ttfamily cc} »ò {\ttfamily gcc}.
ÕâÊµ¼ÊÉÏÊÇ¸öÇ°´¦ÀíÆ÷, C (or C++) ±àÒëÆ÷, ºÍ Á¬½áÆ÷, °´ÕÕÄÇ¸öË³Ðò.
Õâ¹ý³Ì×ª»»Ô­Ê¼Âë(source)Îª¿ÉÕæÕýÈ¥Ö´ÐÐµÄ¶þÔªÂë(binaries).

ÏÂÖ¸Áî {\itshape make\/} Í¨³£Ö»Òª¼üÈë {\bfseries make}.
ÕâÍ¨³£½¨Á¢ÌÖÂÛÖÐµÄÌ×¼þËùÓÐÐèÒªµÄ¿ÉÖ´ÐÐµµ.
È»¶ø, {\itshape make\/} Ò²×öÆäËû¹¤×÷,ÏñÊÇ°²×°µµ°¸ÖÁºÏÊÊµÄÄ¿Â¼ ({\bfseries make install})
¶øÇÒÉ¾³ý¾ÉµÄ object µµ°¸ ({\bfseries make clean}). 
Ö´ÐÐ {\bfseries make -n} ÔÊÐíÔ¤ÀÀ½¨Á¢¹ý³Ì, ¾ÍÊÇÁÐ³öËùÓÐ make 
Ëù»½ÆðµÄ(triggered)ËùÓÐÃüÁî, µ«Ã»ÓÐÕæµÄÈ¥Ö´ÐÐËüÃÇ.

Ö»ÓÐÔÚ×î¼òµ¥µÄÈíÌåÊ¹ÓÃÒ»°ãÐÔµÄ Makefile. ½Ï¸´ÔÓµÄ°²×°ÐèÒª¸ù¾Ýº¯Ê½¿â(libraries),
include µµ°¸ÒÔ¼°Äã¸ö±ð»úÆ÷×ÊÔ´ËùÔÚÄ¿Â¼À´Á¿Éí¶¨ÖÆ.
ÕâÌØ±ðÊÇµ±ÐèÒª {\ttfamily X11} libraries À´°²×°½¨Á¢Ê±.
{\itshape Imake\/} ºÍ {\itshape xmkmf\/} ¿ÉÍê³ÉÕâÑùµÄ¹¤×÷.

ÒýÓÃ×Ô man page,Imakefile ÊÇ¸ö"Ä£°å(template)"µÄ Makefile.
imake ¹¤¾ß²Î¿¼ Imakefile ¸ù¾ÝÄãµÄÏµÍ³Ôì³öºÏÊÊµÄ Makefile.
È»¶ø,¼¸ºõÔÚËùÓÐµÄÇé¿öÏÂ,ÄãÒªÖ´ÐÐ xmkmf, ËüÊÇÒªÏÂ imake Ö¸ÁîÓÃµÄ shell script,
Ò²¾ÍÊÇ¸öÇ°¶Ë½éÃæ(front end). ²ìÔÄÒ»ÏÂÄÚ¸½ÔÚÈíÌåµµ°¸¼äµÄ README »ò INSTALL 
µµ°¸ÒÔÈ¡µÃÌØ±ðµÄÖ¸Ê¾. ÖÁì¶¸üÏêÏ¸µÄ²½Öè·ÖÎö,ÇëÔÄ¶Á imake ºÍ xmkmf µÄ man pages.

ÒªÖªµÀµÄÊÇ {\itshape xmkmf\/} ºÍ {\itshape make\/} ¿ÉÄÜÐèÒªÒÔ root Éí·ÖÀ´ÏÂÖ¸Áî,
ÌØ±ðÊÇµ± {\bfseries make install} À´°áÒÆ¶þÔªÂëµ½ {\ttfamily /usr/bin} 
»ò {\ttfamily /usr/local/bin} Ä¿Â¼. ÒÔÒ»°ãÊ¹ÓÃÕßµÄÉí·Ö¶ø²»¾ß root È¨Á¦
À´Ê¹ÓÃ make ½«¿ÉÄÜ»áµ¼ÖÂ {\ttfamily write access denied} µÄ´íÎóÑ¶Ï¢,
ÒòÎªÄãÈ±ÉÙÐ´Èë(write)ÖÁÏµÍ³Ä¿Â¼µÄÈ¨ÏÞ. Ò²¼ì²éÒ»ÏÂ,
ËùÔì³öÀ´µÄ¶þÔªÂë¶ÔÄãÓëÈÎºÎÆäËûÊÊÓÃµÄÊ¹ÓÃÕßÓÐÊÊºÏµÄÖ´ÐÐ(execute)È¨ÏÞ.

ÏÂÖ¸Áî {\bfseries xmkmf} À´Ê¹ÓÃ {\itshape Imake\/} µµ°¸, 
½¨Á¢Ò»¸öÐÂµÄ¶øÇÒÊÊºÏÄãÏµÍ³µÄ Makefile. Õý³£µØÏÂÖ¸Áî {\bfseries xmkmf} ¶¼»á¸½¼Ó
{\bfseries -a} ÒýÊý, Òò¶ø×Ô¶¯µØ×ö {\itshape make Makefiles, make includes,\/}
ºÍ {\itshape make depend\/} µÄ¶¯×÷. Õâ»áÉè¶¨±äÊý(variables)ºÍ¸ø¶¨º¯Ê½¿â(library)
Î»ÖÃ¸ø±àÒëÆ÷ºÍÁ¬½áÆ÷. ÓÐÊ±»áÃ»ÓÐ {\itshape Imake\/} µµ°¸, Òý¶ø´úÖ®µÄÊÇÓÐ
{\itshape INSTALL\/} ºÍ {\itshape configure\/} µÄ script, Ò²»áµ½ÕâÑùµÄÄ¿µÄ. 
×¢ÒâµÄÊÇÈç¹ûÄãÒªÖ´ÐÐ  {\itshape configure\/}, ÄÇÒªÏÂÖ¸Áî {\bfseries ./configure}
ÒÔÈ·±£ÔÚÄ¿Ç°Ä¿Â¼ÏÂÕýÈ·µÄ script {\itshape configure\/} ÊÇ±»ºô½Ð.
ÔÚ´ó²¿·ÖµÄÇé¿ö, ÔÚ·¢ÐÐÌ×¼þÖÐµÄ {\itshape README\/} µµ°¸»áËµÃ÷°²×°²½Öè.

Í¨³£Ò»¸öºÃµÄ·½·¨ÊÇ´ÓÍâ¹Û¼ìÊÓÒ»ÏÂ {\ttfamily Makefile} ÊÇ {\ttfamily xmkmf} »ò
ÆäÖÐÒ»¸ö°²×°µÄ scripts ËùÔì³öÀ´µÄ.  Makefile Õý³£ÏÂ»áÎªÄãµÄÏµÍ³¶øÐÞÕý,
µ«ÄãÅ¼¶ø¿ÉÄÜÐèÒª"ÐýÅ¤(tweak)"»òÊÖ¶¯µØÐÞÕý´íÎó.



ÄãµÄÒ»°ã°²×°²½Öè½«»áÊÇ:
\begin{itemize}
\item ¶ÁÒ»ÏÂ {\itshape README\/} µµ°¸ºÍÆäËüºÏÓÃµÄÎÄ¼þ.
\item Ö´ÐÐ {\bfseries xmkmf -a}, »¹ÊÇ {\itshape INSTALL\/} »ò {\itshape configure\/} 
script.
\item ¼ì²éÒ»ÏÂ {\ttfamily Makefile}.
\item Èç¹ûÐèÒª, Ö´ÐÐÒ»ÏÂ {\bfseries make clean}, {\bfseries make Makefiles},  
{\bfseries make includes}, and {\bfseries make depend}.
\item Ö´ÐÐ {\bfseries make}.
\item ¼ì²éÒ»ÏÂÈ¨ÏÞ.
\item Èç¹ûÐèÒª, Ö´ÐÐÒ»ÏÂ {\bfseries make install}.
\end{itemize}







\section{¿Ë·þÀ§ÄÑ}



Èç¹ûÓÃ {\bfseries xmkmf} ºÍ/»ò {\bfseries make} ºÜ³É¹¦Ã»ÓÐ´íÎó,
Äã¿ÉÒÔÖøÊÖì¶ \ref{finalsteps} {(next section)}.
È»¶ø, ÔÚÕæÊµÉú»î, ºÜÉÙÊÂÇéÔÚµÚÒ»´Î¾ÍÕýÈ·µÄ¹¤×÷.
Õâ¾ÍÊÇµ±ÄãµÄ»úÖÇ·á¸»Ê±,ÒªÓÂì¶³¢ÊÔ.




\subsection{Á¬½á´íÎó}

\begin{itemize}
\item Èç¹û {\bfseries make} Ê§°Ü¶ø³öÏÖÓÐ {\ttfamily Link error: -lX11:
No such file or directory}, ÉõÖÁÊÇÔÚÊ¹ÓÃ {\bfseries xmkmf} áá.
Õâ¿ÉÄÜÒâÎ¶Öø {\itshape Imake\/} µµ°¸Ã»ÓÐÊÊµ±µØ×°ºÃ. 
¼ì²é {\itshape Makefile\/} µÄµÚÒ»²¿·ÖÓÐÃ»ÓÐÏñÕâÑùµÄ¼¸ÐÐ:

\begin{tscreen}
\begin{verbatim}
LIB=            -L/usr/X11/lib
INCLUDE=        -I/usr/X11/include/X11
LIBS=           -lX11 -lc -lm
\end{verbatim}
\end{tscreen}


{\ttfamily -L} ºÍ {\ttfamily -I} ÇÐ»»Æ÷(switches)»áÍ¨¸æ±àÒëÆ÷ºÍÁ¬½áÆ÷·Ö±ðÈ¥ÄÄ¡õÑ°ÕÒ {\itshape library\/} ºÍ {\itshape include\/} µµ°¸.
ÔÚÕâÀý×Ó,  {\itshape X11 libraries\/} Ó¦¸ÃÊÇÔÚ {\ttfamily /usr/X11/lib} Ä¿Â¼,
¶ø  {\itshape X11 include µµ°¸\/} Ó¦¸ÃÊÇÔÚ {\ttfamily /usr/X11/include/X11}Ä¿Â¼.
Èç¹ûÕâÔÚÄãµÄ»úÆ÷ÉÏÊÇ²»¶ÔµÄ, ±ØÐë¸Ä±ä {\itshape Makefile\/} ¶øÇÒÔÙÊÔÊÔ 
{\bfseries make}. 
\end{itemize}


\begin{itemize}
\item ÔÚ·Ç³£ÉÙµÄÇé¿ö, ÒÔ {\itshape root\/} Éí·ÖÅÜÒ»ÏÂ {\bfseries ldconfig} 
Ò²ÐíÊÇ¸ö´ð°¸:

{\bfseries \# /etc/ldconfig -n /lib} ½«»á¸üÐÂ¹²ÏíÊ½º¯Ê½¿â·ûºÅÁ¬½á
(shared library symbolic links). {\itshape ÕâÔÚÕý³£µÄÇéÐÎÏÂ²»ÊÇÐèÒªµÄ\/}.
\end{itemize}


\begin{itemize}
\item Ä¿Ç°ÁíÒ»¼þÊÂÊÇÈç¹û {\bfseries xmkmf} Ê§°Ü, ÔòÊÔÊÔÏÂÁÐ script:
\begin{tscreen}
\begin{verbatim}
         make -DUseInstalled -I/usr/X386/lib/X11/config
\end{verbatim}
\end{tscreen}

\end{itemize}






\begin{itemize}
\item ÓÐÊ±Ô­Ê¼ÂëÐèÒªÊ¹ÓÃ¾É°æµÄ X11R5 libraries À´½¨Á¢.
Èç¹ûÄãÓÐ R5 libs ÔÚ /usr/X11R6/lib (µ±ÄãÊ×ÏÈÔÚ°²×° Linux Ê±,
ÄãÊÇÓÐÑ¡ÔñÊÇ·ñ°²×°ËüÃÇµÄ), È»ááÄãÖ»ÐèÒªÈ·¶¨,ÄãÓÐÁ¬½áµ½ÈíÌåËùÐèÒª½¨Á¢µÄµØ·½.
{\ttfamily R5 libs} ÊÇÓÐ {\ttfamily libX11.so.3.1.0}, {\ttfamily libXaw.so.3.1.0}, 
ºÍ {\ttfamily libXt.so.3.1.0}. Ò»°ãÄãÐèÒªÁ¬½áÖÁ, ÏñÊÇ
{\bfseries libX11.so.3 -{$>$} libX11.so.3.1.0}. 
´ó¸ÅÈíÌåÒ²ÐèÒªÕâ¸öÐÎÊ½Á¬½á {\bfseries libX11.so -{$>$} libX11.so.3.1.0}.
µ±È», Òª½«Õâ"¶Ïµô(missing)"µÄÁ¬½á½¨ºÃ, ÒªÒÔ {\itshape root\/} Éí·ÖÊ¹ÓÃÕâÖ¸Áî
{\bfseries ln -s libX11.so.3.1.0 libX11.so}.
\end{itemize}




\begin{itemize}
\item Ä³Ð©Ì×¼þ»áÒªÇóÄãÈ¥°²×°Ò»¸ö»òÒÔÉÏµÄÉý¼¶°æ±¾. ¾ÙÀý¶øÑÔ, 
StarDivision GmbH µÄ {\itshape StarOffice\/} ×é¼þ(suite)ÊÇ¶ñÃûÕÑÕÃ(notorious)µÄÒªÇó
{\ttfamily libc} version 5.4.4 »ò¸üÐÂ. ÒÔ {\itshape root\/}Éí·Ö,
ÄãÐèÒª¸´ÖÆÒ»¸ö»òÒÔÉÏµÄº¯Ê½¿â(libraries)ÖÁºÏÊÊµÄÄ¿Â¼, 
É¾È¥¾ÉµÄº¯Ê½¿â(libraries),È»ááÖØÉè·ûºÅÁ¬½á.

{\bfseries Ð¡ÐÄ: ÔÚÕâÒª¸ñÍâ×¢Òâ, ÒòÎªÈç¹ûÄãÅªÔã, Äã¿ÉÄÜ»á¸¶³öÄãµÄÏµÍ³²»ÄÜÔË×÷µÄ´ú¼Û}.

ÄãÍ¨³£¿ÉÒÔÕÒµ½Éý¼¶µÄº¯Ê½¿â(libraries)ÔÚ \nameurl{ftp://sunsite.unc.edu}{Sunsite}.
\end{itemize}





\subsection{ÆäËüÎÊÌâ}



\begin{itemize}
\item ÔÚ°²×°ºÃµÄ {\itshape Perl\/} »ò shell script ¸øÄãÒ»¸ö {\ttfamily No such file or directory} ´íÎóÑ¶Ï¢. ÔÚÕâÇé¿ö,¼ì²éµµ°¸È¨ÏÞÀ´È·¶¨µµ°¸¿ÉÖ´ÐÐ
ÒÔ¼°¼ì²éµµ°¸±êÍ·ÊÇ·ñº¬ÓÐÊ¹ÓÃ shell »ò³ÌÊ½, Ö¸Ã÷ script ËùÔÚµØ·½.
¾ÙÀý¶øÑÔ, script ¿ªÊ¼Èç:
\begin{tscreen}
\begin{verbatim}
#!/usr/local/bin/perl
\end{verbatim}
\end{tscreen}

Èç¹û {\itshape Perl\/} Êµ¼Ê×°ÔÚÄãµÄ {\ttfamily /usr/bin} Ä¿Â¼,
¶ø²»ÊÇ {\ttfamily /usr/local/bin} Ä¿Â¼, ÄÇ÷á script ÎÞ·¨Ö´ÐÐ.
ÓÐÁ½¸ö·½·¨À´ÐÞ¸Ä. script µµ°¸±êÍ·¸Ä³É {\ttfamily \#!/usr/bin/perl}, 
»òÓÃ·ûºÅÁ¬½áÖÁÕýÈ·µÄÄ¿Â¼, {\bfseries ln -s 
/usr/bin/perl /usr/local/bin/perl}. 
\end{itemize}


\begin{itemize}
\item Ä³Ð© X11 ÈíÌåÒªÇóÓÐ {\ttfamily Motif} º¯Ê½¿â(libraries)²ÅÄÜ½¨Á¢.
¶ø±ê×¼µÄ Linux ·¢ÐÐÌ×¼þ²¢Ã»ÓÐ°²×° Motif libraries, ¶øÇÒÄ¿Ç° Motif
»¹Òª¶îÍâ \$100-\$200 µÄ»¨·Ñ (ËäÈ»Ãâ·ÑÈíÌå
\nameurl{http://www.lesstif.org/}{Lesstif} ÔÚÄ³Ð©³¡ºÏÒ²ÄÜ¹»ÓÃ).
Èç¹ûÄãÐèÒª Motif À´½¨Á¢Ä³Ò»Ì×¼þ, µ«È±ÉÙ Motif libraries, 
ÄÇ÷áÒ²Ðí¿ÉÒÔÈ¡µÃ {\itshape ¾²Ì¬Á¬½áµÄ¶þÔªÂë(statically linked binaries)\/}.
¾²Ì¬Á¬½áÔÚ¶þÔªÂë±¾ÉíÄÉÈëº¯Ê½¿âÐÐ³Ì(library routines).
ÕâÔì³É¶þÔªÂëµµ°¸´óÁËÐí¶à, µ«ÊÇÂë¿ÉÔÚÈ±ÉÙ¸Ãº¯Ê½¿âµÄÏµÍ³ÉÏÖ´ÐÐ.
\end{itemize}




\begin{itemize}
\item Ö´ÐÐ {\itshape configure\/} script »á´´ÔìÆæ¹ÖµÄ {\ttfamily Makefile},
ÄÇÏñÊÇÓëÄãËùÒªÉè·¨½¨Á¢µÄÌ×¼þÙñ²»Ïà¸É. Õâ±íÊ¾ÅÜÖø´íÎóµÄ {\itshape configure\/},
ÆäÕÒµ½ÄãµÄ path ÉÏÄ³´¦ÆäËûµÄ configure. ËùÒÔÒªÏÂ {\itshape configure\/} Ö¸Áî
Ó¦¸ÃÒªÏÂ³É {\bfseries ./configure} ¼´Ä¿Ç°Ä¿Â¼ÏÂµÄ.
\end{itemize}




\begin{itemize}
\item Ä³Ð©³ÌÊ½»áÒªÇóÓÐ {\itshape setuid root\/}, ÎªÁËÒªÒÔÓÐ {\itshape root È¨Á¦\/} 
À´Ö´ÐÐ. Òª´ï³ÉÕâÄ¿Â¼µÄÖ¸ÁîÊÇ {\itshape ÒÔroot\/} ÏÂÖ¸Áî
{\bfseries chmod u+s filename}. (×¢ÒâµÄÊÇÕâ³ÌÊ½ÒÑ¾­ÊÇ {\itshape root\/} ËùÓµÓÐÁË).
ÕâÔÚÉè¶¨µµ°¸È¨ÏÞÖÐµÄ {\itshape setuid\/} bit ºÜÓÐÓÃ.
ÕâÑùÓÃÔÚµ±³ÌÊ½ÔÚ´æÈ¡ÏµÍ³Ó²Ìå,ÏñÊÇ modem »ò CD ROM drive, 
»òµ± SVGA libs ±»Ê¹ÔÚì¶Ö÷¿ØÌ¨Ä£Ê½(console mode), 
ÏñÊÇÔÚÒ»¸öÌØ±ð¶ñÃûÕÑÕÃµÄ(notorious)Ä£ÄâÆ÷(emulation)Ì×¼þ. 
Èç¹û³ÌÊ½Õý±» root Ö´ÐÐ,
µ«¸øÒ»°ãÊ¹ÓÃÕßÒ»¸ö {\itshape access denied\/} µÄ´íÎóÑ¶Ï¢, ÏëÏñ¾ÍÊÇÕâÑùÔì³ÉµÄ.



{\bfseries ¾¯¸æ:}   
Ò»¸öÓÐ {\itshape setuid\/} ³É root µÄ³ÌÊ½¿ÉÄÜÌá³ö¶ÔÄãµÄÏµÍ³ÓÐ°²È«ÉÏµÄ·çÏÕ.
Õâ¸ö³ÌÊ½¿ÉÒÔ root È¨Á¦À´ÅÜ¶øËùÒÔÓÐÄ³Ð©ÆÆº¦µÄÇ±ÔÚÐÔ. 
ÔÚÉè¶¨ {\itshape setuid\/} bit Ç°, È·¶¨ÄãÖªµÀ¸Ã³ÌÊ½ÔÚ×öÊ²÷á, ±ØÒªÊ±¿´Ò»ÏÂÔ­Ê¼Âë.



\end{itemize}







\subsection{ÐýÅ¤ÓëÎ¢µ÷}



Äã¿ÉÄÜÏ£Íû¼ì²é {\ttfamily Makefile} À´È·¶¨ÓÐÑ¡ÓÃ¶ÔÄãÏµÍ³×î¼Ñ±àÒëÑ¡Ïî.
¾ÙÀýÀ´Ëµ, Éè¶¨ {\itshape -O2\/} Æì±êÀ´Ñ¡×î¸ß²ã¼¶µÄ×î¼Ñ»¯¶ø 
{\itshape -fomit-frame-pointer\/} Æì±êÀ´Ôì×îÐ¡¶þÔªÂë
(ËäÈ» debugging »áÃ»ÓÐ´ò¿ª). {\bfseries ³ý·ÇÄãÖªµÀÄãÔÚ×öÊ²÷á, 
¶øÇÒÔÚÈÎºÎÇé¿öÏÂ, ³ý·Ç¼è¿à½¨Á¢µÄ¹¤×÷ÒÑÍê³É, ·ñÔò²»ÒªÍæÕâÐ©}.








\subsection{È¥ÄÄÈ¡µÃ½øÒ»²½µÄÐ­Öú}

ÔÚÎÒµÄ¾­Ñé, ´ó¸Å25\%µÄÓ¦ÓÃ³ÌÊ½½¨Á¢"ÍêÈ«Ã»ÓÐÀ§ÄÑ". 
ÁíÍâ´óÔ¼50\%ÄÜ"±»Ëµ·þ"µÄ½¨Á¢, Òª¸¶³öÅ¬Á¦µÄ¡õÎ§´ÓÎÞÁÄµ½¼«ÎªÀ§ÄÑ.
ÄÇÈÔÈ»±íÊ¾ÓÐÄ³Ð©Ì×¼þÎÞÂÛÈçºÎ¶¼ÎÞ·¨½¨Á¢. ¼´Ê¹ÄÇÑù, ÄÇÐ©
Intel {\ttfamily ELF} ºÍ/»ò {\ttfamily a.out} ¶þÔªÂë, Ò²¿ÉÄÜÔÚ
\nameurl{ftp://sunsite.unc.edu}{Sunsite}, \nameurl{ftp://tsx-11.mit.edu}{TSX-11 archive} »òÆäËüµØ·½ÕÒµ½.
Ò²Ðí, ÈíÌåµÄ´´ÔìÕß¿ÉÒÔÌá¹©±àÒëºÃµÄ¶þÔªÂë¸øÄãµÄÌØ±ðµÄ»úÆ÷Ê¹ÓÃ.



{\ttfamily ×¢ÒâµÄÊÇÈç¹ûÄãÈ¡µÃÔ¤ÏÈ±àÒëºÃµÄ¶þÔªÂë, Äã»áÐèÒª¼ì²éÊÇ·ñÓëÄãµÄÏµÍ³ÏàÈÝ:} 
\begin{itemize}
\item {\ttfamily Õâ¶þÔªÂë±ØÐëÔÚÄãµÄ Ó²ÌåÉÏÅÜ (i.e., Intel x86).}       
\item {\ttfamily Õâ¶þÔªÂë±ØÐëÓëÄãµÄºËÐÄ(kernel)ÏàÈÝ (i.e., a.out »ò ELF).}     
\item {\ttfamily ÄãµÄº¯Ê½¿â(libraries)±ØÐëÊÇ×îÐÂµÄ.}
\end{itemize}


Èç¹ûÈ«¶¼Ê§°Ü, Äã¿ÉÒÔÔÚºÏÊÊµÄ {\itshape ÐÂÎÅÈº×é\/}Ñ°Çó°ïÃ¦,
ÏñÊÇÔÚ\onlynameurl{comp.os.linux.x} »ò \onlynameurl{comp.os.linux.development}. ÍòÒ»ÄãÖ»ÊÇ²»¹»ÐÒÔËµÄ»°,
ºÙ, ÊÔÊÔÒ²ÊÇÓÐÈ¤µÄ.












\section{×îáá²½Öè\label{finalsteps}}

¶ÁÒ»ÏÂÈíÌåÌ×¼þµÄÎÄ¼þÀ´¾ö¶¨ÊÇ·ñÓÐÄ³Ð©»·¾³±äÊýÐèÒªÉè (ÔÚ {\itshape .bashrc\/}
»ò {\itshape .cshrc\/}) ÒÔ¼°
ÊÇ·ñ {\itshape .Xdefaults\/} ºÍ {\itshape .Xresources\/} µµ°¸ÐèÒªµ÷Õû.

¿ÉÄÜÓÐ¸öÓ¦ÓÃ³ÌÊ½ÄÚ¶¨µÄµµ°¸, Í¨³£½Ð×ö Xfoo.ad ÔÚÔ­±¾µÄ Xfoo ·¢ÐÐÌ×¼þ. 
Èç¹ûÕâÑù, ±à¼­ Xfoo.ad µµ°¸ÊÊºÏÄãµÄ»úÆ÷, È»ááÖØÐÂÃüÃû ({\bfseries mv}) ³É Xfoo 
¶øÇÒ {\itshape ÒÔ root Éí·Ö\/} °²×°Ëüµ½ {\ttfamily /usr/lib/X11/app-defaults} Ä¿Â¼, 
Ã»ÕâÑù×ö¿ÉÄÜ»áÔì³ÉÈíÌåÐÐÎªºÜÆæ¹Ö, ÉõÖÁ¾Ü¾øÖ´ÐÐ.

´ó¶àÊýµÄÈíÌåÌ×¼þ¸½ÓÐÒ»¸ö»òÒÔÉÏµÄ¸ñÊ½»¯ man pages. 
{\itshape ÒÔ root Éí·Ö\/}, ¸´ÖÆ Xfoo.man µµ°¸µ½ºÏÊÊµÄ {\ttfamily /usr/man} Ä¿Â¼
({\ttfamily man1} - {\ttfamily man9}), ¶ø¸ù¾ÝÄÇÔÙÖØÐÂÃüÃû. ¾ÙÀý¶øÑÔ, 
Èç¹û Xfoo.man ½á¹ûÊÇÔÚ /usr/man/man4, ÄÇÓ¦¸ÃÃüÃûÎª Xfoo.4 
(mv Xfoo.man Xfoo.4). ¸ù¾ÝÒ»°ãÔ¼¶¨Ê¹ÓÃÕßµÄÃüÁî°ÚÔÚ {\ttfamily man1},
ÓÎÏ·ÊÇÔÚ {\ttfamily man6}, ¶ø¹ÜÀíµÄÌ×¼þÊÇÔÚ {\ttfamily man8} (¿´Ò»ÏÂ {\itshape man ÎÄ¼þ\/}
ÒÔÈ¡µÃ¸üÏêÏ¸×ÊÁÏ).µ±È»,ÔÚÄãÏµÍ³Äã¿ÉÒÔ²»ÕÕÕâ¸öÔ¼¶¨, Ö»ÒªÄãÏ²»¶.

Ä³Ð©Ì×¼þ²»»á°²×°¶þÔªÂë(binaries)ÔÚºÏÊÊµÄÏµÍ³Ä¿Â¼, »»¾ä»°Ëµ, ËûÃÇÃ»ÓÐ 
{\itshape install\/} Ñ¡ÏîÔÚ {\ttfamily Makefile} ÖÐ. Èç¹ûÊÇÕâÇé¿ö, 
Äã¿ÉÒÔÓÃ root Éí·Ö¸´ÖÆ¶þÔªÂë(binaries)µ½ {\ttfamily usr/local/bin} 
Ä¿Â¼À´ÊÖ¶¯°²×°¶þÔªÂë(binaries).

×¢ÒâµÄÊÇÄ³Ð©»òÈ«²¿ÉÏÊö²½Öè,ÔÚ´ó²¿·ÖÇéÐÎÏÂ,Ó¦¸Ã»áÓÉ {\bfseries make install}
À´×Ô¶¯²Ù×÷. Èç¹ûÊÇÕâÑù, {\ttfamily README} »ò {\ttfamily INSTALL} ÎÄ¼þµµ»áÌáµ½Õâ¸ö.






\section{µÚÒ»¸öÀý×Ó: Xscrabble}

Matt ChapmanµÄ {\bfseries Xscrabble} ËÆºõÏñÊÇ¸öÆÄÓÐÈ¤µÄ³ÌÊ½,
ÒòÎªÎÒÔøÊÇ¸öÌ°À·µÄ Scrabble{\ttfamily \texttrademark{}}(Æ´×ÖÓÎÏ·)Íæ¼Ò.ÎÒÏÂÔØÏÂ,½âÑ¹, 
¶øÇÒ½¨Á¢ËüÒÔ README µµ°¸ÖÐµÄÏÂÁÐ²½Öè:
\begin{tscreen}
\begin{verbatim}
     xmkmf
     make Makefiles
     make includes
     make
\end{verbatim}
\end{tscreen}


{\itshape µ±È»Ëü²»ÄÜÕý³£ÔË×÷...\/}

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
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...
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÎÒÔÚ \onlynameurl{comp.os.linux.x}
µÄÐÂÎÅÈº×éÑ¯ÎÊ¹ý, ¶øÇÒÓÐÐ©ÈËºÃÐÄµÄÖ¸³öËÆºõ Xt, Xaw, Xmu, ºÍ X11 libs
Ã»ÓÐÈÃÁ¬½áÆ÷(linker)ÕÒµÃµ½. àÅ...

ÓÐÁ½¸öÖ÷ÒªµÄ Makefiles, ¶øÇÒÔÚ {\ttfamily src} Ä¿Â¼ÏÂµÄÄÇ¸öÈÃÎÒ¸ÐÐËÈ¤.
ÔÚ Makefile Ò»ÐÐÓÐ¶¨Òå LOCAL\_LIBS ³É:
LOCAL\_LIBS = \$(XAWLIB) \$(XMULIB) \$(XTOOLLIB) \$(XLIB) ÕâËùÖ¸µÄ libs
²¢Ã»ÓÐ±»Á¬½áÆ÷ÕÒµ½.

ÕÒÕÒÏÂ¸öÖ¸µ½ LOCAL\_LIBS µÄµØ·½, ÎÒ¿´µ½¸ÃÔÚ Makerfile µÄ495ÐÐ:
\begin{tscreen}
\begin{verbatim}
      $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LOCAL_LIBS) $(LDLIBS)
$(EXTRA_LOAD_FLAGS)
\end{verbatim}
\end{tscreen}


¶øÏÖÔÚ LDLIBS ÊÇÊ²÷áÄØ?
\begin{tscreen}
\begin{verbatim}
      LDLIBS = $(LDPOSTLIB) $(THREADS_LIBS) $(SYS_LIBRARIES)
$(EXTRA_LIBRARIES)
\end{verbatim}
\end{tscreen}


SYS\_LIBRARIES ÊÇ:
\begin{tscreen}
\begin{verbatim}
 SYS_LIBRARIES = -lXpm -L../Xc -lXc
\end{verbatim}
\end{tscreen}

ÊÇ¸ö! ¾ÍÊÇÕâÑùÒÅÊ§ libraries. 

´ó¸ÅÁ¬½áÆ÷ÐèÒªÔÚ LOCAL\_LIBS Ö®Ç°¿´µ½ LDLIBS...
ËùÒÔ, µÚÒ»¼þÊÂÒª³¢ÊÔÈ¥ÐÞ¸Ä Makefile ¾ÍÊÇ¸ÄÐ´ÔÚ495ÐÐµÄ
\$(LOCAL\_LIBS) ºÍ \$(LDLIBS) , ËùÒÔËüÏÖÔÚ±ä³É: 
\begin{tscreen}
\begin{verbatim}
        $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LDLIBS) $(LOCAL_LIBS)
$(EXTRA_LOAD_FLAGS)                          ^^^^^^^^^^^^^^^^^^^^^^^
\end{verbatim}
\end{tscreen}


ÔÚÉÏÃæµÄ¸Äáá,ÎÒÊÔÖøÔÙ´ÎÖ´ÐÐ {\bfseries make} , ÇÆ, ËüÕâ´Î¿ÉÕý³£ÅÜÁË.
µ±È», Xscrabble ÈÔÈ»ÐèÒªÒ»Ð©Î¢µ÷(fine tuning]ÓëÍæÅª(twiddling),
ÏñÊÇÖØÐÂÃüÃû×ÖµäÒÔ¼°±ê×¢Ä³Ð©¸¨ÖúµÄÐðÊöÔÚÔ­Ê¼Âëµµ°¸Ö®Ò»,
µ«ÕýÒòÎªÄÇÑù,ËüÒÑ¸øÎÒºÃ¼¸¸öÐ¡Ê±µÄÏûÇ².

Äã¿ÉÒÔ¼Ä e-mail \nameurl{mailto:matt@belgarath.demon.co.uk}{Matt Chapman}, ¶øÇÒ´ÓËûµÄ \nameurl{http://www.belgarath.demon.co.uk/programs/index.html}{home  page}
ÏÂÔØ {\bfseries Xscrabble}. 







\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
       Scrabble ÊÇ Milton Bradley Co., Inc. µÄ×¢²áÉÌ±ê.
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}











\section{µÚ¶þ¸öÀý×Ó: Xloadimage}

Õâ¸öÀý×ÓÌá³ö½Ï¼òµ¥µÄÎÊÌâ. {\bfseries xloadimage} 
³ÌÊ½¼ÓÈëµ½ÎÒµÄÍ¼ÐÎ¹¤×÷×éËÆºõÊÇºÜÓÐÓÃ. ÎÒ´ÓÒ»±¾ÓÉ Mui ºÍ Quercia ËùÖøµÄºÃÊé
\ref{refs} {(X User Tools)}
Ëù¸½µÄ CD ÉÏµÄÔ­Ê¼ÂëÄ¿Â¼(source directory), Ö±½Ó¸´ÖÆ {\itshape xloadi41.gz\/}
µµ°¸ÏÂÀ´. ÈçÔ¤ÆÚµÄ, ÓÃ {\bfseries tar xzvf} ½â¿ªËùÓÐµµ°¸. È»¶ø,
{\bfseries make} ³öÏÖÁËÁîÈËÌÖÑáµÄ´íÎó¶øÇÒÖÐ¶Ï.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
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
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Õâ´íÎóÑ¶Ï¢º¬ÓÐ×î¸ù±¾µÄÏßË÷.

¿´Ò»ÏÂµµ°¸ {\itshape image.h\/} µÄ23ÐÐ.
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
       #include <stdlib.h>
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}

°¡¹þ! ÔÚ {\itshape xloadimage\/}, {\ttfamily wchar\_t} 
Ô­Ê¼ÂëµÄÄ³´¦ÒÑ¾­ÖØ¸´¶¨ÒåÁËÔÚ±ê×¼ include µµ°¸ {\ttfamily stdlib.h} ÒÑ¶¨ÒåµÄ¶«Î÷.
Ê×ÏÈÊÔÊÔ½«ÔÚ {\ttfamily image.h} µÄ23ÐÐ±ê×¢(commenting out)ÆðÀ´,
Ò²Ðí {\ttfamily stdlib.h include} ÊÇ²»´óÐèÒªµÄ.

´ËÊ±, {\itshape build\/} ¹ý³ÌÃ»ÓÐÈÎºÎÖØ´ó´íÎó. 
{\bfseries xloadimage} ³ÌÊ½ÏÖÔÚ¹¦ÄÜ¶¼Õý³£.












\section{µÚÈý¸öÀý×Ó: Fortune}

×îááÀý×ÓÐèÒªÄ³Ð© C ³ÌÊ½Éè¼ÆÖªÊ¶. ´ó²¿·ÖµÄ Linux ÈíÌåÊÇÓÃ C Ð´µÄ,
¶øÇÒÖÁÉÙÑ§µã C Ã÷ÏÔµÄ¶ÔÈÎºÎÏëÈíÌå°²×°µÄÈË»áÓÐÖúÒæ.

¶ñÃûÕÑÕÃµÄ(notorious) {\itshape fortune\/} ³ÌÊ½ÔÚÃ¿´Î Linux 
¿ª»úÆðÀ´Ê±Ðã³öÓÄÄ¬µÄÑèÓï "fortune cookie".
²»ÐÒµØ (ÓÐË«¹ØÒâË¼µÄ), Éè·¨ÔÚ Red Hat ·¢ÐÐÌ×¼þ 2.0.30 µÄºËÐÄÏÂ½¨Á¢,³öÏÖÁË
Ò»¶ÑÑÏÖØµÄ´íÎó. 

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
~/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
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}








¿´Ò»ÏÂ {\ttfamily fortune.c}, ÓÐ¹ØÁªµÄ¼¸ÐÐÔÚÕâ.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
   if (dirent->d_namlen == 0)
            continue;
        name = copy(dirent->d_name, dirent->d_namlen);
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÎÒÃÇÐèÒªÕÒ³ö {\ttfamily dirent} µÄ structure, µ«ËüÃ»ÓÐÐû¸æ(declared)ÔÚ 
{\itshape fortune.c\/} µµ°¸ÖÐ, ÏëÓÃ {\bfseries grep dirent} 
À´Ðã³öÊÇ·ñÔÚÆäËüÔ­Ê¼ÂëµÄµµ°¸ÖÐ, µ«Ò²Ã»ÓÐ. È»¶ø, ÔÚ {\itshape fortune.c\/}
µµµÄ×îÉÏ·½ÓÐÏÂÁÐÕâÐÐ.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
#include <dirent.h>
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÕâËÆºõÊÇÏµÍ³º¯Ê½¿âµÄ include µµ°¸, ËùÒÔÒªÕÒ {\itshape dirent.h\/} µÄºÏÀíÎ»ÖÃÊÇÔÚ
{\itshape /usr/include\/}. ÊÂÊµÉÏ, {\itshape dirent.h\/} µÄÈ·ÓÐÔÚ {\itshape /usr/include\/}
ÖÐ, µ«¸ÃµµÃ»ÓÐ°üº¬ {\ttfamily dirent} µÄ structure. È»¶ø, ²Î¿¼ÁíÒ»¸ö
{\itshape dirent.h\/} µµ.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
#include <linux/dirent.h>
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}




×îáá, È¥ {\itshape /usr/include/linux/dirent.h\/}, ÎÒÃÇ¿ÉÕÒµ½ÎÒÃÇËùÐèÒªÐû¸æµÄ
structure.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
struct dirent {
        long            d_ino;
        __kernel_off_t  d_off;
        unsigned short  d_reclen;
        char            d_name[256]; /* We must not include
limits.h! */
};
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}

×ã¹»µØÈ·¶¨, Õâ¸ö structure Ðû¸æÃ»ÓÐ°üº¬ {\itshape d\_namelen\/},
µ«ÓÐÒ»¶ÔÓëÆäÏàµ±µÄÑ¡Ôñ. ÆäÖÐ×î¿ÉÄÜµÄÊÇ {\itshape d\_reclen\/}, ÒòÎª
Õâ¸ö structure member ±íÊ¾Ä³Ñù¶«Î÷µÄ length ¶øÇÒËüÊÇ short integer.
ÆäËû´óÂÔ, {\itshape d\_ino\/}, ¿ÉÄÜÊÇ inode number, ÅÐ¶ÏËüµÄ name ºÍ type.
ÊÂÊµÉÏ, ÎÒÃÇ´ó¸ÅÊÇ´¦Àí "directory entry" structure, ¶øÔªËØ±íÊ¾µµ°¸ÊôÐÔ,
ËüµÄÃû³Æ, inode, ºÍ length (ÒÔ blocks ×÷µ¥Î»). ÕâËÆºõ¶ÔÎÒÃÇµÄ²ÂÏëºÜºÏÀí.

ÎÒÃÇ±à¼­µµ°¸ {\itshape fortune.c\/}, ¶øÇÒ¸Ä±äÔÚ551ÐÐºÍ553ÐÐµÄ {\ttfamily d\_namelen}
±ä³É {\ttfamily d\_reclen}. ÔÙÊÔÊÔ {\ttfamily make all}. {\bfseries Success.} 
Õâ´Î½¨Á¢Ã»ÓÐ´íÎó. ÎÒÃÇÏÖÔÚÄÜ¹»´Ó {\itshape fortune\/} »ñµÃ "cheap thrills"




\section{ÄÄ¡õ¿ÉÕÒµ½Ô­Ê¼Âëµµ°¸}

ÏÖÔÚÄãºÜ¿ÊÍûµÄÊ¹ÓÃÄã×îÐÂ»ñµÃµÄÖªÊ¶À´¼ÓÈëÒ»Ð©¹¤¾ßºÍÆäËüºÃ¶«Î÷µ½ÄãµÄÏµÍ³,
Äã¿ÉÒÔÔÚÏßÉÏÕÒµ½ËüÃÇ,
\nameurl{http://www.redhat.com/linux-info/linux-app-list/linapps.html}{Linux Applications and Utilities Page}, 
»òÕßÔÚºÜºÏÀí¼ÛÎ»µÄ CD ROM µÄµµ°¸, ½åÓÉ \nameurl{http://www.redhat.com/}{Red Hat}, \nameurl{mailto:orders@infomagic.com}{InfoMagic}, ÒÔ¼°ÆäËüµÄ. 

Ò»¸öÖÚ¶àÔ­Ê¼ÂëµÄ±¦¿âÊÇÔÚ \nameurl{ftp://ftp.vix.com/pub/usenet/comp.sources.unix/}{comp sources UNIX archive}.

ºÜ¶à UNIX Ô­Ê¼Âë·¢±íÔÚ \onlynameurl{alt.sources}
ÐÂÎÅÈº×é. Èç¹ûÄãÒªÕÒÌØ±ðµÄÔ­Ê¼Âë°ü×°µÄ, Äã¿ÉÒÔÌùÔÚÏà¹ØµÄ \onlynameurl{alt.sources.wanted} ÐÂÎÅÈº×é.
ÁíÍâÒ»¸ö²»´íµÄµØ·½ÊÇ²é¿´  \onlynameurl{comp.os.linux.announce} ÐÂÎÅÈº×é. ÒªÈ¡µÃÔÚ \nameurl{mailto:unix-sources@pa.dec.com}{Unix sources} µÄÍ¨ÐÅÂÛÌ³,
Çë¼Ä¸ö {\itshape subscribe\/} Ñ¶Ï¢µ½ÄÇ.

ÖÁì¶\onlynameurl{alt.sources} 
ÐÂÎÅÈº×éµÄµµ°¸ÊÇÔÚÏÂÃæ ftp Õ¾:

\begin{itemize}
\item \nameurl{ftp://ftp.sterling.com/usenet/alt.sources/}{ftp.sterling.com/usenet/alt.sources/}
\item \nameurl{ftp://wuarchive.wustl.edu/usenet/alt.sources/articles}{wuarchive.wustl.edu/usenet/alt.sources/articles}
\item \nameurl{ftp://src.doc.ic.ac.uk/usenet/alt.sources/articles}{src.doc.ic.ac.uk/usenet/alt.sources/articles}
\end{itemize}









\section{½áÓï}

×Ü½á, °ÙÕÛ²»ÄÓ»áÊ¹Ê²÷á¶¼±ä³É²»Ò»Ñù (¶øÇÒ¸ßÄÑ¶È´ìÕÛÃÅ¼÷Ã÷ÏÔ»áÓÐ°ïÖú).
Ê¹³öÈ«Á¦,´ÓÊ§°ÜÖÐ»ñµÃÑ§Ï°¸üÊÇÖØÒª. ÔÚÃ¿¸ö¹ýÊ§µÄ²½·¥, 
Ã¿¸öÊ§°ÜÔì¾ÍÁËÄÜ¹»ÕÆÎÕ {\bfseries ½¨Á¢ÈíÌåÒÕÊõ} µÄÖªÊ¶¸öÌå.






\section{²Î¿¼Óë½øÒ»²½ÔÄ¶Á×ÊÁÏ\label{refs}}



\begin{tscreen}
\begin{verbatim}
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 ²Î¿¼×ÊÁÏ×îºÃµÄ, ËäÈ»ÔÚÄ³Ð©µØ·½È±ÉÙ±È½ÏÉîÈëÌÖÂÛ.]
\end{verbatim}
\end{tscreen}


µ±È»»¹ÓÐ {\itshape make\/},
{\itshape imake\/}, {\itshape xmkmf\/}, {\itshape gcc\/}, {\itshape ldconfig\/},
{\itshape gzip\/}, {\itshape tar\/}, ºÍ {\itshape patch\/} µÄ {\ttfamily man pages}.



\end{document}
