Gmake Tutorial
Gmake Tutorial
gmake
• Write a Makefile
helloworld : helloworld.c
cc helloworld.c -o helloworld
• Run gmake
gmake output on screen: cc helloworld.c -o helloworld
• Run gmake again
gmake output on screen: gmake: helloworld is up to date.
• A shorter version of this Makefile
helloworld :
all
rules
• Expanding is direct
Suppose we define:
x := oldtext
y := $(x) extrastuff
x := newtext
– '%' may also be used in the prerequisites, as a place holder for the
string matched by '%' in the current target. As example, the rule to
build an object file in the same directory as its C-file:
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
easy, after
the scripting
workshop;-)
function definition
function call