Makefile Examples
#A simple makefile
#Lines beginning with # are comments
#Targets begin at the left margin, followed by ":"
#Shell command lines begin with a tab
# Compiling with -o lets you name the output file (instead of a.out)
parser:
g++ -o parser line.cpp pstack.cpp parse.cpp
#Ex 2.
parser: parse.o line.o pstack.o
g++ -o parser line.o pstack.o parse.o
parse.o: parse.cpp token.h line.h pstack.h
g++ -c parse.cpp
line.o: line.cpp line.h token.h
g++ -c line.cpp
pstack.o: pstack.cpp pstack.h token.h
g++ -c pstack.cpp
#Ex 3.
parser: parse.o line.o pstack.o
g++ -o parser line.o pstack.o parse.o
parse.o: parse.cpp token.h line.h pstack.h
g++ -c parse.cpp
line.o: line.cpp line.h token.h
g++ -c line.cpp
pstack.o: pstack.cpp pstack.h token.h
g++ -c pstack.cpp
clean:
rm *.o parser