automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Automatic recompile when flags change


From: Pauli .
Subject: Automatic recompile when flags change
Date: Thu, 20 Oct 2016 14:26:35 +0300

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 = $(address@hidden@)
flags_verbose_ = $(address@hidden@)
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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]