help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What does this piece of code from a Makefile do??


From: John Graham-Cumming
Subject: Re: What does this piece of code from a Makefile do??
Date: Tue, 10 May 2005 21:52:51 -0400

On Tue, 2005-05-10 at 23:15 +0100, haynes george wrote:
> ALL = prog1 prog2 prog3 prog4 prog5
> 
> LOCK_DIR = /var/lock/test
> ECHO = /bin/echo
> BIN_DIR = /home/bin
> TMP_FILE = /home/temp/tmp.file
> JOB = start
> 
> 
> $(ALL)        : $(SUBSYS_FILE_DIR)/$@ 

This defines five rules (one each for prog1, prog2, ...) in the form:

prog1: $(SUBSYS_FILE_DIR)/prog1

etc.  Note, however, that this was not done with GNU Make because GNU
Make does not allow $@ in the prereq list (it does allow $$@ for SysV
compatibility).

> @$(ECHO) "Begin \"$(JOB) address@hidden"  >  $(TMP_FILE)

This writes a string to $(TMP_FILE) so for prog1 /home/temp/tmp.file
gets the line Begin "start prog1" written to it.

> @$(BIN_DIR)/$@  $(JOB)      >> $(TMP_FILE) 2>&1  

This then runs $(BIN_DIR)/prog1 (or prog2, ...) and appends the output
to the temporary file mapping handle 2 to 1 (i.e. errors go into the
file as well).

> @$(ECHO) "End \"$(JOB) address@hidden"   >> $(TMP_FILE)     

And this appends End "start prog1" or similar to the temporary file.

> prog1 : prog2 prog3
> prog3 : prog4
> prog4 
> prog5 : prog4 prog1

And these are just dependencies between the various programs.

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]