From: Danuvius <dan...@gm...> - 2012-05-26 14:22:40
|
Greetings! I have a bit of a makefile issue which I've failed not only to solve but even to understand. The below seems to work fine (pairing the proper .cpp file with the corresponding .o file) when I don't do the monkeying around to get the .o files to end up in a separate output directory. But once the output directory is prefixed to the .o files, every object files is compiled by taking the first file (main.cpp) as the source... which, obviously leads to nothing workable. I searched google and attempted to make sense of autovariables via the makefile documentation... but still don't understand why the observed outcome is happening. However I have a nagging suspicion that this is one of those situation that may be solved by changing a single character, or, at most, a few on a single line. I'd be grateful for any assistance, or even suggestions pointing me in new directions toward figuring it out on my own. Thank you in advance! -- Danuvius ----- CC=g++ INDIR=./src OUTDIR=./bin INCLUDES=-I./sfml-1.6/include -I./lua-5.2.0/src LINCLUDES=-L./sfml-1.6/lib -L./lua-5.2.0/src LIBRARIES=-lsfml-graphics-s -lsfml-window-s -lsfml-system-s -llua52 CFLAGS=-c $(INCLUDES) -Wall -O3 -o $(OUTDIR) LFLAGS=-static-libgcc -static-libstdc++ $(LINCLUDES) $(LIBRARIES) TSOURCES=main.cpp Logger.cpp TOBJECTS=$(TSOURCES:.cpp=.o) SOURCES=$(addprefix $(INDIR)/,$(TSOURCES)) OBJECTS=$(addprefix $(OUTDIR)/,$(TOBJECTS)) EXECUTABLE=$(OUTDIR)/vilag all: $(SOURCES) $(EXECUTABLE) run: $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LFLAGS) $(OBJECTS) -o $@ $(OBJECTS): $(SOURCES) $(CC) $(CFLAGS) $< -o $@ clean: rm -rf $(OUTDIR)/*.o ----- |