I'm trying to write a simple make file that automatically finds all C++ source files, compiles a corresponding object file and puts it in directory "build" and then links the resulting binary. But I don't know how to put the object files in directory "build" - they always end up in the same directory as the source files.
Here is my make file: # ============ # Variables # ============ PROGRAM = program.bin CXX = c++ SOURCES = $(shell ls src/*.cpp) OBJECTS = $(SOURCES:.cpp=.o) INCS = -Iinclude -Igfx LIBS = -L/app/glib/1.2.10/lib -L/app/gtk+/1.2.10/lib # ============ # Targets # ============ $(PROGRAM): $(OBJECTS) $(CXX) -o $(PROGRAM) $(OBJECTS) $(LIBS) %.o : %.cpp $(CXX) -c $(INCS) -o $@ $< clean: \rm src/*.o $(PROGRAM) I suppose I have to move the object file at the end of target "%.o" to the "build" directory, but I don't know how. _______________________________________________ help-gnu-utils mailing list help-gnu-utils@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-utils