Pauli .
2016-10-20 11:26:35 UTC
Hello
In many cases partial build with differing flags can results to hard
to debug runtime bugs. To avoid issues when compiler flags change
build system could automatically rebuild files when flags change. But
so far automake doesn't support flag change checking
I decided to try to implement checking my self. Following
implementation seems fairly simple but I think implementation depends
on gnu make specific features. It supports only c++ and seperation of
language specific flags is missing (to recompile only C files if
CFLAGS changes).
I'm wondering if this checking could be implemented in automake. I
don't want to attempt to implement this my self because I don't have
experience writing portable makefiles.
# Add compiler flags dependency to targets
flags_verbose = $(***@AM_V@)
flags_verbose_ = $(***@AM_DEFAULT_V@)
flags_verbose_0 = @echo " CHK-FLAG $@";
flags_verbose_1 =
#Helper for variable lists
varprefix=$(foreach V,$(2),$($(1)$(V)))
FD_VARS = CPPFLAGS CXXFLAGS LDFLAGS LDADD
FD_GLOBALS = $(call varprefix,AM_,$(FD_VARS)) $(call varprefix,,$(FD_VARS))
%.flags: %.tflags
$(flags_verbose)if ! cmp -s $< $@; then cp $< $@; fi; $(RM) $<
# Generate rules and dependencies for a target
# param 1: target filename
# param 2: target variable prefix
define flagsdep_single
$(1).tflags:
@echo "$$(FD_GLOBALS) $$(call varprefix,$(2)_,$$(FD_VARS))" > $$@;
$$(am_$(2)_OBJECTS): $(1).flags
$(1): $(1).flags
endef
# Callable variable to add flag dependency to targets
flagsdep=$(foreach T,$(1),$(call flagsdep_single,$(T),$(subst
.,_,$(subst $(EXEEXT),,$(T)))))
$(eval $(call flagsdep,$(LTLIBRARIES) $(PROGRAMS) $(check_PROGRAMS)))
In many cases partial build with differing flags can results to hard
to debug runtime bugs. To avoid issues when compiler flags change
build system could automatically rebuild files when flags change. But
so far automake doesn't support flag change checking
I decided to try to implement checking my self. Following
implementation seems fairly simple but I think implementation depends
on gnu make specific features. It supports only c++ and seperation of
language specific flags is missing (to recompile only C files if
CFLAGS changes).
I'm wondering if this checking could be implemented in automake. I
don't want to attempt to implement this my self because I don't have
experience writing portable makefiles.
# Add compiler flags dependency to targets
flags_verbose = $(***@AM_V@)
flags_verbose_ = $(***@AM_DEFAULT_V@)
flags_verbose_0 = @echo " CHK-FLAG $@";
flags_verbose_1 =
#Helper for variable lists
varprefix=$(foreach V,$(2),$($(1)$(V)))
FD_VARS = CPPFLAGS CXXFLAGS LDFLAGS LDADD
FD_GLOBALS = $(call varprefix,AM_,$(FD_VARS)) $(call varprefix,,$(FD_VARS))
%.flags: %.tflags
$(flags_verbose)if ! cmp -s $< $@; then cp $< $@; fi; $(RM) $<
# Generate rules and dependencies for a target
# param 1: target filename
# param 2: target variable prefix
define flagsdep_single
$(1).tflags:
@echo "$$(FD_GLOBALS) $$(call varprefix,$(2)_,$$(FD_VARS))" > $$@;
$$(am_$(2)_OBJECTS): $(1).flags
$(1): $(1).flags
endef
# Callable variable to add flag dependency to targets
flagsdep=$(foreach T,$(1),$(call flagsdep_single,$(T),$(subst
.,_,$(subst $(EXEEXT),,$(T)))))
$(eval $(call flagsdep,$(LTLIBRARIES) $(PROGRAMS) $(check_PROGRAMS)))