Makefile: fix parallel building
This changes the default rules for ar archives to work correctly under parallel buildings in GNU make ≥4.4.1. Incidentally, this also fixes the entire build being sequential for GNU make <4.4 due to .NOTPARALLEL not supporting prerequisites. For older versions, timestamps of archive members are not handled correctly, but that's a relatively minor issue.
This commit is contained in:
parent
09724908d1
commit
b673c5889e
12
Makefile
12
Makefile
@ -203,11 +203,7 @@ $(LIBDIR)/libgray.so: $(MODULES) | $(LIBDIR)
|
||||
$(LD) -shared $(LDFLAGS) -o '$@' $^
|
||||
|
||||
# GRAY static library
|
||||
$(LIBDIR)/libgray.a($(MODULES)): | $(LIBDIR)
|
||||
$(LIBDIR)/libgray.a: $(LIBDIR)/libgray.a($(MODULES))
|
||||
|
||||
# Don't update archives in parallel, it's unsupported
|
||||
.NOTPARALLEL: $(LIBDIR)/libgray.a
|
||||
$(LIBDIR)/libgray.a: $(LIBDIR)/libgray.a($(MODULES)) | $(LIBDIR)
|
||||
|
||||
# GRAY static library when compiling from JETTO
|
||||
-include ../include.mk
|
||||
@ -270,6 +266,12 @@ $(OBJDIR)/%.d: %.f90 | $(OBJDIR)
|
||||
sort -u >> '$@'
|
||||
@sed -nE 's@^#include "(.+)"@$(INCDIR)/\1 \\@p' '$<' >> '$@'
|
||||
|
||||
# Accumulate members and update archives all at once
|
||||
# Note: this replaces the default POSIX rules that
|
||||
# break under parallel building (make -j)
|
||||
(%) : % ;
|
||||
%.a : ; $(AR) $(ARFLAGS) $@ $?
|
||||
|
||||
# Load the generated rules
|
||||
include $(DEPS)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user