Make File Page:
examples:
wget http://home.adelphi.edu/~pe16132/csc270/note/SampleCode/cplus/guySample2/guy2.cpp
wget http://home.adelphi.edu/~pe16132/csc270/note/SampleCode/cplus/guySample2/guy2.h
wget http://home.adelphi.edu/~pe16132/csc270/note/SampleCode/cplus/guySample2/guy2app.cpp
wget http://home.adelphi.edu/~pe16132/csc270/note/SampleCode/cplus/guySample2/Makefile
wget http://home.adelphi.edu/~pe16132/csc270/note/SampleCode/cplus/guySample2/MakefileBetter
http://www.codeproject.com/Articles/31488/Makefiles-in-Linux-An-Overview
Makefile
Note that this contains 3 compilation steps:
1) guy2.o is created whenever guy2.cpp or guy2.h changes
2) guy2app.o is created whenever guy2app.cpp or guy2.h is created.
3) guy2app is created whenever guy2app.o or guy2.o changes
all: guy2app.o guy2.o
g++ guy2app.o guy2.o -o guy2appguy2app.o: guy2app.cpp guy2.h
g++ -c guy2app.cppguy2.o: guy2.cpp guy2.h
g++ -c guy2.cpp
In MakefileBetter
# build an executable for guy2app from my guy2app.cpp and guy2 files
# (note: the <tab> in the command line is necessary for make to work)# the variable CC will be the compiler to use.
CC=g++
# that CFLAGS will be the options I'll pass to the compiler.
CFLAGS= -Wallall: guy2app
guy2app: guy2app.o guy2.o
$(CC) $(CFLAGS) guy2app.o guy2.o -o guy2appguy2app.o: guy2app.cpp guy2.h
$(CC) $(CFLAGS) -c guy2app.cppguy2.o: guy2.cpp guy2.h
$(CC) $(CFLAGS) -c guy2.cppclean:
rm guy2app guy2.o guy2app.o