Reputation: 4146
Say I have the following GNU make targets:
create_dir:
@mkdir objects
build_asm: $(ASM_FILES)
@echo building assembly files...
build_c: $(C_FILES)
@echo building c files...
I have a generic rule for creation of object files from .asm or .c files. I want to combine these into a single target as follows...
all: create_dir build_asm build_c
@echo build complete
...and I want to build this target using the jobs using multiple jobs to increase performance. The *.c and *.s files should be placed in the directory created by build_c, so allowing make to execute them in any order is problematic.
Is there a way to force make to resolve the phony target create_dir before resolving build_c and build_asm without breaking up the target?
Upvotes: 2
Views: 1325
Reputation: 539685
Creating an objects directory is a typical use case of "order-only-prerequisites" (see Types of Prerequisites in the GNU make manual):
create_dir:
@mkdir objects
build_asm: $(ASM_FILES) | create_dir
@echo building assembly files...
build_c: $(C_FILES) | create_dir
@echo building c files...
all: build_asm build_c
@echo build complete
Upvotes: 3