Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # SPDX-License-Identifier: GPL-2.0
  2. include ../scripts/Makefile.include
  3. include ../scripts/Makefile.arch
  4. ifeq ($(ARCH),x86_64)
  5. ARCH := x86
  6. endif
  7. # always use the host compiler
  8. HOSTCC ?= gcc
  9. HOSTLD ?= ld
  10. CC = $(HOSTCC)
  11. LD = $(HOSTLD)
  12. AR = ar
  13. ifeq ($(srctree),)
  14. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  15. srctree := $(patsubst %/,%,$(dir $(srctree)))
  16. endif
  17. SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
  18. LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/)
  19. LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
  20. OBJTOOL := $(OUTPUT)objtool
  21. OBJTOOL_IN := $(OBJTOOL)-in.o
  22. all: $(OBJTOOL)
  23. INCLUDES := -I$(srctree)/tools/include \
  24. -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
  25. -I$(srctree)/tools/objtool/arch/$(ARCH)/include
  26. WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
  27. CFLAGS += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
  28. LDFLAGS += -lelf $(LIBSUBCMD)
  29. # Allow old libelf to be used:
  30. elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
  31. CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
  32. AWK = awk
  33. export srctree OUTPUT CFLAGS SRCARCH AWK
  34. include $(srctree)/tools/build/Makefile.include
  35. $(OBJTOOL_IN): fixdep FORCE
  36. @$(MAKE) $(build)=objtool
  37. $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
  38. @$(CONFIG_SHELL) ./sync-check.sh
  39. $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
  40. $(LIBSUBCMD): fixdep FORCE
  41. $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT)
  42. clean:
  43. $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
  44. $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
  45. $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
  46. FORCE:
  47. .PHONY: clean FORCE