#Implicite Pattern Rule for Library Members changed in order to use # -I include option DEFAULT=libutil.a LIB = libutil.a CC :=g++ CPPFLAG += -I. source := $(wildcard *.cc) object := $(source:.cc=.o) mkfiles := $(source:.cc=.d) tutorials := harray-tutorial.o hstring-tutorial.o hnamedlist-tutorial.o hvector-tutorial.o objects =$(filter-out $(tutorials), $(object)) # Include a dependency Makefile *.d for each cc-file, containing the # the included header files. # This makefile is updated, whenever one of the included header files # is changed by the pattern rule (%d: %.cc) below. # If it doesn't exist, it will be created. include $(source:.cc=.d) %.d: %.cc @$(SHELL) -ec '$(CC) -M $(CPPFLAG) \ $< |sed '\''s/$*.o/& $@/g'\'' > $@ @echo creating Makefile $*.d @echo $(LIBDIR) (%.o): %.cc %.d $(CC) $(CPPFLAG) -c $< -o $% $(AR) rv $@ $% $(RM) $% ranlib $(LIB) %.o: %.cc %.d $(CC) $(CPPFLAGS) -c $< -o $@ $(LIB): $(LIB)($(objects)) @echo " " harray-tutorial: harray-tutorial.o $(LIB)($(objects)) $(mkfiles) $(CC) -o harray-tutorial harray-tutorial.o -L. -lutil hstring-tutorial: hstring-tutorial.o $(LIB)($(objects)) $(mkfiles) $(CC) -o hstring-tutorial hstring-tutorial.o -L. -lutil hnamedlist-tutorial: hnamedlist-tutorial.o $(LIB)($(objects)) $(mkfiles) $(CC) -o hnamedlist-tutorial hnamedlist-tutorial.o -L. lutil hvector-tutorial: hvector-tutorial.o $(LIB)($(objects)) $(mkfiles) $(CC) -o hvector-tutorial hvector-tutorial.o -L. -lutil CLEAN: rm *.bak rm *~ rm *.h rm *.cc rm *.d rm *.o