Skip to content

Commit

Permalink
Makefile.rules: generate .deps/*.d files for ward output
Browse files Browse the repository at this point in the history
This keeps track of the source file for gen/foobar.c, i.e.
either src/foobar.c or hpcgap/src/foobar.c
And in the latter case, if hpcgap/src/foobar.c is deleted,
then we now automatically trigger a rebuild of gen/foobar.c

Fixes gap-system#58
  • Loading branch information
fingolfin committed Mar 3, 2017
1 parent 6f1286d commit abec016
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,15 @@ HPCGAP_SOURCES := $(addprefix gen/,$(HPCGAP_SOURCES))
# static pattern rule for sources with an HPCGAP-version
# (note that ward needs to parse the sources, hence gen/config.h must already be made)
$(HPCGAP_SOURCES): gen/%.c: hpcgap/src/%.c gen/config.h
@$(MKDIR_P) $(@D)
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
@echo "$@: $<\n$<:" > $(DEPFILE)
$(QUIET_WARD) $(ADDGUARDS2) -cpp $(CPPFLAGS) -- $< > $@

# static pattern rule for sources without an HPCGAP-version
# (note that ward needs to parse the sources, hence gen/config.h must already be made)
gen/%.c: src/%.c gen/config.h
@$(MKDIR_P) $(@D)
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
@echo "$@: $<\n$<:" > $(DEPFILE)
$(QUIET_WARD) $(ADDGUARDS2) -cpp $(CPPFLAGS) -- $< > $@

# Normally, GNU make deletes intermediate build files, such as the gen/*.c
Expand Down Expand Up @@ -291,14 +293,16 @@ DEPDIRS = $(addsuffix /$(DEPDIRNAME),obj obj/hpc gen gen/hpc)
# source files. This can save quite a bit of disk access time.
.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS)))

DEPFILE = "$(@D)/$(DEPDIRNAME)/$(*F).d"

# The following flags instruct the compiler to enable advanced
# dependency tracking. Supported by GCC 3 and newer; clang; Intel C
# compiler; and more.
#
# TODO: use configure to compute DEPFLAGS, so that we can
# disable it for compilers that don't support it, resp. replace it
# something that works for that compiler
DEPFLAGS = -MQ "$@" -MMD -MP -MF "$(@D)/$(DEPDIRNAME)/$(*F).d"
DEPFLAGS = -MQ "$@" -MMD -MP -MF $(DEPFILE)


########################################################################
Expand Down

0 comments on commit abec016

Please sign in to comment.