xref: /openbmc/linux/arch/s390/purgatory/Makefile (revision 0c94efab)
1# SPDX-License-Identifier: GPL-2.0
2
3OBJECT_FILES_NON_STANDARD := y
4
5purgatory-y := head.o purgatory.o string.o sha256.o mem.o
6
7targets += $(purgatory-y) purgatory.lds purgatory purgatory.ro
8PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
9
10$(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE
11	$(call if_changed_rule,cc_o_c)
12
13$(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE
14	$(call if_changed_rule,as_o_S)
15
16$(obj)/string.o: $(srctree)/arch/s390/lib/string.c FORCE
17	$(call if_changed_rule,cc_o_c)
18
19KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
20KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
21KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
22KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common
23KBUILD_CFLAGS += $(CLANG_FLAGS)
24KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
25KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
26
27LDFLAGS_purgatory := -r --no-undefined -nostdlib -z nodefaultlib -T
28$(obj)/purgatory: $(obj)/purgatory.lds $(PURGATORY_OBJS) FORCE
29		$(call if_changed,ld)
30
31OBJCOPYFLAGS_purgatory.ro := -O elf64-s390
32OBJCOPYFLAGS_purgatory.ro += --remove-section='*debug*'
33OBJCOPYFLAGS_purgatory.ro += --remove-section='.comment'
34OBJCOPYFLAGS_purgatory.ro += --remove-section='.note.*'
35$(obj)/purgatory.ro: $(obj)/purgatory FORCE
36		$(call if_changed,objcopy)
37
38$(obj)/kexec-purgatory.o: $(obj)/kexec-purgatory.S $(obj)/purgatory.ro FORCE
39	$(call if_changed_rule,as_o_S)
40
41obj-$(CONFIG_ARCH_HAS_KEXEC_PURGATORY) += kexec-purgatory.o
42