xref: /linux/scripts/Makefile.vmlinux_a (revision 9c72d26e9fe3be79dd1d8a2ba00a033503ffd27d)
1*9c72d26eSMasahiro Yamada# SPDX-License-Identifier: GPL-2.0-only
2*9c72d26eSMasahiro Yamada
3*9c72d26eSMasahiro YamadaPHONY := __default
4*9c72d26eSMasahiro Yamada__default: vmlinux.a
5*9c72d26eSMasahiro Yamada
6*9c72d26eSMasahiro Yamadainclude include/config/auto.conf
7*9c72d26eSMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include
8*9c72d26eSMasahiro Yamadainclude $(srctree)/scripts/Makefile.lib
9*9c72d26eSMasahiro Yamada
10*9c72d26eSMasahiro Yamada# Link of built-in-fixup.a
11*9c72d26eSMasahiro Yamada# ---------------------------------------------------------------------------
12*9c72d26eSMasahiro Yamada
13*9c72d26eSMasahiro Yamada# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
14*9c72d26eSMasahiro Yamadaquiet_cmd_ar_builtin_fixup = AR      $@
15*9c72d26eSMasahiro Yamada      cmd_ar_builtin_fixup = \
16*9c72d26eSMasahiro Yamada	rm -f $@; \
17*9c72d26eSMasahiro Yamada	$(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
18*9c72d26eSMasahiro Yamada	$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
19*9c72d26eSMasahiro Yamada
20*9c72d26eSMasahiro Yamadatargets += built-in-fixup.a
21*9c72d26eSMasahiro Yamadabuilt-in-fixup.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
22*9c72d26eSMasahiro Yamada	$(call if_changed,ar_builtin_fixup)
23*9c72d26eSMasahiro Yamada
24*9c72d26eSMasahiro Yamada# vmlinux.a
25*9c72d26eSMasahiro Yamada# ---------------------------------------------------------------------------
26*9c72d26eSMasahiro Yamada
27*9c72d26eSMasahiro Yamadatargets += vmlinux.a
28*9c72d26eSMasahiro Yamadavmlinux.a: built-in-fixup.a FORCE
29*9c72d26eSMasahiro Yamada	$(call if_changed,copy)
30*9c72d26eSMasahiro Yamada
31*9c72d26eSMasahiro Yamada# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
32*9c72d26eSMasahiro Yamada# ---------------------------------------------------------------------------
33*9c72d26eSMasahiro Yamada
34*9c72d26eSMasahiro YamadaPHONY += FORCE
35*9c72d26eSMasahiro YamadaFORCE:
36*9c72d26eSMasahiro Yamada
37*9c72d26eSMasahiro Yamada# Read all saved command lines and dependencies for the $(targets) we
38*9c72d26eSMasahiro Yamada# may be building above, using $(if_changed{,_dep}). As an
39*9c72d26eSMasahiro Yamada# optimization, we don't need to read them if the target does not
40*9c72d26eSMasahiro Yamada# exist, we will rebuild anyway in that case.
41*9c72d26eSMasahiro Yamada
42*9c72d26eSMasahiro Yamadaexisting-targets := $(wildcard $(sort $(targets)))
43*9c72d26eSMasahiro Yamada
44*9c72d26eSMasahiro Yamada-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
45*9c72d26eSMasahiro Yamada
46*9c72d26eSMasahiro Yamada.PHONY: $(PHONY)
47