aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: bf16c3b5620ca09ff4baecd69abea24927a714d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# directories
DESTDIR	?=
prefix	?= /usr/local
datadir	:= $(DESTDIR)$(prefix)/share/qemu-firmware

vgabios_variants := stdvga cirrus vmware qxl isavga virtio
vgabios_targets  := $(subst -isavga,,$(patsubst %,vgabios-%.bin,$(vgabios_variants)))

#
# cross compiler auto detection
#
path := $(subst :, ,$(PATH))
system := $(shell uname -s | tr "A-Z" "a-z")

# first find cross binutils in path
find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path))))
# then check we have cross gcc too
find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1)))))
# finally strip off path + toolname so we get the prefix
find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1))))

powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64)
powerpc_cross_prefix := $(call find-cross-prefix,powerpc)
x86_64_cross_prefix := $(call find-cross-prefix,x86_64)

# tag our seabios builds
SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org"

default help:
	@echo
	@echo "nothing is done by default"
	@echo
	@echo "build targets:"
	@echo "  bios           -- update bios.bin (seabios)"
	@echo "  vgabios        -- update vgabios binaries (seabios)"
	@echo
	@echo "other targets:"
	@echo "  clean          -- cleanup"
	@echo "  install        -- install blobs to $(datadir)"
	@echo
	@echo "You can set DESTDIR and prefix on the command line to"
	@echo "to change the install target directory, for example:"
	@echo "$ make prefix=/usr install"
	@echo

install:
	mkdir -p $(datadir)
	cp -v blobs/*.bin $(datadir)

bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k
	cp repos/seabios/builds/seabios-128k/bios.bin blobs/bios.bin
	cp repos/seabios/builds/seabios-256k/bios.bin blobs/bios-256k.bin

vgabios: $(patsubst %,vgabios-%,$(vgabios_variants))

vgabios-isavga: build-seabios-config-vga-isavga
	cp repos/seabios/builds/vga-isavga/vgabios.bin blobs/vgabios.bin

vgabios-%: build-seabios-config-vga-%
	cp repos/seabios/builds/vga-$*/vgabios.bin blobs/vgabios-$*.bin

build-seabios-config-%: configs/% submodule-seabios
	mkdir -p repos/seabios/builds/$*
	cp $< repos/seabios/builds/$*/.config
	$(MAKE) -C repos/seabios \
		EXTRAVERSION=$(SEABIOS_EXTRAVERSION) \
		CROSS_COMPILE=$(x86_64_cross_prefix) \
		KCONFIG_CONFIG=$(CURDIR)/repos/seabios/builds/$*/.config \
		OUT=$(CURDIR)/repos/seabios/builds/$*/ oldnoconfig
	$(MAKE) -C repos/seabios \
		EXTRAVERSION=$(SEABIOS_EXTRAVERSION) \
		CROSS_COMPILE=$(x86_64_cross_prefix) \
		KCONFIG_CONFIG=$(CURDIR)/repos/seabios/builds/$*/.config \
		OUT=$(CURDIR)/repos/seabios/builds/$*/ all

clean:
	rm -rf repos/seabios/.config repos/seabios/out repos/seabios/builds

submodule-%:
	git submodule update --init repos/$*