1 # SPDX-License-Identifier: GPL-2.0
2 include ..
/scripts
/Makefile.
include
3 include ..
/scripts
/Makefile.arch
9 # always use the host compiler
15 srctree
:= $(patsubst %/,%,$(dir $(CURDIR
)))
16 srctree
:= $(patsubst %/,%,$(dir $(srctree
)))
19 SUBCMD_SRCDIR
= $(srctree
)/tools
/lib
/subcmd
/
20 LIBSUBCMD_OUTPUT
= $(if
$(OUTPUT
),$(OUTPUT
),$(CURDIR
)/)
21 LIBSUBCMD
= $(LIBSUBCMD_OUTPUT
)libsubcmd.a
23 OBJTOOL
:= $(OUTPUT
)objtool
24 OBJTOOL_IN
:= $(OBJTOOL
)-in.o
28 INCLUDES
:= -I
$(srctree
)/tools
/include \
29 -I
$(srctree
)/tools
/arch
/$(HOSTARCH
)/include/uapi \
30 -I
$(srctree
)/tools
/objtool
/arch
/$(HOSTARCH
)/include
31 WARNINGS
:= $(EXTRA_WARNINGS
) -Wno-switch-default
-Wno-switch-enum
-Wno-packed
32 CFLAGS
+= -Wall
-Werror
$(WARNINGS
) -fomit-frame-pointer
-O2
-g
$(INCLUDES
)
33 LDFLAGS
+= -lelf
$(LIBSUBCMD
)
35 # Allow old libelf to be used:
36 elfshdr
:= $(shell echo
'\#include <libelf.h>' |
$(CC
) $(CFLAGS
) -x c
-E
- | grep elf_getshdr
)
37 CFLAGS
+= $(if
$(elfshdr
),,-DLIBELF_USE_DEPRECATED
)
40 export srctree OUTPUT CFLAGS SRCARCH AWK
41 include $(srctree
)/tools
/build
/Makefile.
include
43 $(OBJTOOL_IN
): fixdep FORCE
44 @
$(MAKE
) $(build
)=objtool
46 # Busybox's diff doesn't have -I, avoid warning in that case
48 $(OBJTOOL
): $(LIBSUBCMD
) $(OBJTOOL_IN
)
49 @
(diff
-I
2>&1 | grep
-q
'option requires an argument' && \
50 test -d ..
/..
/kernel
-a
-d ..
/..
/tools
-a
-d ..
/objtool
&& (( \
51 diff arch
/x86
/lib
/insn.c ..
/..
/arch
/x86
/lib
/insn.c
>/dev
/null
&& \
52 diff arch
/x86
/lib
/inat.c ..
/..
/arch
/x86
/lib
/inat.c
>/dev
/null
&& \
53 diff arch
/x86
/lib
/x86-opcode-map.txt ..
/..
/arch
/x86
/lib
/x86-opcode-map.txt
>/dev
/null
&& \
54 diff arch
/x86
/tools
/gen-insn-attr-x86.awk ..
/..
/arch
/x86
/tools
/gen-insn-attr-x86.awk
>/dev
/null
&& \
55 diff arch
/x86
/include/asm
/insn.h ..
/..
/arch
/x86
/include/asm
/insn.h
>/dev
/null
&& \
56 diff arch
/x86
/include/asm
/inat.h ..
/..
/arch
/x86
/include/asm
/inat.h
>/dev
/null
&& \
57 diff arch
/x86
/include/asm
/inat_types.h ..
/..
/arch
/x86
/include/asm
/inat_types.h
>/dev
/null
) \
58 || echo
"warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true
59 @
(test -d ..
/..
/kernel
-a
-d ..
/..
/tools
-a
-d ..
/objtool
&& (( \
60 diff ..
/..
/arch
/x86
/include/asm
/orc_types.h arch
/x86
/include/asm
/orc_types.h
>/dev
/null
) \
61 || echo
"warning: objtool: orc_types.h differs from kernel" >&2 )) || true
62 $(QUIET_LINK
)$(CC
) $(OBJTOOL_IN
) $(LDFLAGS
) -o
$@
65 $(LIBSUBCMD
): fixdep FORCE
66 $(Q
)$(MAKE
) -C
$(SUBCMD_SRCDIR
) OUTPUT
=$(LIBSUBCMD_OUTPUT
)
69 $(call QUIET_CLEAN
, objtool
) $(RM
) $(OBJTOOL
)
70 $(Q
)find
$(OUTPUT
) -name
'*.o' -delete
-o
-name
'\.*.cmd' -delete
-o
-name
'\.*.d' -delete
71 $(Q
)$(RM
) $(OUTPUT
)arch
/x86
/lib
/inat-tables.c
$(OUTPUT
)fixdep