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