tags:

views:

72

answers:

1

I use GNU make, I want my source files and object files to be in different folders.

As a first step, I want the source files at the root of my project folder, and the object files in a subfolder (say Debug/).

The inference rule would be:

.ss.obj:
    echo Assembling $*.ss...
    $(ASSEMBLY) $(2210_ASSEMBLY_FLAGS) $*.ss -o Debug\$*.obj 

but in that case, make rebuilds all files all the time, since there are no .obj in the root folder.

Is there a way to include a folder for the target in the line .ss.obj?

I also tried:

$(OBJS_WITH_PATH):$(SRC)    
    echo Assembling $<...
    $(ASSEMBLY) $(ASSEMBLY_FLAGS) $< -o $@ 

with $(SRC) as a list of all my sources, $(OBJS_WITH_PATH) built that way:

OBJS_WITH_PATH = $(patsubst %.ss,Debug\\%.obj,$(SRC))

but that builds a dependency on all source files for all object files.

What I would like is to modify the inference rule I wrote first, to take Debug/*.obj files. What it says now is no rule to make target Debug/asdfasdf.obj.

+2  A: 

Use pattern rules:

Debug/%.obj : %.ss
Marcelo Cantos
Great, it worked fine. Thanks!
Gauthier