I’ve been working on a makefile that uses secondary expansion not knowing that this feature only exists since version 3.81 of GNU make. Unfortunately, there are some old machines around here that only have make 3.79.1 installed and on these machines, the makefile doesn’t work, of course. Is there an alternative to secondary expansion?
The rule for a C++ program where I use it looks like the following:
.SECONDEXPANSION:
# Pattern rule for linking
%_$(SYSTEM) : $$(%_ofiles) $(EXEC)/%_$(SYSTEM).o
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
# Example for an ofiles variable
prog1_ofiles = $(C1) $(C2)
C1 = $(OFILES)/C1.o
C2 = $(OFILES)/C2.o
I know – the best solution would be to install a current make version. But our system administrator was not enthusiastic about it 😉 So I’m looking forward to your suggestions.
Btw, does anyone know where to get the documentation of GNU make 3.79.1 – I couldn’t find it anywhere.
Just add
make-3.81sources in your source tree. Your main Makefile first should compilemake-3.81using whatever make is available and then usemake-3.81for compiling everything else.