Makefile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # SPDX-License-Identifier: GPL-2.0
  2. ifeq ($(srctree),)
  3. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  4. srctree := $(patsubst %/,%,$(dir $(srctree)))
  5. endif
  6. include $(srctree)/tools//scripts/Makefile.include
  7. define allow-override
  8. $(if $(or $(findstring environment,$(origin $(1))),\
  9. $(findstring command line,$(origin $(1)))),,\
  10. $(eval $(1) = $(2)))
  11. endef
  12. $(call allow-override,CC,$(CROSS_COMPILE)gcc)
  13. $(call allow-override,LD,$(CROSS_COMPILE)ld)
  14. export HOSTCC HOSTLD HOSTAR
  15. export srctree CC LD
  16. MAKEFLAGS := --no-print-directory
  17. build := -f $(srctree)/tools/build/Makefile.build dir=. obj
  18. all: $(OUTPUT)fixdep
  19. # Make sure there's anything to clean,
  20. # feature contains check for existing OUTPUT
  21. TMP_O := $(if $(OUTPUT),$(OUTPUT)feature/,./)
  22. clean:
  23. $(call QUIET_CLEAN, fixdep)
  24. $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
  25. $(Q)rm -f $(OUTPUT)fixdep
  26. $(call QUIET_CLEAN, feature-detect)
  27. ifneq ($(wildcard $(TMP_O)),)
  28. $(Q)$(MAKE) -C feature OUTPUT=$(TMP_O) clean >/dev/null
  29. endif
  30. FIXDEP := $(OUTPUT)fixdep
  31. FIXDEP_IN := $(OUTPUT)fixdep-in.o
  32. # To track fixdep's dependencies properly, fixdep needs to run on itself.
  33. # Build it twice the first time.
  34. $(FIXDEP_IN): FORCE
  35. $(Q)if [ ! -f $(FIXDEP) ]; then \
  36. $(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)"; \
  37. rm -f $(FIXDEP).o; \
  38. fi
  39. $(Q)$(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)"
  40. $(FIXDEP): $(FIXDEP_IN)
  41. $(QUIET_LINK)$(HOSTCC) $(FIXDEP_IN) $(KBUILD_HOSTLDFLAGS) -o $@
  42. FORCE:
  43. .PHONY: FORCE