aboutsummaryrefslogtreecommitdiff
path: root/zh_TW.Big5/books/developers-handbook/tools/chapter.xml
diff options
context:
space:
mode:
Diffstat (limited to 'zh_TW.Big5/books/developers-handbook/tools/chapter.xml')
-rw-r--r--zh_TW.Big5/books/developers-handbook/tools/chapter.xml131
1 files changed, 60 insertions, 71 deletions
diff --git a/zh_TW.Big5/books/developers-handbook/tools/chapter.xml b/zh_TW.Big5/books/developers-handbook/tools/chapter.xml
index 486176ac32..7f0f4fb633 100644
--- a/zh_TW.Big5/books/developers-handbook/tools/chapter.xml
+++ b/zh_TW.Big5/books/developers-handbook/tools/chapter.xml
@@ -5,24 +5,16 @@
$FreeBSD$
Original revision: 1.46
-->
-
-<chapter id="tools">
- <chapterinfo>
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="tools">
+ <info><title>程式開發工具</title>
<authorgroup>
- <author>
- <firstname>James</firstname>
- <surname>Raynard</surname>
- <contrib>Contributed by </contrib>
- </author>
- <author>
- <firstname>Murray</firstname>
- <surname>Stokely</surname>
- </author>
+ <author><personname><firstname>James</firstname><surname>Raynard</surname></personname><contrib>Contributed by </contrib></author>
+ <author><personname><firstname>Murray</firstname><surname>Stokely</surname></personname></author>
</authorgroup>
- </chapterinfo>
+ </info>
- <title>程式開發工具</title>
- <sect1 id="tools-synopsis"><title>概敘</title>
+
+ <sect1 xml:id="tools-synopsis"><title>概敘</title>
<para>本章將介紹如何使用一些 FreeBSD 所提供的程式開發工具(programing tools),
本章所介紹的工具程式在其他版本的 &unix; 上也可使用,
@@ -32,7 +24,7 @@
</sect1>
- <sect1 id="tools-intro"><title>簡介</title>
+ <sect1 xml:id="tools-intro"><title>簡介</title>
<para>FreeBSD 提供一個非常棒的開發環境,
比如說像是 C、C++、Fortran 和 assembler(組合語言)的編譯器(compiler),
@@ -53,7 +45,7 @@
</sect1>
- <sect1 id="tools-programming">
+ <sect1 xml:id="tools-programming">
<title>Programming 概念</title>
<para>簡單的說,程式只是一堆指令的集合體;而這些指令是用來告訴電腦應該要作那些事情。
@@ -95,7 +87,7 @@
<para>下面這邊有份 &os; Ports Collection 所提供的直譯器清單,還有討論一些比較受歡迎的直譯式語言</para>
<para>至於如何使用 Ports Collection 安裝的說明,可參閱 FreeBSD Handbook 中的
- <ulink url="&url.books.handbook;/ports-using.html">Ports章節</ulink>。</para>
+ <link xlink:href="&url.books.handbook;/ports-using.html">Ports章節</link>。</para>
<variablelist>
<varlistentry>
<term><acronym>BASIC</acronym></term>
@@ -107,8 +99,8 @@
此外,BASIC 也是 Visual Basic 的基礎。</para>
<para>FreeBSD Ports Collection 也有收錄相關的 BASIC 直譯器。
- Bywater Basic 直譯器放在 <filename role="package">lang/bwbasic</filename>。
- 而 Phil Cockroft's Basic 直譯器(早期也叫 Rabbit Basic)放在 <filename role="package">lang/pbasic</filename>。</para>
+ Bywater Basic 直譯器放在 <package>lang/bwbasic</package>。
+ 而 Phil Cockroft's Basic 直譯器(早期也叫 Rabbit Basic)放在 <package>lang/pbasic</package>。</para>
</listitem>
</varlistentry>
@@ -125,12 +117,12 @@
<para>LISP 是非常強悍且複雜的程式語言,但是缺點是程式碼會非常大而且難以操作。</para>
<para>絕大部分的 LISP 直譯器都可以在 &unix; 系統上運作,當然 &os; 的 Ports Collection 也有收錄。
- GNU Common Lisp 收錄在 <filename role="package">lang/gcl</filename>,
- Bruno Haible 和 Michael Stoll 的 CLISP 收錄在 <filename role="package">lang/clisp</filename>
+ GNU Common Lisp 收錄在 <package>lang/gcl</package>,
+ Bruno Haible 和 Michael Stoll 的 CLISP 收錄在 <package>lang/clisp</package>
,此外 CMUCL(包含一個已經最佳化的編譯器),
以及其他簡化版的 LISP 直譯器(比如以 C 語言寫的 SLisp,只用幾百行程式碼就實作大多數 Common Lisp 的功能)
- 則是分別收錄在 <filename role="package">lang/cmucl</filename> 以及
- <filename role="package">lang/slisp</filename>。</para>
+ 則是分別收錄在 <package>lang/cmucl</package> 以及
+ <package>lang/slisp</package>。</para>
</listitem>
</varlistentry>
@@ -141,7 +133,7 @@
<para>對系統管理者而言,最愛用 perl 來撰寫 scripts 以管理主機,
同時也經常用來寫 WWW 主機上的 <acronym>CGI</acronym> Script 程式。</para>
- <para>Perl 在 Ports Collection 內的 <filename role="package">lang/perl5</filename>。
+ <para>Perl 在 Ports Collection 內的 <package>lang/perl5</package>。
而 &os; 4.X 則是把 Perl 裝在 <command>/usr/bin/perl</command>。</para>
</listitem>
</varlistentry>
@@ -154,10 +146,10 @@
由於 Scheme 簡單,所以很多大學拿來當作第一堂程式語言教學教材。
而且對於研究人員來說也可以快速的開發他們所需要的程式。</para>
- <para>Scheme 收錄在 <filename role="package">lang/elk</filename>,
+ <para>Scheme 收錄在 <package>lang/elk</package>,
Elk Scheme 直譯器(由麻省理工學院所發展的 Scheme 直譯器)收錄在
- <filename role="package">lang/mit-scheme</filename>,
- SCM Scheme Interpreter 收錄在 <filename role="package">lang/scm</filename>。</para>
+ <package>lang/mit-scheme</package>,
+ SCM Scheme Interpreter 收錄在 <package>lang/scm</package>。</para>
</listitem>
</varlistentry>
@@ -167,7 +159,7 @@
<listitem>
<para>Icon 屬高階程式語言,Icon 具有強大的字串(String)和結構(Structure)處理能力。
&os; Ports Collection 所收錄的 Icon 直譯器版本則是放在
- <filename role="package">lang/icon</filename>。</para>
+ <package>lang/icon</package>。</para>
</listitem>
</varlistentry>
@@ -179,7 +171,7 @@
如果要給小朋友開始上程式語言課的話,Logo 是相當不錯的選擇。
因為,即使對小朋友來說,要用 Logo 來秀出複雜多邊形圖形是相當輕鬆容易的。</para>
- <para>Logo 在 &os; Ports Collection 的最新版則是放在 <filename role="package">lang/logo</filename>。</para>
+ <para>Logo 在 &os; Ports Collection 的最新版則是放在 <package>lang/logo</package>。</para>
</listitem>
</varlistentry>
@@ -192,7 +184,7 @@
雖然 Python 可以很簡單的開始,但是不代表它就會輸給其他直譯式語言(像是 Perl 和 Tcl),
事實證明 Python 也可以拿來開發大型、複雜的應用程式。</para>
- <para>&os; Ports Collection 收錄在 <filename role="package">lang/python</filename>。</para>
+ <para>&os; Ports Collection 收錄在 <package>lang/python</package>。</para>
</listitem>
</varlistentry>
@@ -204,7 +196,7 @@
Ruby 目前非常流行,原因在於他易懂的程式語法結構,在撰寫程式時的彈性,
以及天生具有輕易的發展維護大型專案的能力。</para>
- <para>&os; Ports Collection 收錄在 <filename role="package">lang/ruby8</filename>。</para>
+ <para>&os; Ports Collection 收錄在 <package>lang/ruby8</package>。</para>
</listitem>
</varlistentry>
@@ -216,7 +208,7 @@
Tcl 也可以快速發展一個簡單但是具有雛型的程式或者具有完整功能的程式。</para>
<para>Tcl 許多的版本都可在 &os; 上運作,而最新的 Tcl 版本為 Tcl 8.4,
- &os; Ports Collection 收錄在 <filename role="package">lang/tcl84</filename>。</para>
+ &os; Ports Collection 收錄在 <package>lang/tcl84</package>。</para>
</listitem>
</varlistentry>
</variablelist>
@@ -248,13 +240,13 @@
Pascal 其實是一個設計用來教學用的程式語言,而且也很適合用來入門,
&os; 預設並沒有把 Pascal 整合進 base system 中,
但是 GNU Pascal Compiler 和 Free Pascal Compiler 都可分別在
- <filename role="package">lang/gpc</filename> 和 <filename role="package">lang/fpc</filename> 中找到。</para>
+ <package>lang/gpc</package> 和 <package>lang/fpc</package> 中找到。</para>
<para>如果你用不同的程式來寫編譯式程式,那麼不斷地編輯-編譯-執行-除錯的這個循環肯定會很煩人,
為了更簡化、方便程式開發流程,很多商業編譯器廠商開始發展所謂的 <acronym>IDE</acronym>
(Integrated Development Environments) 開發環境,
FreeBSD 預設並沒有把 IDE 整合進 base system 中,
- 但是你可透過 <filename role="package">devel/kdevelop</filename> 安裝 kdevelop
+ 但是你可透過 <package>devel/kdevelop</package> 安裝 kdevelop
或使用 <application>Emacs</application> 來體驗 IDE 開發環境。
在後面的 <xref linkend="emacs"/> 專題將介紹,如何以 <application>Emacs</application> 來作為 IDE 開發環境。</para>
</sect2>
@@ -263,7 +255,7 @@
</sect1>
- <sect1 id="tools-compiling">
+ <sect1 xml:id="tools-compiling">
<title>用 <command>cc</command> 來編譯程式</title>
<para>本章範例只有針對 GNU C compiler 和 GNU C++ compiler 作說明,
@@ -351,8 +343,8 @@
</footnote></para>
<informalexample>
- <screen>&prompt.user; <userinput>cc foobar.c</userinput> <lineannotation>執行檔就是 <filename>a.out</filename></lineannotation>
-&prompt.user; <userinput>cc -o foobar foobar.c</userinput> <lineannotation>執行檔就是 <filename>foobar</filename></lineannotation>
+ <screen>&prompt.user; <userinput>cc foobar.c</userinput> <lineannotation>執行檔就是 a.out</lineannotation>
+&prompt.user; <userinput>cc -o foobar foobar.c</userinput> <lineannotation>執行檔就是 foobar</lineannotation>
</screen>
</informalexample>
</listitem>
@@ -482,7 +474,7 @@
跟其他作業平台不一樣的是,這函示學函式都不在標準函式庫(library)中,
因此編譯器並不知道這函式庫名稱,你必須告訴編譯器要加上它才行。</para>
- <para>規則很簡單,如果有個函式庫叫做 <filename>lib<replaceable>something</replaceable>.a</filename>,
+ <para>規則很簡單,如果有個函式庫叫做 <filename>libsomething.a</filename>,
就必須在編譯時加上參數 <option>-l<replaceable>something</replaceable></option> 才行。
舉例來說,數學函式庫叫做 <filename>libm.a</filename>,
所以你必須給 <command>cc</command> 的參數就是 <option>-lm</option>。
@@ -820,7 +812,7 @@ free(foo);
<para>to find out the process ID of your program, and
do</para>
- <screen>&prompt.user; <userinput>kill -ABRT <replaceable>pid</replaceable></userinput>
+ <screen>&prompt.user; <userinput>kill -ABRT pid</userinput>
</screen>
<para>where
@@ -848,7 +840,7 @@ free(foo);
</sect2>
</sect1>
- <sect1 id="tools-make">
+ <sect1 xml:id="tools-make">
<title>Make</title>
<sect2>
@@ -971,22 +963,22 @@ install:
<para>We can tell make which target we want to make by
typing:</para>
- <screen>&prompt.user; <userinput>make <replaceable>target</replaceable></userinput></screen>
+ <screen>&prompt.user; <userinput>make target</userinput></screen>
<para><command>make</command> will then only look at that target
and ignore any others. For example, if we type
<userinput>make foo</userinput> with the makefile above, make
- will ignore the <maketarget>install</maketarget> target.</para>
+ will ignore the <buildtarget>install</buildtarget> target.</para>
<para>If we just type <userinput>make</userinput> on its own,
make will always look at the first target and then stop
without looking at any others. So if we typed
<userinput>make</userinput> here, it will just go to the
- <maketarget>foo</maketarget> target, re-compile
+ <buildtarget>foo</buildtarget> target, re-compile
<filename>foo</filename> if necessary, and then stop without
- going on to the <maketarget>install</maketarget> target.</para>
+ going on to the <buildtarget>install</buildtarget> target.</para>
- <para>Notice that the <maketarget>install</maketarget> target does not
+ <para>Notice that the <buildtarget>install</buildtarget> target does not
actually depend on anything! This means that the command on
the following line is always executed when we try to make that
target by typing <userinput>make install</userinput>. In this
@@ -1190,7 +1182,7 @@ DISTFILES= scheme-microcode+dist-7.3-freebsd.tgz
</sect2>
</sect1>
- <sect1 id="debugging">
+ <sect1 xml:id="debugging">
<title>Debugging</title>
<sect2>
@@ -1200,12 +1192,12 @@ DISTFILES= scheme-microcode+dist-7.3-freebsd.tgz
<command>gdb</command> (<application>GNU
debugger</application>). You start it up by typing</para>
- <screen>&prompt.user; <userinput>gdb <replaceable>progname</replaceable></userinput></screen>
+ <screen>&prompt.user; <userinput>gdb progname</userinput></screen>
<para>although most people prefer to run it inside
<application>Emacs</application>. You can do this by:</para>
- <screen><userinput>M-x gdb RET <replaceable>progname</replaceable> RET</userinput></screen>
+ <screen><userinput>M-x gdb RET progname RET</userinput></screen>
<para>Using a debugger allows you to run the program under more
controlled circumstances. Typically, you can step through the
@@ -1222,8 +1214,7 @@ DISTFILES= scheme-microcode+dist-7.3-freebsd.tgz
on a few of the basic commands.</para>
<para>Finally, if you find its text-based command-prompt style
- off-putting, there is a graphical front-end for it (<ulink
- url="&url.base;/ports/devel.html">xxgdb</ulink>) in the ports
+ off-putting, there is a graphical front-end for it (<link xlink:href="&url.base;/ports/devel.html">xxgdb</link>) in the ports
collection.</para>
<para>This section is intended to be an introduction to using
@@ -1306,15 +1297,15 @@ GDB is free software and you are welcome to distribute copies of it
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.13 (i386-unknown-freebsd), Copyright 1994 Free Software Foundation, Inc.
(gdb) <userinput>break main</userinput> <lineannotation>Skip the set-up code</lineannotation>
-Breakpoint 1 at 0x160f: file temp.c, line 9. <lineannotation><command>gdb</command> puts breakpoint at <function>main()</function></lineannotation>
-(gdb) <userinput>run</userinput> <lineannotation>Run as far as <function>main()</function></lineannotation>
+Breakpoint 1 at 0x160f: file temp.c, line 9. <lineannotation>gdb puts breakpoint at main()</lineannotation>
+(gdb) <userinput>run</userinput> <lineannotation>Run as far as main()</lineannotation>
Starting program: /home/james/tmp/temp <lineannotation>Program starts running</lineannotation>
-Breakpoint 1, main () at temp.c:9 <lineannotation><command>gdb</command> stops at <function>main()</function></lineannotation>
+Breakpoint 1, main () at temp.c:9 <lineannotation>gdb stops at main()</lineannotation>
(gdb) <userinput>n</userinput> <lineannotation>Go to next line</lineannotation>
This is my program <lineannotation>Program prints out</lineannotation>
-(gdb) <userinput>s</userinput> <lineannotation>step into <function>bazz()</function></lineannotation>
-bazz (anint=4231) at temp.c:17 <lineannotation><command>gdb</command> displays stack frame</lineannotation>
+(gdb) <userinput>s</userinput> <lineannotation>step into bazz()</lineannotation>
+bazz (anint=4231) at temp.c:17 <lineannotation>gdb displays stack frame</lineannotation>
(gdb)</screen>
<para>Hang on a minute! How did <symbol>anint</symbol> get to be
@@ -1323,9 +1314,9 @@ bazz (anint=4231) at temp.c:17 <lineannotation><command>gdb</command> displays
move up to <function>main()</function> and have a look.</para>
<screen>(gdb) <userinput>up</userinput> <lineannotation>Move up call stack</lineannotation>
-#1 0x1625 in main () at temp.c:11 <lineannotation><command>gdb</command> displays stack frame</lineannotation>
-(gdb) <userinput>p i</userinput> <lineannotation>Show us the value of <symbol>i</symbol></lineannotation>
-$1 = 4231 <lineannotation><command>gdb</command> displays <literal>4231</literal></lineannotation></screen>
+#1 0x1625 in main () at temp.c:11 <lineannotation>gdb displays stack frame</lineannotation>
+(gdb) <userinput>p i</userinput> <lineannotation>Show us the value of i</lineannotation>
+$1 = 4231 <lineannotation>gdb displays 4231</lineannotation></screen>
<para>Oh dear! Looking at the code, we forgot to initialize
<symbol>i</symbol>. We meant to put</para>
@@ -1366,7 +1357,7 @@ main() {
listings of core files and sweat over machine code manuals,
but now life is a bit easier. Incidentally, under FreeBSD and
other 4.4BSD systems, a core file is called
- <filename><replaceable>progname</replaceable>.core</filename> instead of just
+ <filename>progname.core</filename> instead of just
<filename>core</filename>, to make it clearer which program a
core file belongs to.</para>
@@ -1374,7 +1365,7 @@ main() {
the usual way. Instead of typing <command>break</command> or
<command>run</command>, type</para>
- <screen>(gdb) <userinput>core <replaceable>progname</replaceable>.core</userinput></screen>
+ <screen>(gdb) <userinput>core progname.core</userinput></screen>
<para>If you are not in the same directory as the core file,
you will have to do <userinput>dir
@@ -1432,7 +1423,7 @@ Cannot access memory at address 0x7020796d.
use <command>ps</command> to find the process ID for the
child, and do</para>
- <screen>(gdb) <userinput>attach <replaceable>pid</replaceable></userinput></screen>
+ <screen>(gdb) <userinput>attach pid</userinput></screen>
<para>in <command>gdb</command>, and then debug as usual.</para>
@@ -1460,7 +1451,7 @@ else if (pid == 0) { /* child */
</sect2>
</sect1>
- <sect1 id="emacs">
+ <sect1 xml:id="emacs">
<title>Using Emacs as a Development Environment</title>
<sect2>
@@ -1549,9 +1540,8 @@ else if (pid == 0) { /* child */
<para>And doubtless many more that I have overlooked.</para>
- <para>Emacs can be installed on FreeBSD using <ulink
- url="&url.base;/ports/editors.html">the Emacs
- port</ulink>.</para>
+ <para>Emacs can be installed on FreeBSD using <link xlink:href="&url.base;/ports/editors.html">the Emacs
+ port</link>.</para>
<para>Once it is installed, start it up and do <userinput>C-h
t</userinput> to read an Emacs tutorial&mdash;that means
@@ -1633,9 +1623,8 @@ else if (pid == 0) { /* child */
although it is considerably smaller (and thus easier to
master).</para>
- <para>The best way to learn Emacs Lisp is to download the <ulink
- url="ftp://ftp.gnu.org/old-gnu/emacs/elisp-manual-19-2.4.tar.gz">Emacs
- Tutorial</ulink></para>
+ <para>The best way to learn Emacs Lisp is to download the <link xlink:href="ftp://ftp.gnu.org/old-gnu/emacs/elisp-manual-19-2.4.tar.gz">Emacs
+ Tutorial</link></para>
<para>However, there is no need to actually know any Lisp to get
started with configuring Emacs, as I have included a sample
@@ -1702,7 +1691,7 @@ else if (pid == 0) { /* child */
if you are doing something outside Emacs and you want to
edit a file, you can just type in</para>
- <screen>&prompt.user; <userinput>emacsclient <replaceable>filename</replaceable></userinput>
+ <screen>&prompt.user; <userinput>emacsclient filename</userinput>
</screen>
<para>and then you can edit the file in your
@@ -2081,7 +2070,7 @@ else if (pid == 0) { /* child */
</sect2>
</sect1>
- <sect1 id="tools-reading">
+ <sect1 xml:id="tools-reading">
<title>Further Reading</title>
<para>For information about setting up a development environment