LDFLAGS := -lnlopt c_sources := poiss.c arg_parser.c parse_csv.c % : %.c # cancel built-in one-step rule %.o : %.c g++ -g -O2 -Wall $< -c % : %.o g++ $^ $(LDFLAGS) -o $@ .PHONY : all ## dependency-finding scheme (with local mods) based on: ## http://www.gnu.org/manual/make-3.77/html_mono/make.html#SEC42 ## (requires an include statement at end of the makefile) %.d: %.c @$(SHELL) -ec '$(CXX) -MM $(CXXFLAGS) $< \ | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ [ -s $@ ] || rm -f $@' ################ end of pattern rules, start of real rules all : poiss poiss : poiss.o arg_parser.o parse_csv.o g++ $^ $(LDFLAGS) -o $@ ifndef NO_DOT_D include $(c_sources:.c=.d) endif