1 # SPDX-License-Identifier: GPL-2.0
2 include ..
/scripts
/Makefile.
include
3 include ..
/scripts
/Makefile.arch
9 # always use the host compiler
18 srctree
:= $(patsubst %/,%,$(dir $(CURDIR
)))
19 srctree
:= $(patsubst %/,%,$(dir $(srctree
)))
22 SUBCMD_SRCDIR
= $(srctree
)/tools
/lib
/subcmd
/
23 LIBSUBCMD_OUTPUT
= $(if
$(OUTPUT
),$(OUTPUT
),$(CURDIR
)/)
24 LIBSUBCMD
= $(LIBSUBCMD_OUTPUT
)libsubcmd.a
26 OBJTOOL
:= $(OUTPUT
)objtool
27 OBJTOOL_IN
:= $(OBJTOOL
)-in.o
29 LIBELF_FLAGS
:= $(shell pkg-config libelf
--cflags 2>/dev
/null
)
30 LIBELF_LIBS
:= $(shell pkg-config libelf
--libs
2>/dev
/null || echo
-lelf
)
34 INCLUDES
:= -I
$(srctree
)/tools
/include \
35 -I
$(srctree
)/tools
/arch
/$(HOSTARCH
)/include/uapi \
36 -I
$(srctree
)/tools
/objtool
/arch
/$(ARCH
)/include
37 WARNINGS
:= $(EXTRA_WARNINGS
) -Wno-switch-default
-Wno-switch-enum
-Wno-packed
38 CFLAGS
+= -Werror
$(WARNINGS
) $(KBUILD_HOSTCFLAGS
) -g
$(INCLUDES
) $(LIBELF_FLAGS
)
39 LDFLAGS
+= $(LIBELF_LIBS
) $(LIBSUBCMD
) $(KBUILD_HOSTLDFLAGS
)
41 # Allow old libelf to be used:
42 elfshdr
:= $(shell echo
'$(pound)include <libelf.h>' |
$(CC
) $(CFLAGS
) -x c
-E
- | grep elf_getshdr
)
43 CFLAGS
+= $(if
$(elfshdr
),,-DLIBELF_USE_DEPRECATED
)
46 export srctree OUTPUT CFLAGS SRCARCH AWK
47 include $(srctree
)/tools
/build
/Makefile.
include
49 $(OBJTOOL_IN
): fixdep FORCE
50 @
$(MAKE
) $(build
)=objtool
52 $(OBJTOOL
): $(LIBSUBCMD
) $(OBJTOOL_IN
)
53 @
$(CONFIG_SHELL
) .
/sync-check.sh
54 $(QUIET_LINK
)$(CC
) $(OBJTOOL_IN
) $(LDFLAGS
) -o
$@
57 $(LIBSUBCMD
): fixdep FORCE
58 $(Q
)$(MAKE
) -C
$(SUBCMD_SRCDIR
) OUTPUT
=$(LIBSUBCMD_OUTPUT
)
61 $(call QUIET_CLEAN
, objtool
) $(RM
) $(OBJTOOL
)
62 $(Q
)find
$(OUTPUT
) -name
'*.o' -delete
-o
-name
'\.*.cmd' -delete
-o
-name
'\.*.d' -delete
63 $(Q
)$(RM
) $(OUTPUT
)arch
/x86
/lib
/inat-tables.c
$(OUTPUT
)fixdep