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