. 40
( 69 .)


drawfigs.tar is tar -xvf drawfigs.tar. The -v
and a -v argument, making the command tar -xvf, if you
argument of the tar command stands for verbose. When
want to list the files as you extract them.
you use this option, the tar command displays each
filename as it extracts the file.
To ensure that the TAR file is intact, it is always a good idea
to examine the contents of the TAR file before you extract
from it. If you downloaded a TAR file without using binary
mode, you may end up with a file that is corrupt. Checking
the contents also tells you where the software installs when
you extract it. Most TAR files install in the directory that you
are in when you issue the tar command.


‹ Type the name of a TAR ‹ Type the name of a TAR
file, and press Return. file, and press Return.
„ In a Terminal window, „ In a Terminal window,
– The contents of the TAR – The contents of the TAR
type tar followed by a space. type tar followed by a space.
file appear. file extract into the current
¤ Type tvf followed by a ¤ Type xvf followed by a directory.
space. space.


You can use the tar command to extract a single file or directory
from an archive instead of the entire contents. For example, you
may want to first read the license agreement or README file before
proceeding to extract the remaining contents from the archive.
To extract a single file from a TAR file, add the name of that file to
the end of the tar command. The command tar -xvf
drawfigs.tar README extracts only the README file. If you are
extracting a file from a directory inside the TAR file, be careful to
type the directory name and filename exactly as they appear in the
file listing produced by the tar -tvf command. For example, if
the file you want to extract appears as tmpls/template1.tmpl, type
the command tar xvf drawfigs.tar tmpls/template1.tmpl.
If you want to change some part of the pathname for the extracted
files while you are extracting them, you can use the -s option. For
example, if want to change the tmpls directory to orig_tmpls
during the extraction, you can type tar -s /tmpls/orig_tmpls/ -xvf

¤ Type the name of a ¤ Type the name of a
gunzipped TAR file, and compressed TAR file, and
„ In a Terminal window, „ In a Terminal window,
press Return. press Return.
type gunzip followed by a type uncompress followed by
– The TAR file is – The TAR file is
space. a space.
uncompressed. uncompressed.


than the source code; after all, this indicates that no

ou can compile software from source code with a
changes have been made to the code since it was last
utility called make, a tool favored by many users of
compiled. Large applications containing many source files
open source software. make is not itself a compiler,
recompile much faster than they first compiled because
but a tool that manages compilation. With the Mac OS X
only the updated source files are recompiled. You can also
system, make calls gcc, the GNU C compiler, to compile the
run make without a Makefile to compile a program with a
source code.
single source file.
While the process of compiling your own applications might
Source code prepared specifically for Mac OS X may
seem tedious at first, some developments have arisen that
already include a Makefile. Generic source code requires an
have made source code compiling much more efficient. For
additional step that evaluates the configuration of your
one, the process of going from source code to executable
system and creates an appropriate Makefile.
has become significantly standardized; if you can remember
this sequence of steps ” configure, make, make install, and
The make install step uses instructions in the Makefile to
make clean ” you can build and install most software that
install the application into the directory from which you
you find. For another, you can often avoid the manual
want it to run. The make clean step removes object files,
process of compiling by using a tool such as Fink.
which are intermediate files in the compilation of a
complex application.
One reason why make is efficient is because it does not
recompile a program when the existing program is newer


‹ Type main() { and press Á Save your file, and exit ° Type chmod a+x greetme
A SMALL PROGRAM Return. the editor. and press Return.
„ Open a text editor to – Your simple C program is
› Press the spacebar four · Type ./greetme and press
create a file named greetme.c. times, type printf("Hello, saved in your directory. Return.
– The blank editor screen there!\n"); and then press
– The make utility compiles
‡ Type make greetme and
appears. press Return. your program, and your
ˇ Type }.
¤ Type #include <stdio.h> program runs.
and press Return twice.


When you compile Apache from the compressed TAR file that you
download from www.apache.org, there are several steps you must
follow. First, you must uncompress the file, and extract the
contents. You must then run the configure command to prepare
your Makefile, execute the make command to read the Makefile,
and call gcc to compile each piece of code and create your
executables. After this, you run make install to place the new
binaries and associated configuration files in the directories from
which you want to run them, and then run make clean to remove
intermediate files. While that process involves a number of steps,
these steps become second nature after you build several
applications this way.
It is always a good idea to read the included README or INSTALL
files before you begin the compilation process. These files often
contain instructions that make building the application easier. For
example, you may run through all the steps of the building process
for Apache without realizing that adding a prefix specification such
as ”prefix=/sw/apache to your configure command tells
Apache to install as /sw/apache/httpd and to look for configuration
files in /sw/apache/conf.

– The make process tells you – The make process
‚ Type make greetme and ” Type touch greetme.c to
press Return. there is nothing to be done give your source file a newer compiles your code again.
because the source file has timestamp than the compiled
– The make utility compiles
not changed. file.
your software.
± Type make greetme and
press Return.


complete. During this stage of preparing for compilation,

ou can compile and install a new version of Apache
information about your system is being collected and
from source code. New versions are available from
analyzed and a Makefile is being prepared that guides the
time to time from www.apache.org. Installing a new
compilation process on your Mac OS X system. Keep in
version may give you additional features, better security, or
mind that the Apache distribution was built so that it would
improved performance.
compile on many different types of systems. Therefore, this
configuration step is critical to the compilation on any
You compile Apache with the standard set of steps for
particular operating system.
compiling open source software. You generally start with a
gzipped TAR file freshly downloaded from apache.org. You
After the configuration operation is complete, you can
then need to unzip that file with gunzip, and untar the
begin the actual compilation using the make command. The
resulting file with tar xvf. After your untar operation is
make command starts by reading the Makefile that the
complete, you have a directory containing all of the files
configuration process created and using it to drive the
needed for configuring and compiling the new version of
compilation process. Unlike the use of make with a simple
C source code file, this make process compiles many
different programs and builds a small number of programs,
After moving into the new Apache source directory with the
in particular the httpd process that represents the Web
cd command, you run the configure script that is included
server you have just built.
with the distribution. This step takes several minutes to


– Your Apache Makefile is
„ Type gunzip followed by ¤ Type tar xf followed by › Type ./configure --prefix=
the name of your downloaded the name of your Apache followed by the name of the created.
Apache source file, for TAR file, for example httpd- directory in which you want
example httpd-2.0.43.tar.gz, 2.0.43.tar, and press Return. your new Apache server
and press Return. installed, for example /sw,
‹ Type cd followed by the and press Return.
– Your downloaded file is name of your new source
unzipped. directory, for example httpd-
2.0.43, and press Return.

While your new Apache server is
After compiling and installing Apache, you have to start the
ready to run, it uses the default
server. Along with the files that you just installed is a script
DocumentRoot ” the directory
named apachectl. This script starts, restarts, and stops the
in which your Web pages will
Apache server. If you installed Apache in /sw/apache, through
install ” and serves only the set
the “prefix=/sw configure option, you can find apachectl in
of pages that the installation
/sw/apache/bin/apachectl. To start Apache, you then type
process installs. Refer to Chapter
/sw/apache/bin/apachectl start.
14 for information on configuring
The configuration and installation process described on these
your Apache server and
pages is probably the most standard process for installing Apache.
populating your new Web site.
Without the “prefix argument provided with the configure
command, Apache compiles to run from the default directory. The
remainder of the process as described uses only default values.
To learn about the many different options that you can use to build a
customized Apache server, use the command ./configure “help.

– Compilation begins. – Your new Apache server
ˇ Type make and press Á Type make install and
Return. press Return. will be installed in the


. 40
( 69 .)