Reputation: 19333
I have a 500+ line Makefile that is used to handle various automated builds. In its current state, it specifies a few rules, and depends on an argument being passed to make
to determine which architecture to build for, ie:
all: release_build clean_all debug_build clean_all
So, on my build server, for example, I can generate tarballs of my project for multiple architectures like so:
make all ARCH=armhf
make all ARCH=x86
make all ARCH=x64
I'm attempting to parallelize builds to speed up how quickly the build server can give me the output of these builds, since CPU and IO-wise, it's underutilized. However, this leads to havok, as all the architectures use the same naming scheme for intermediate object files.
Is there a simple way to have my builds generate an intermediate folder like .obj/${RELEASE_TYPE}/
to store the intermediate files? This would let me run debug and release builds in parallel
Thank you.
Upvotes: 0
Views: 121
Reputation: 99104
This doesn't sound difficult. (I could have sworn there was already a question like this...)
OBJECTS := foo.o bar.o
OBJDIR := ./.obj/$(ARCH)
all: release_build debug_build
RELEASEOBJECTS := $(addprefix $(OBJDIR)/release/, $(OBJECTS))
release_build: $(RELEASEOBJECTS)
do something with $^ to produce $@
DEBUGOBJECTS := $(addprefix $(OBJDIR)/debug/, $(OBJECTS))
debug_build: $(DEBUGOBJECTS)
do something with $^ to produce $@
With some further trickery you could have one rule for both builds, but it would be quite cryptic.
Upvotes: 2