# NU EECS Magic Makefile # If you put this in a directory with C++ code, then # # make -- compiles your project into program.exe # make clean -- removes compiled item # make handin -- creates a project Zip file for hand in # # All .cpp flles are included. # UnitTest++ is included. # Changes to any header file or this Makefile triggers recompilation # of all .cpp files. CC = g++ SRCS = $(wildcard *.cpp) HDRS = $(wildcard *.h) OBJS = $(SRCS:.cpp=.o) DIRS = $(subst /, ,$(CURDIR)) PROJ = $(word $(words $(DIRS)), $(DIRS)) APP = $(PROJ).exe CFLAGS = -c -g -Wall -I/usr/local/include LDFLAGS = -L/usr/local/lib/UnitTest++ LIBS = -lUnitTest++ # gcc 4 in Cygwin needs non-standard --enable-auto-import option ifneq (,$(findstring CYGWIN,$(shell uname))) LDFLAGS += -Wl,--enable-auto-import endif all: $(APP) $(APP): $(OBJS) $(CC) $(LDFLAGS) $(OBJS) -o $(APP) $(LIBS) %.o: %.cpp $(HDRS) $(MF) $(CC) $(CFLAGS) $< -o $@ clean: rm -f *.o $(APP) handin: rm -f $(PROJ).zip zip $(PROJ).zip -q Makefile *.cpp *.h unzip -l $(PROJ).zip