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 | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 5 | # always use the host compiler |
Nathan Chancellor | 8ea58f1 | 2019-05-16 12:49:42 -0500 | [diff] [blame] | 6 | AR = $(HOSTAR) |
Mikulas Patocka | 14c47b54 | 2017-12-02 16:17:44 -0600 | [diff] [blame] | 7 | CC = $(HOSTCC) |
| 8 | LD = $(HOSTLD) |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 9 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 10 | ifeq ($(srctree),) |
Uwe Kleine-König | e19b7ce | 2016-11-22 09:30:26 +0100 | [diff] [blame] | 11 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 12 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
| 13 | endif |
| 14 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 15 | SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ |
Uwe Kleine-König | e19b7ce | 2016-11-22 09:30:26 +0100 | [diff] [blame] | 16 | LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/) |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 17 | LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 18 | |
| 19 | OBJTOOL := $(OUTPUT)objtool |
| 20 | OBJTOOL_IN := $(OBJTOOL)-in.o |
| 21 | |
Rolf Eike Beer | 056d28d | 2019-03-26 12:48:39 -0500 | [diff] [blame] | 22 | LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null) |
| 23 | LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) |
| 24 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 25 | all: $(OBJTOOL) |
| 26 | |
Josh Poimboeuf | 6a77cff | 2017-11-06 07:21:50 -0600 | [diff] [blame] | 27 | INCLUDES := -I$(srctree)/tools/include \ |
| 28 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ |
Julien Thierry | 6f8ca67 | 2020-03-27 15:28:46 +0000 | [diff] [blame] | 29 | -I$(srctree)/tools/arch/$(SRCARCH)/include \ |
Vasily Gorbik | 7786032 | 2020-11-13 00:03:32 +0100 | [diff] [blame] | 30 | -I$(srctree)/tools/objtool/include \ |
Julien Thierry | 6f8ca67 | 2020-03-27 15:28:46 +0000 | [diff] [blame] | 31 | -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include |
Vasily Gorbik | 2486baa | 2020-10-05 17:50:28 +0200 | [diff] [blame] | 32 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs |
Josh Poimboeuf | f73b3cc | 2019-08-29 18:28:49 -0500 | [diff] [blame] | 33 | CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) |
Rolf Eike Beer | 056d28d | 2019-03-26 12:48:39 -0500 | [diff] [blame] | 34 | LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 35 | |
Jan Beulich | 2e51f26 | 2016-05-16 15:31:07 -0500 | [diff] [blame] | 36 | # Allow old libelf to be used: |
Rasmus Villemoes | 9564a8c | 2018-04-08 23:35:28 +0200 | [diff] [blame] | 37 | 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] | 38 | CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) |
| 39 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 40 | AWK = awk |
Matt Helsley | 0decf1f | 2020-05-19 13:55:33 -0700 | [diff] [blame] | 41 | |
| 42 | SUBCMD_CHECK := n |
| 43 | SUBCMD_ORC := n |
| 44 | |
| 45 | ifeq ($(SRCARCH),x86) |
| 46 | SUBCMD_CHECK := y |
| 47 | SUBCMD_ORC := y |
| 48 | endif |
| 49 | |
| 50 | export SUBCMD_CHECK SUBCMD_ORC |
Josh Poimboeuf | 60cbdf5 | 2016-07-22 14:19:20 -0500 | [diff] [blame] | 51 | export srctree OUTPUT CFLAGS SRCARCH AWK |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 52 | include $(srctree)/tools/build/Makefile.include |
| 53 | |
| 54 | $(OBJTOOL_IN): fixdep FORCE |
Julien Thierry | aa58472 | 2020-03-27 15:28:38 +0000 | [diff] [blame] | 55 | @$(CONFIG_SHELL) ./sync-check.sh |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 56 | @$(MAKE) $(build)=objtool |
| 57 | |
| 58 | $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 59 | $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ |
| 60 | |
| 61 | |
| 62 | $(LIBSUBCMD): fixdep FORCE |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 63 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 64 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 65 | clean: |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 66 | $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) |
| 67 | $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete |
Josh Poimboeuf | d046b72 | 2019-08-29 17:41:18 -0500 | [diff] [blame] | 68 | $(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 69 | |
| 70 | FORCE: |
| 71 | |
| 72 | .PHONY: clean FORCE |