Newsgroups: comp.os.minix
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!lll-winken.llnl.gov!uwm.edu!chi-news.cic.net!newsfeed.internetmci.com!swrinde!sgigate.sgi.com!uhog.mit.edu!news.mtholyoke.edu!news.umass.edu!news.hampshire.edu!hamp!aswNS
From: aswNS@hamp.hampshire.edu (Albert S Woodhull)
Subject: Re: MAKE commands!?
Message-ID: <b187cb$101f1d.d9@news.hampshire.edu>
Date: Fri, 24 Nov 1995 21:31:29 GMT
References: <4948ja$2nb@mimas.hts.hsa.nl>
Organization: Hampshire College, Amherst MA
X-Newsreader: TIN [version 1.2 PL2]
Lines: 71

On 24 Nov 1995 11:59:54 +0100 M.L.A. Lammerse (e9360@mimas.hts.hsa.nl)
wrote in comp.os.minix:

: Can anyone provide me with information on the syntax for the MAKE utility?

There is quite a lot to this, you'd do best to get hold of a
reference. I recommend chapter 19 of Gilly et al's UNIX in a Nutshell 
(O'Reilly). There are also lots of examples in the Minix source tree. 

Basically, a make file specifies what file depends upon what other
files.  Here's a simple example:

------------------------------
CFLAGS	= -D_MINIX -D_POSIX_SOURCE
#CFLAGS	= -D_LINUX -D_POSIX_SOURCE -ansi
CCLD	= $(CC) -i $(CFLAGS)
MAKE	= exec make -$(MAKEFLAGS) install

xd:	xd.c
	$(CCLD) -o $@ $?

install:	/usr/local/bin/xd

/usr/local/bin/xd:	xd
	install -cs -o bin xd $@
clean:
	rm -rf a.out core 
-------------------- 

The first lines define macros. Some, like CC, the name of the system C
compiler, have default values already defined. 

Following are the dependency definitions. There can be three parts: a
label, depencies, and actions. Each colon-terminated string beginning
at the left margin is a label specifying something that may be made
(or done). Anything following the label on the same line defines the
dependencies for that label. There may be none, as in the "clean:"
entry.  A logical line may be wrapped using the usual "\" escape at
the end of a physical line.  The indented lines following a dependency
are the actions to be taken.

For instance if you type "make clean" at the system prompt the actions
specified after that label will be taken. There are no dependencies
listed, so the actions are taken unconditionally.

The first label is the default action, if you type "make" or "make xd"
in the directory containing this Makefile the same actions will ensue.

Dependencies work according to comparisons of the date and time of
last modification of the relevant files. In this example the
dependence of xd on xd.c means that the compiler does not need to be
invoked if the file xd.c is older than the xd executable.

The various labels can chain together. In this example, if you type
"make install" you may also cause the compiler to execute, if the xd
binary is not as new as the xd.c source file.

There is one awful, confusing, stupid thing about make files. This is
that the command lines that follow the dependency lines must begin
with tabs. Just about everywhere else in the Unix world white space is
white space, and replacing tabs with spaces or vice-versa makes no
difference. It does make a difference here. Spaces won't work. It
could very well be that in transmitting this makefile example to you
inside a mail message it has been rendered unusable by invisible
changes of tabs to spaces.

--
Albert S. Woodhull, Hampshire College, Amherst, MA
awoodhull@hamp.hampshire.edu
woodhull@shaysnet.com
413-549-2962

