xref: /openbmc/qemu/roms/Makefile (revision ef17dd6a)
1
2vgabios_variants := stdvga cirrus vmware qxl isavga virtio bochs-display ramfb ati
3vgabios_targets  := $(subst -isavga,,$(patsubst %,vgabios-%.bin,$(vgabios_variants)))
4pxerom_variants  := e1000 e1000e eepro100 ne2k_pci pcnet rtl8139 virtio vmxnet3
5pxerom_targets   := 8086100e 808610d3 80861209 10500940 10222000 10ec8139 1af41000 15ad07b0
6
7pxe-rom-e1000    efi-rom-e1000    : VID := 8086
8pxe-rom-e1000    efi-rom-e1000    : DID := 100e
9pxe-rom-e1000e   efi-rom-e1000e   : VID := 8086
10pxe-rom-e1000e   efi-rom-e1000e   : DID := 10d3
11pxe-rom-eepro100 efi-rom-eepro100 : VID := 8086
12pxe-rom-eepro100 efi-rom-eepro100 : DID := 1209
13pxe-rom-ne2k_pci efi-rom-ne2k_pci : VID := 1050
14pxe-rom-ne2k_pci efi-rom-ne2k_pci : DID := 0940
15pxe-rom-pcnet    efi-rom-pcnet    : VID := 1022
16pxe-rom-pcnet    efi-rom-pcnet    : DID := 2000
17pxe-rom-rtl8139  efi-rom-rtl8139  : VID := 10ec
18pxe-rom-rtl8139  efi-rom-rtl8139  : DID := 8139
19pxe-rom-virtio   efi-rom-virtio   : VID := 1af4
20pxe-rom-virtio   efi-rom-virtio   : DID := 1000
21pxe-rom-vmxnet3  efi-rom-vmxnet3  : VID := 15ad
22pxe-rom-vmxnet3  efi-rom-vmxnet3  : DID := 07b0
23
24#
25# cross compiler auto detection
26#
27path := $(subst :, ,$(PATH))
28system := $(shell uname -s | tr "A-Z" "a-z")
29
30# first find cross binutils in path
31find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path))))
32# then check we have cross gcc too
33find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1)))))
34# finally strip off path + toolname so we get the prefix
35find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1))))
36
37arm_cross_prefix := $(call find-cross-prefix,arm)
38powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64)
39powerpc_cross_prefix := $(call find-cross-prefix,powerpc)
40x86_64_cross_prefix := $(call find-cross-prefix,x86_64)
41riscv32_cross_prefix := $(call find-cross-prefix,riscv32)
42riscv64_cross_prefix := $(call find-cross-prefix,riscv64)
43
44# tag our seabios builds
45SEABIOS_EXTRAVERSION="-prebuilt.qemu.org"
46
47#
48# EfiRom utility is shipped with edk2 / tianocore, in BaseTools/
49#
50# We need that to combine multiple images (legacy bios,
51# efi ia32, efi x64) into a single rom binary.
52#
53EDK2_EFIROM = edk2/BaseTools/Source/C/bin/EfiRom
54
55default help:
56	@echo "nothing is build by default"
57	@echo "available build targets:"
58	@echo "  bios               -- update bios.bin (seabios)"
59	@echo "  vgabios            -- update vgabios binaries (seabios)"
60	@echo "  sgabios            -- update sgabios binaries"
61	@echo "  pxerom             -- update nic roms (bios only)"
62	@echo "  efirom             -- update nic roms (bios+efi)"
63	@echo "  slof               -- update slof.bin"
64	@echo "  skiboot            -- update skiboot.lid"
65	@echo "  u-boot.e500        -- update u-boot.e500"
66	@echo "  u-boot.sam460      -- update u-boot.sam460"
67	@echo "  npcm7xx_bootrom    -- update vbootrom for npcm7xx"
68	@echo "  efi                -- update UEFI (edk2) platform firmware"
69	@echo "  opensbi32-generic  -- update OpenSBI for 32-bit generic machine"
70	@echo "  opensbi64-generic  -- update OpenSBI for 64-bit generic machine"
71	@echo "  qboot              -- update qboot"
72	@echo "  clean              -- delete the files generated by the previous" \
73	                              "build targets"
74
75bios: build-seabios-config-seabios-128k \
76		build-seabios-config-seabios-256k \
77		build-seabios-config-seabios-microvm
78	cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin
79	cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin
80	cp seabios/builds/seabios-microvm/bios.bin ../pc-bios/bios-microvm.bin
81
82vgabios seavgabios: $(patsubst %,seavgabios-%,$(vgabios_variants))
83
84seavgabios-isavga: build-seabios-config-vga-isavga
85	cp seabios/builds/vga-isavga/vgabios.bin ../pc-bios/vgabios.bin
86
87seavgabios-%: build-seabios-config-vga-%
88	cp seabios/builds/vga-$*/vgabios.bin ../pc-bios/vgabios-$*.bin
89
90build-seabios-config-%: config.%
91	mkdir -p seabios/builds/$*
92	cp $< seabios/builds/$*/.config
93	$(MAKE) -C seabios \
94		EXTRAVERSION=$(SEABIOS_EXTRAVERSION) \
95		CROSS_PREFIX=$(x86_64_cross_prefix) \
96		KCONFIG_CONFIG=$(CURDIR)/seabios/builds/$*/.config \
97		OUT=$(CURDIR)/seabios/builds/$*/ oldnoconfig
98	$(MAKE) -C seabios \
99		EXTRAVERSION=$(SEABIOS_EXTRAVERSION) \
100		CROSS_PREFIX=$(x86_64_cross_prefix) \
101		KCONFIG_CONFIG=$(CURDIR)/seabios/builds/$*/.config \
102		OUT=$(CURDIR)/seabios/builds/$*/ all
103
104
105.PHONY: sgabios skiboot qboot
106sgabios:
107	$(MAKE) -C sgabios
108	cp sgabios/sgabios.bin ../pc-bios
109
110
111pxerom: $(patsubst %,pxe-rom-%,$(pxerom_variants))
112
113pxe-rom-%: build-pxe-roms
114	cp ipxe/src/bin/$(VID)$(DID).rom ../pc-bios/pxe-$*.rom
115
116efirom: $(patsubst %,efi-rom-%,$(pxerom_variants))
117
118efi-rom-%: build-pxe-roms build-efi-roms edk2-basetools
119	$(EDK2_EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
120		-b ipxe/src/bin/$(VID)$(DID).rom \
121		-ec ipxe/src/bin-x86_64-efi/$(VID)$(DID).efidrv \
122		-o ../pc-bios/efi-$*.rom
123
124build-pxe-roms:
125	$(MAKE) -C ipxe/src CONFIG=qemu \
126		CROSS_COMPILE=$(x86_64_cross_prefix) \
127		$(patsubst %,bin/%.rom,$(pxerom_targets))
128
129build-efi-roms: build-pxe-roms
130	$(MAKE) -C ipxe/src CONFIG=qemu \
131		CROSS_COMPILE=$(x86_64_cross_prefix) \
132		$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
133
134# Build scripts can pass compiler/linker flags to the EDK2
135# build tools via the EDK2_BASETOOLS_OPTFLAGS (CFLAGS) and
136# EDK2_BASETOOLS_LDFLAGS (LDFLAGS) environment variables.
137#
138# Example:
139#
140#  make -C roms \
141#    EDK2_BASETOOLS_OPTFLAGS='...' \
142#    EDK2_BASETOOLS_LDFLAGS='...' \
143#    efirom
144#
145edk2-basetools:
146	cd edk2/BaseTools && git submodule update --init --force \
147		Source/C/BrotliCompress/brotli
148	$(MAKE) -C edk2/BaseTools \
149		PYTHON_COMMAND=$${EDK2_PYTHON_COMMAND:-python3} \
150		EXTRA_OPTFLAGS='$(EDK2_BASETOOLS_OPTFLAGS)' \
151		EXTRA_LDFLAGS='$(EDK2_BASETOOLS_LDFLAGS)'
152
153slof:
154	$(MAKE) -C SLOF CROSS=$(powerpc64_cross_prefix) qemu
155	cp SLOF/boot_rom.bin ../pc-bios/slof.bin
156
157u-boot.e500:
158	$(MAKE) -C u-boot O=build-e500 qemu-ppce500_config
159	$(MAKE) -C u-boot CROSS_COMPILE=$(powerpc_cross_prefix) \
160		O=build-e500
161	$(powerpc_cross_prefix)strip u-boot/build-e500/u-boot -o \
162		../pc-bios/u-boot.e500
163
164u-boot.sam460:
165	$(MAKE) -C u-boot-sam460ex Sam460ex_config
166	$(MAKE) -C u-boot-sam460ex CROSS_COMPILE=$(powerpc_cross_prefix)
167	cp u-boot-sam460ex/u-boot.bin ../pc-bios/u-boot-sam460-20100605.bin
168
169skiboot:
170	$(MAKE) -C skiboot CROSS=$(powerpc64_cross_prefix)
171	cp skiboot/skiboot.lid ../pc-bios/skiboot.lid
172
173efi: edk2-basetools
174	$(MAKE) -f Makefile.edk2
175
176opensbi32-generic:
177	$(MAKE) -C opensbi \
178		CROSS_COMPILE=$(riscv32_cross_prefix) \
179		PLATFORM="generic"
180	cp opensbi/build/platform/generic/firmware/fw_dynamic.bin ../pc-bios/opensbi-riscv32-generic-fw_dynamic.bin
181
182opensbi64-generic:
183	$(MAKE) -C opensbi \
184		CROSS_COMPILE=$(riscv64_cross_prefix) \
185		PLATFORM="generic"
186	cp opensbi/build/platform/generic/firmware/fw_dynamic.bin ../pc-bios/opensbi-riscv64-generic-fw_dynamic.bin
187
188MESON = meson
189NINJA = ninja
190qboot:
191	mkdir -p qboot/build
192	$(MESON) setup $(if $(wildcard qboot/build/meson-private),--wipe,) qboot qboot/build
193	$(NINJA) -C qboot/build
194	cp qboot/build/bios.bin ../pc-bios/qboot.rom
195
196npcm7xx_bootrom:
197	$(MAKE) -C vbootrom CROSS_COMPILE=$(arm_cross_prefix)
198	cp vbootrom/npcm7xx_bootrom.bin ../pc-bios/npcm7xx_bootrom.bin
199
200clean:
201	rm -rf seabios/.config seabios/out seabios/builds
202	$(MAKE) -C sgabios clean
203	rm -f sgabios/.depend
204	$(MAKE) -C ipxe/src veryclean
205	$(MAKE) -C edk2/BaseTools clean
206	$(MAKE) -C SLOF clean
207	rm -rf u-boot/build-e500
208	$(MAKE) -C u-boot-sam460ex distclean
209	$(MAKE) -C skiboot clean
210	$(MAKE) -f Makefile.edk2 clean
211	$(MAKE) -C opensbi clean
212	$(MAKE) -C qboot clean
213	$(MAKE) -C vbootrom clean
214