Single-pass dependency generation

This commit is contained in:
Christophe de Dinechin 2017-05-01 17:06:28 +02:00
parent 4dad7dfda9
commit 28c8dda7c6
3 changed files with 14 additions and 23 deletions

View File

@ -46,7 +46,7 @@ CFLAGS_profile= -pg
CFLAGS_cxx= -x c++
LDFLAGS_debug= -g
LDFLAGS_profile=-pg
DEPFLAGS= -MD -MP -MF $(@).d -MT $@
#------------------------------------------------------------------------------
# File extensions
@ -62,8 +62,9 @@ DLL_EXT= .so
# Build rules
#------------------------------------------------------------------------------
MAKE_CC= $(CC) $(CFLAGS) $(CPPFLAGS_$*) $(CFLAGS_$*) -c $< -o $@
MAKE_CXX= $(CXX) $(CXXFLAGS) $(CPPFLAGS_$*) $(CXXFLAGS_$*) -c $< -o $@
MAKE_CC= $(CC) $(CFLAGS) $(CPPFLAGS_$*) $(CFLAGS_$*) -c $< -o $@ $(DEPFLAGS)
MAKE_CXX= $(CXX) $(CXXFLAGS) $(CPPFLAGS_$*) $(CXXFLAGS_$*) -c $< -o $@ $(DEPFLAGS)
MAKE_AS= $(CC) $(CFLAGS) $(CPPFLAGS_$*) $(CFLAGS_$*) -c $< -o $@ $(DEPFLAGS)
MAKE_OBJDIR= mkdir -p $* && touch $@
MAKE_LIB= $(AR) $@ $(LINK_INPUTS)&& $(RANLIB) $@
MAKE_DLL= $(LIBTOOL) -shared $(LINK_INPUTS) -o $@
@ -74,6 +75,6 @@ MAKE_EXE= $(LD) -o $@ $(LINK_INPUTS) $(LDFLAGS) $(LDFLAGS_$*)
# Dependencies
#------------------------------------------------------------------------------
CC_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MF $@ -MT $(@:.d=) $<
CXX_DEPEND= $(CXX) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MF $@ -MT $(@:.d=) $<
AS_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MF $@ -MT $(@:.d=) $<
CC_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<
CXX_DEPEND= $(CXX) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<
AS_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<

View File

@ -28,11 +28,6 @@ OS_NAME_mingw=windows
include $(BUILD)config.gnu.mk
# We need a special treatment of this on Windows
POSTPROCESS_DEPENDENCY= \
( sed -e 's/.*://' -e 's/\\$$//' < $@ | \
sed -e 's/^ *//' -e 's/$$/:/' -e 's/\\\\:$$/:/' >> $@ )
# MinGW does not have --line-buffered for colorized builds
LINE_BUFFERED=

View File

@ -314,21 +314,16 @@ OBJDIR_DEPS=$(OBJDIR)/%.deps/.mkdir
OBJ_DEPS=$(OBJDIR_DEPS) $(MAKEFILE_DEPS) | hello prebuild
# The following is a trick to avoid errors if a header file appears in a
# generated dependency but no longer in the source code.
# The trick is quite ugly, but fortunately documented here:
# http://scottmcpeak.com/autodepend/autodepend.html
POSTPROCESS_DEPENDENCY?= \
( sed -e 's/.*://' -e 's/\\$$//' < $@ | \
fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $@ )
ifndef DEPFLAGS
$(OBJDIR)/%.c$(OBJ_EXT).d: %.c $(OBJ_DEPS)
$(PRINT_DEPEND) ( $(CC_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(PRINT_DEPEND) ( $(CC_DEPEND)
$(OBJDIR)/%.cpp$(OBJ_EXT).d: %.cpp $(OBJ_DEPS)
$(PRINT_DEPEND) ( $(CXX_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(PRINT_DEPEND) ( $(CXX_DEPEND)
$(OBJDIR)/%.s$(OBJ_EXT).d: %.s $(OBJ_DEPS)
$(PRINT_DEPEND) ( $(AS_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(PRINT_DEPEND) ( $(AS_DEPEND)
else
$(OBJDIR)/%$(OBJ_EXT).d: $(OBJDIR)/%$(OBJ_EXT)
endif
#------------------------------------------------------------------------------