Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [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 |
Mikulas Patocka | 14c47b54 | 2017-12-02 16:17:44 -0600 | [diff] [blame^] | 10 | HOSTCC ?= gcc |
| 11 | HOSTLD ?= ld |
| 12 | CC = $(HOSTCC) |
| 13 | LD = $(HOSTLD) |
| 14 | AR = ar |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 15 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 16 | ifeq ($(srctree),) |
Uwe Kleine-König | e19b7ce | 2016-11-22 09:30:26 +0100 | [diff] [blame] | 17 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 18 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
| 19 | endif |
| 20 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 21 | SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ |
Uwe Kleine-König | e19b7ce | 2016-11-22 09:30:26 +0100 | [diff] [blame] | 22 | LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/) |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 23 | LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 24 | |
| 25 | OBJTOOL := $(OUTPUT)objtool |
| 26 | OBJTOOL_IN := $(OBJTOOL)-in.o |
| 27 | |
| 28 | all: $(OBJTOOL) |
| 29 | |
Josh Poimboeuf | 6a77cff | 2017-11-06 07:21:50 -0600 | [diff] [blame] | 30 | INCLUDES := -I$(srctree)/tools/include \ |
| 31 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ |
Josh Poimboeuf | 9eb7198 | 2017-11-07 21:01:52 -0600 | [diff] [blame] | 32 | -I$(srctree)/tools/objtool/arch/$(ARCH)/include |
Josh Poimboeuf | 21ec3bf | 2017-07-27 15:56:56 -0500 | [diff] [blame] | 33 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed |
| 34 | CFLAGS += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 35 | LDFLAGS += -lelf $(LIBSUBCMD) |
| 36 | |
Jan Beulich | 2e51f26 | 2016-05-16 15:31:07 -0500 | [diff] [blame] | 37 | # Allow old libelf to be used: |
| 38 | elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) |
| 39 | CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) |
| 40 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 41 | AWK = awk |
Josh Poimboeuf | 60cbdf5 | 2016-07-22 14:19:20 -0500 | [diff] [blame] | 42 | export srctree OUTPUT CFLAGS SRCARCH AWK |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 43 | include $(srctree)/tools/build/Makefile.include |
| 44 | |
| 45 | $(OBJTOOL_IN): fixdep FORCE |
| 46 | @$(MAKE) $(build)=objtool |
| 47 | |
| 48 | $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) |
Josh Poimboeuf | 3bd51c5 | 2017-11-06 07:21:51 -0600 | [diff] [blame] | 49 | @./sync-check.sh |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 50 | $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ |
| 51 | |
| 52 | |
| 53 | $(LIBSUBCMD): fixdep FORCE |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 54 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 55 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 56 | clean: |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 57 | $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) |
| 58 | $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete |
Josh Poimboeuf | 6a77cff | 2017-11-06 07:21:50 -0600 | [diff] [blame] | 59 | $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 60 | |
| 61 | FORCE: |
| 62 | |
| 63 | .PHONY: clean FORCE |