Macros in make
The make program allows you to use macros, which are similar to
variables, to store names of files. The format is as follows: Here is our sample Makefile again, using a macro.
OBJECTS = data.o main.o io.o
project1: $(OBJECTS)
cc $(OBJECTS) -o project1
data.o: data.c data.h
cc -c data.c
main.o: data.h io.h main.c
cc -c main.c
io.o: io.h io.c
cc -c io.c
You can also specify a macro's value when running make, as follows:make 'OBJECTS=data.o newio.o main.o' project1 This overrides the value of OBJECTS in THE Makefile |
Author: Ben Yoshino (ben@wiliki.eng.hawaii.edu)Comments, Questions? | E-mail: webmaster@wiliki.eng.hawaii.edu Last updated on Monday, February 05, 2001 Copyright © 2001 University of Hawai`i, College of Engineering, Computer Facility All rights reserved. |