07-04-04 10:52 PM
How can I separate the src/ from the obj/ tree, using make? It looks
chaotic when my src folder is full of .o files.
The tricky thing is I have src files with the same name, just in
different subdirectories:
src/main.cpp
src/bmw/car.cpp
src/mercedes/car.cpp
Now, (GNU) make should place the obj files into obj, preserving the
directory structure:
obj/main.o
obj/bmw/car.o
obj/mercedes/car.o
This should be the most natural thing in the world for make to do. But
it seems it's tricky...?
Markus
Here is my stupid Makefile that just puts the o files next to the src
files:
SRC=src
OBJ=obj
FILES=main bmw/car mercedes/car
OFILES=$(FILES:%=$(SRC)/%.o)
TARGET=cars
all: $(TARGET)
$(TARGET): $(OFILES)
g++ $(OFILES) -o $@
%.o: %.cpp
g++ -I$(SRC) -c -o $@ $<
[ Post a follow-up to this message ]
|