Commit a808a2b3 authored by Josh Poimboeuf's avatar Josh Poimboeuf
Browse files

tools build: Fix fixdep dependencies



The tools version of fixdep has broken dependencies.  It doesn't get
rebuilt if the host compiler or headers change.

Build fixdep with the tools kbuild infrastructure, so fixdep runs on
itself.  Due to the recursive dependency, its dependency file is
incomplete the very first time it gets built.  In that case build it a
second time to achieve fixdep inception.

Reported-by: default avatarArthur Marsh <arthur.marsh@internode.on.net>
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
parent 2e985fdb
Loading
Loading
Loading
Loading

tools/build/Build

0 → 100644
+2 −0
Original line number Diff line number Diff line
hostprogs	:= fixdep
fixdep-y	:= fixdep.o
+21 −2
Original line number Diff line number Diff line
@@ -37,5 +37,24 @@ ifneq ($(wildcard $(TMP_O)),)
	$(Q)$(MAKE) -C feature OUTPUT=$(TMP_O) clean >/dev/null
endif

$(OUTPUT)fixdep: $(srctree)/tools/build/fixdep.c
	$(QUIET_CC)$(HOSTCC) $(KBUILD_HOSTCFLAGS) $(KBUILD_HOSTLDFLAGS) -o $@ $<
include $(srctree)/tools/build/Makefile.include

FIXDEP		:= $(OUTPUT)fixdep
FIXDEP_IN	:= $(OUTPUT)fixdep-in.o

# To track fixdep's dependencies properly, fixdep needs to run on itself.
# Build it twice the first time.
$(FIXDEP_IN): FORCE
	$(Q)if [ ! -f $(FIXDEP) ]; then						\
		$(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)";	\
		rm -f $(FIXDEP).o;						\
	fi
	$(Q)$(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)"


$(FIXDEP): $(FIXDEP_IN)
	$(QUIET_LINK)$(HOSTCC) $(FIXDEP_IN) $(KBUILD_HOSTLDFLAGS) -o $@

FORCE:

.PHONY: FORCE