Make utility

Hi Guys,

I m very confused about the make/makefile utility in all unix.

1) My questions is why we need make.
2) Why some source code needs to complile.
3) I download the Bind 9 from Sunfreeware.com. I use pkgadd -d to install the bind. I 'm struck here becasue I can't find /etc/named.conf file. Why is it so.

Thanks in advance for all help.

Kelvin :confused:

Source code doesn't 'NEED' to be compiled - source code can sit out there doing nothing at all. You would need to compile it so that you can create the executable only if you need that software.

If you were not running Bind before (or running an old version 4), then you might need to create the /etc/named.conf. I would have thought there would be an example file but I didn't find one (probably less of a download if they get rid of the stuff you can easily build). Your /etc/named.conf will be specific to your server. There are examples in the named.conf man page which would get you started. Also look at the rndc.conf man page. And suggest you buy "DNS & Bind" from O'Reilly books.

Hmm ... the Make/Makefile concept is not unique to Unix. MS Visual C++ also uses Makefile to automate the build process of a source project. It just has an interface fancy enough to hide some of its dark corners.

You need to distinguish the roles played by "make" and compilation. Make is a build utility. It defines a language (in the way you write Makefiles) that allows developers to specify exactly the way they would like their source files to be transformed (by means of external commands that carry out the actual transformation), and, most importantly, the interdependencies of source files and their derivatives (such as compiled object code, executables etc.). Finding out the interdependencies is exactly the strength of Make, otherwise we can always put the transformation commands in a batch file (shell script), which will always work but you will miss one of the major offerings of a build system - selective transformation (compilation).

For instance, given this simple Makefile:

.PHONY: all clean

all: output.html

output.html: stylesheet.xsl model.xml
    xsltproc stylesheet.xsl model.xml > output.html

clean:
    -rm output.html

which generates the file "output.html" derived from two source files "stylesheet.xsl" and "model.xml" (the dependencies). We confirm we get the generated "output.html":

cbkihong@cbkihong:/dev/shm$ make
xsltproc stylesheet.xsl model.xml > output.html

cbkihong@cbkihong:/dev/shm$ ls -l
 16
-rw-r--r--  1 cbkihong cbkihong 118 2005-10-11 08:27 Makefile
-rw-r--r--  1 cbkihong cbkihong 157 2005-10-11 08:27 model.xml
drwxr-xr-x  2 root     root      60 2005-10-11 07:51 network
-rw-r--r--  1 cbkihong cbkihong 253 2005-10-11 08:28 output.html
-rw-r--r--  1 cbkihong cbkihong 415 2005-10-11 08:28 stylesheet.xsl

But if we run "make" again,

cbkihong@cbkihong:/dev/shm$ make
make: Nothing to be done for `all'.

It detects the timestamp of "output.html" is newer than stylesheet.xsl and model.xml, so it concludes the previously generated target is up to date, hence a transformation is not required this time. So this is selective transformation. If you have a complex project involving lots of transformations, this will save you a lot of time for compilation if you have the previously generated derivatives. This is what a simple batch file that can't give you (without extra coding). Make manages this for you.

Although Make is frequently used for compilation, it is separate from the actual compilation process (which is performed by the transformation command specified). That is why I used the term "transformation" instead of "compilation" above. In the example above I did not compile any C source files, but I have used Make to automate the process of building in a likewise fashion. Think about Make as a coordinator of the build process. It manages the compilation of a source project, but the actual compilation is done by a compiler, not Make.