Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 2 | include ../scripts/Makefile.include |
Arnaldo Carvalho de Melo | 630e7a2 | 2016-07-22 09:59:24 -0300 | [diff] [blame] | 3 | include ../scripts/Makefile.arch |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 4 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 5 | ifeq ($(ARCH),x86_64) |
| 6 | ARCH := x86 |
| 7 | endif |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 8 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 9 | # always use the host compiler |
Nathan Chancellor | 2bfc2e3 | 2019-05-16 12:49:42 -0500 | [diff] [blame] | 10 | HOSTAR ?= ar |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 11 | HOSTCC ?= gcc |
| 12 | HOSTLD ?= ld |
Nathan Chancellor | 2bfc2e3 | 2019-05-16 12:49:42 -0500 | [diff] [blame] | 13 | AR = $(HOSTAR) |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 14 | CC = $(HOSTCC) |
| 15 | LD = $(HOSTLD) |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 16 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 17 | ifeq ($(srctree),) |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 18 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 19 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
| 20 | endif |
| 21 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 22 | SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 23 | LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/) |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 24 | LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 25 | |
| 26 | OBJTOOL := $(OUTPUT)objtool |
| 27 | OBJTOOL_IN := $(OBJTOOL)-in.o |
| 28 | |
| 29 | all: $(OBJTOOL) |
| 30 | |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 31 | INCLUDES := -I$(srctree)/tools/include \ |
| 32 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ |
| 33 | -I$(srctree)/tools/objtool/arch/$(ARCH)/include |
| 34 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed |
Josh Poimboeuf | cb40b5b | 2019-08-29 18:28:49 -0500 | [diff] [blame] | 35 | CFLAGS := -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 36 | LDFLAGS += -lelf $(LIBSUBCMD) |
| 37 | |
Jan Beulich | 2e51f26 | 2016-05-16 15:31:07 -0500 | [diff] [blame] | 38 | # Allow old libelf to be used: |
Rasmus Villemoes | b5d7d7d | 2018-04-08 23:35:28 +0200 | [diff] [blame] | 39 | elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) |
Jan Beulich | 2e51f26 | 2016-05-16 15:31:07 -0500 | [diff] [blame] | 40 | CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) |
| 41 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 42 | AWK = awk |
Josh Poimboeuf | 60cbdf5 | 2016-07-22 14:19:20 -0500 | [diff] [blame] | 43 | export srctree OUTPUT CFLAGS SRCARCH AWK |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 44 | include $(srctree)/tools/build/Makefile.include |
| 45 | |
| 46 | $(OBJTOOL_IN): fixdep FORCE |
| 47 | @$(MAKE) $(build)=objtool |
| 48 | |
| 49 | $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 50 | @$(CONFIG_SHELL) ./sync-check.sh |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 51 | $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ |
| 52 | |
| 53 | |
| 54 | $(LIBSUBCMD): fixdep FORCE |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 55 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 56 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 57 | clean: |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 58 | $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) |
| 59 | $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete |
Greg Kroah-Hartman | b790b4f | 2018-06-03 12:35:15 +0200 | [diff] [blame] | 60 | $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 61 | |
| 62 | FORCE: |
| 63 | |
| 64 | .PHONY: clean FORCE |