1# SPDX-License-Identifier: GPL-2.0-only
2#
3# linux/arch/parisc/boot/compressed/Makefile
4#
5# create a compressed self-extracting vmlinux image from the original vmlinux
6#
7
8KCOV_INSTRUMENT := n
9GCOV_PROFILE := n
10UBSAN_SANITIZE := n
11
12targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
13targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
14targets += misc.o piggy.o sizes.h head.o real2.o firmware.o
15
16KBUILD_CFLAGS := -D__KERNEL__ -O2 -DBOOTLOADER
17KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
18KBUILD_CFLAGS += $(cflags-y) -fno-delete-null-pointer-checks -fno-builtin-printf
19KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs -Os
20ifndef CONFIG_64BIT
21KBUILD_CFLAGS += -mfast-indirect-calls
22endif
23
24OBJECTS += $(obj)/head.o $(obj)/real2.o $(obj)/firmware.o $(obj)/misc.o $(obj)/piggy.o
25
26LDFLAGS_vmlinux := -X -e startup --as-needed -T
27$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(LIBGCC)
28	$(call if_changed,ld)
29
30sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\|parisc_kernel_start\)$$/\#define SZ\2 0x\1/p'
31
32quiet_cmd_sizes = GEN $@
33      cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@
34
35$(obj)/sizes.h: vmlinux
36	$(call if_changed,sizes)
37
38AFLAGS_head.o += -I$(objtree)/$(obj) -DBOOTLOADER
39$(obj)/head.o: $(obj)/sizes.h
40
41CFLAGS_misc.o += -I$(objtree)/$(obj)
42$(obj)/misc.o: $(obj)/sizes.h
43
44$(obj)/firmware.o: $(obj)/firmware.c
45$(obj)/firmware.c: $(srctree)/arch/$(SRCARCH)/kernel/firmware.c
46	$(call cmd,shipped)
47
48AFLAGS_real2.o += -DBOOTLOADER
49$(obj)/real2.o: $(obj)/real2.S
50$(obj)/real2.S: $(srctree)/arch/$(SRCARCH)/kernel/real2.S
51	$(call cmd,shipped)
52
53$(obj)/misc.o: $(obj)/sizes.h
54
55CPPFLAGS_vmlinux.lds += -I$(objtree)/$(obj) -DBOOTLOADER
56$(obj)/vmlinux.lds: $(obj)/sizes.h
57
58$(obj)/vmlinux.bin: vmlinux
59	$(call if_changed,objcopy)
60
61vmlinux.bin.all-y := $(obj)/vmlinux.bin
62
63suffix-$(CONFIG_KERNEL_GZIP)  := gz
64suffix-$(CONFIG_KERNEL_BZIP2) := bz2
65suffix-$(CONFIG_KERNEL_LZ4)  := lz4
66suffix-$(CONFIG_KERNEL_LZMA)  := lzma
67suffix-$(CONFIG_KERNEL_LZO)  := lzo
68suffix-$(CONFIG_KERNEL_XZ)  := xz
69
70$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
71	$(call if_changed,gzip)
72$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
73	$(call if_changed,bzip2)
74$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
75	$(call if_changed,lz4)
76$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
77	$(call if_changed,lzma)
78$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
79	$(call if_changed,lzo)
80$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y)
81	$(call if_changed,xzkern)
82
83LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T
84$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y)
85	$(call if_changed,ld)
86