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