1 2 CC = g++ 3 LD = g++ 4 5 OPATH = .generated 6 BINDIR = bin 7 8 # list your binaries here 9 BINARIES = $(BINDIR)/sumArrayTBB 10 11 # don't modify this line 12 CCFLAGS = -c 13 LDFLAGS = -ltbb 14 15 # add other CFLAGS here 16 CCFLAGS += -O2 17 18 LINK_MESSAGE = "\033[32;1m\n***Making binary \033[33m%s\033[32m...\n\033[m" 19 COMPILE_MESSAGE = "\033[32;1m\n*Compiling \033[33m%s\033[32m...\n\033[m" 20 21 # list OBJFILES here for each binary 22 # for files with header dependencies, include build rule below, 23 # otherwise default build rule is sufficient 24 OBJFILES_COMMON = $(OPATH)/fatals.o 25 OBJFILES_SUMARRAY = $(OBJFILES_COMMON) \ 26 $(OPATH)/main.o 27 28 all: $(OPATH) $(BINDIR) $(BINARIES) 29 @printf "\033[34;1m\nMy work here is done.\n\033[m" 30 31 $(OPATH): 32 @printf "\033[32;1m\nMaking \033[33m$(OPATH)/ \033[32mpath for object files...\n\033[m" 33 mkdir $(OPATH) 34 35 $(BINDIR): 36 @printf "\033[32;1m\nMaking \033[33m$(BINDIR)/ \033[32mpath for binaries...\n\033[m" 37 mkdir $(BINDIR) 38 39 # binary targets are like this 40 $(BINDIR)/sumArrayTBB: $(OBJFILES_SUMARRAY) 41 @printf $(LINK_MESSAGE) "sumArrayTBB" 42 $(LD) $(LDFLAGS) $(OBJFILES_SUMARRAY) -o $@ 43 44 $(OPATH)/fatals.o: fatals.cpp fatals.h 45 @printf $(COMPILE_MESSAGE) "$<" 46 $(CC) $(CCFLAGS) $< -o $@ 47 48 $(OPATH)/main.o: main.C fatals.h 49 @printf $(COMPILE_MESSAGE) "$<" 50 $(CC) $(CCFLAGS) $< -o $@ 51 52 # default build rule 53 $(OPATH)/%.o: %.c $(OPATH) 54 @printf $(COMPILE_MESSAGE) "$<" 55 $(CC) $(CCFLAGS) $< -o $@ 56 57 almost_clean: 58 @printf "\033[34;1m\nMaking \033[31;1malmost\033[34;1m clean ... (saving binaries)\n\033[m" 59 -rm -rf core* *.o 60 -rm -rf $(OPATH) 61 62 clean: 63 @printf "\033[34;1m\nCleaning up...\n\033[m" 64 -rm -rf core* $(BINARIES) *.o 65 -rm -rf $(BINDIR) 66 -rm -rf $(OPATH) 67