CXX = g++ CXXFLAGS = -O -W -Wall `vigra-config --cppflags` # define list of object files for "myprog", one .o file per .cpp file # (this defines a variable that is referenced below with "$(MYPROG_OBJECTS)") MYPROG_OBJECTS = \ main.o \ other.o # if you want to add other libraries (e.g. libfoo), look for # "foo-config" scripts or foo.pc files in the PKG_CONFIG_PATH # (try "pkg-config --list-all"). The latter can be used with # `pkg-config --cflags foo` for compiling (e.g. CXXFLAGS) and # `pkg-config --libs foo` for linking # rule for generating "myprog" myprog: $(MYPROG_OBJECTS) $(CXX) -o $@ $(MYPROG_OBJECTS) $(LDFLAGS) `vigra-config --impex-lib` # "clean" target to remove compiled files etc. (adapt this as appropriate): clean: rm -f *.o *.exe core *.plg *ilk *.lib *.pdb *.exp \ debug-output.gif rm -rf Release Debug ii_files #--------------------------------------------------------------------- # fixed rules for compiling and generating dependency files: #--------------------------------------------------------------------- # (change .cpp into .cxx, .c++, or .C if you use a different filename # extension for C++ code - just use search & replace below) %.o: %.cpp $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c "$*.cpp" %.d: %.cpp @echo updating header dependencies for $*.cpp @rm -f $*.d @(echo "$*.d \\" ; $(CXX) -M $(CXXFLAGS) $(CPPFLAGS) -c "$*.cpp" ) > $*.d \ || { rm -f $*.d; exit 1; } # if we are not in cleaning-mode, we include the dependency files # ("make" will auto-generate/update them with the above rule) ifneq "$(MAKECMDGOALS)" "clean" include $(patsubst %.o, %.d, $(MYPROG_OBJECTS)) endif