# makefile for package1 and package2 CFLAGS = $(INCDIRS) \ -ansi -pedantic -g \ -Wall -Wconversion\ -Wformat -Wshadow\ -Wpointer-arith -Wcast-qual -Wwrite-strings\ -D__USE_FIXED_PROTOTYPES__ LIBS = -l stdc++ -lm CXX = g++ .PHONY: clean clean: rm *.o # These lines define what package1 depends on, and how to make it package1: package1.o tinyutils.o $(CXX) $(CFLAGS) $(LIBS) package1.o tinyutils.o -o package1 package2: package2.o tinyutils2.o $(CXX) $(CFLAGS) $(LIBS) package2.o tinyutils2.o -o package2 # The following g++ commands are redundant. It would be # perfectly normal to have just one or the other -- not both. # I have both because I like to compile first with the optimizer # flag on (as this helps the compiler catch more interesting warnings), # then a second time with the optimizer off (as this makes a program # that displays best in the debugger, kdbg). %.o: %.cc $(CXX) -O2 $(CFLAGS) $< -c -o $@ $(CXX) $(CFLAGS) $< -c -o $@ %: %.cc makefile $(CXX) -O2 $(CFLAGS) $(LIBS) $< -o $@ $(CXX) $(CFLAGS) $(LIBS) $< -o $@