Makefile 1.6 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2
include ../scripts/Makefile.include
3
include ../scripts/Makefile.arch
4 5 6 7 8

ifeq ($(ARCH),x86_64)
ARCH := x86
endif

J
Josh Poimboeuf 已提交
9 10 11 12 13
# always use the host compiler
CC = gcc
LD = ld
AR = ar

14
ifeq ($(srctree),)
15
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
16 17 18
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

J
Josh Poimboeuf 已提交
19
SUBCMD_SRCDIR		= $(srctree)/tools/lib/subcmd/
20
LIBSUBCMD_OUTPUT	= $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/)
J
Josh Poimboeuf 已提交
21
LIBSUBCMD		= $(LIBSUBCMD_OUTPUT)libsubcmd.a
22 23 24 25 26 27

OBJTOOL    := $(OUTPUT)objtool
OBJTOOL_IN := $(OBJTOOL)-in.o

all: $(OBJTOOL)

28 29 30
INCLUDES := -I$(srctree)/tools/include \
	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
	    -I$(srctree)/tools/objtool/arch/$(HOSTARCH)/include
31 32
WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
CFLAGS   += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
33 34
LDFLAGS  += -lelf $(LIBSUBCMD)

35 36 37 38
# Allow old libelf to be used:
elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)

39
AWK = awk
40
export srctree OUTPUT CFLAGS SRCARCH AWK
41 42 43 44 45 46
include $(srctree)/tools/build/Makefile.include

$(OBJTOOL_IN): fixdep FORCE
	@$(MAKE) $(build)=objtool

$(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
47
	@./sync-check.sh
48 49 50 51
	$(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@


$(LIBSUBCMD): fixdep FORCE
J
Josh Poimboeuf 已提交
52
	$(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT)
53

J
Josh Poimboeuf 已提交
54
clean:
55 56
	$(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
	$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
57
	$(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
58 59 60 61

FORCE:

.PHONY: clean FORCE