|
1 | | -all: coreboot |
| 1 | +modules := |
| 2 | +pwd := $(shell pwd) |
| 3 | +packages := $(pwd)/packages |
| 4 | +build := $(pwd)/build |
| 5 | +config := $(pwd)/build |
| 6 | + |
| 7 | +all: |
| 8 | + |
| 9 | +include modules/qrencode |
| 10 | +include modules/kexec |
| 11 | +include modules/tpmtotp |
| 12 | +include modules/mbedtls |
| 13 | + |
| 14 | +all: $(modules) |
| 15 | + |
| 16 | +define prefix = |
| 17 | +$(foreach _, $2, $1$_) |
| 18 | +endef |
| 19 | + |
| 20 | +define outputs = |
| 21 | +$(call prefix,$(build)/$($1_dir)/,$($1_output)) |
| 22 | +endef |
| 23 | + |
| 24 | +# |
| 25 | +# Generate the targets for a module. |
| 26 | +# |
| 27 | +# Special variables like $@ must be written as $$@ to avoid |
| 28 | +# expansion during the first evaluation. |
| 29 | +# |
| 30 | +define define_module = |
| 31 | + # Fetch and verify the source tar file |
| 32 | + $(packages)/$($1_tar): |
| 33 | + wget -O "$$@" $($1_url) |
| 34 | + $(packages)/.$1_verify: $(packages)/$($1_tar) |
| 35 | + echo "$($1_hash) $$^" | sha256sum --check - |
| 36 | + touch "$$@" |
| 37 | + |
| 38 | + # Unpack the tar file and touch the canary so that we know |
| 39 | + # that the files are all present |
| 40 | + $(build)/$($1_dir)/.canary: $(packages)/.$1_verify |
| 41 | + tar -xvf "$(packages)/$($1_tar)" -C "$(build)" |
| 42 | + touch "$$@" |
| 43 | + |
| 44 | + # Copy our stored config file into the unpacked directory |
| 45 | + $(build)/$($1_dir)/.config: config/$1.config $(build)/$($1_dir)/.canary |
| 46 | + cp "$$<" "$$@" |
| 47 | + |
| 48 | + # Use the module's configure variable to build itself |
| 49 | + $(build)/$($1_dir)/.configured: \ |
| 50 | + $(build)/$($1_dir)/.canary \ |
| 51 | + $(build)/$($1_dir)/.config |
| 52 | + cd "$(build)/$($1_dir)" ; $($1_configure) |
| 53 | + touch "$$@" |
| 54 | + |
| 55 | + # Actually build the target |
| 56 | + $(call outputs,$1): $(build)/$($1_dir)/.configured $(call outputs,$($1_depends)) |
| 57 | + make -C "$(build)/$($1_dir)" $($1_target) |
| 58 | + $1: $(call outputs,$1) |
| 59 | + |
| 60 | + # Update any dependencies |
| 61 | +endef |
| 62 | + |
| 63 | +$(foreach _, $(modules), $(eval $(call define_module,$_))) |
2 | 64 |
|
3 | | -force: |
4 | | - -rm $(linux_dir)/arch/x86/boot/bzImage |
5 | | - |
6 | | -# uclibc must be built after the kernel, |
7 | | -# since 'make headers_install' must be run to generate the |
8 | | -# headers that uclibc needs. |
9 | | -uclibc_url := https://uclibc.org/downloads/uClibc-0.9.33.tar.xz |
10 | | - |
11 | | - |
12 | | -kexec_version := 2.0.12 |
13 | | -kexec_dir := kexec-tools-$(kexec_version) |
14 | | -kexec_tar := kexec-tools-$(kexec_version).tar.gz |
15 | | -kexec_url := https://kernel.org/pub/linux/utils/kernel/kexec/$(kexec_tar) |
16 | | -kexec_hash := cc7b60dad0da202004048a6179d8a53606943062dd627a2edba45a8ea3a85135 |
17 | | - |
18 | | -$(kexec_tar): |
19 | | - wget "$(kexec_url)" |
20 | | - sha256sum "$(kexec_tar)" |
21 | | - echo "$(kexec_hash)" |
22 | | - |
23 | | -$(kexec_dir): $(kexec_tar) |
24 | | - tar xvf "$(kexec_tar)" |
25 | | - cd "$(kexec_dir)" && ./configure |
26 | | - |
27 | | -kexec: $(kexec_dir) |
28 | | - make -C "$(kexec_dir)" -j 8 |
29 | | - |
30 | | - |
31 | | -qrencode_dir := qrencode-3.4.4 |
32 | | -qrencode_tar := qrencode-3.4.4.tar.gz |
33 | | -qrencode_url := https://fukuchi.org/works/qrencode/$(qrencode_tar) |
34 | | -qrencode_canary := $(qrencode_dir)/.canary |
35 | | - |
36 | | -$(qrencode_tar): |
37 | | - wget $(qrencode_url) |
38 | | - |
39 | | -qrencode_lib := $(qrencode_dir)/.libs/libqrencode.so |
40 | | -$(qrencode_canary): $(qrencode_tar) |
41 | | - tar xvf "$<" |
42 | | - touch "$@" |
43 | | - |
44 | | -$(qrencode_lib): $(qrencode_canary) |
45 | | - cd $(qrencode_dir) ; ./configure --without-tools |
46 | | - make -C "$(qrencode_dir)" |
47 | | - |
48 | | - |
49 | | -initrd/bin/unsealtotp: $(qrencode_lib) |
50 | | - make -C tpmtotp unsealtotp |
51 | | - cp tpmtotp/unsealtotp "$@" |
52 | | -initrd/bin/sealtotp: $(qrencode_lib) |
53 | | - make -C tpmtotp sealtotp |
54 | | - cp tpmtotp/sealtotp "$@" |
55 | | - |
56 | | - |
57 | | -busybox_version := 1.25.0 |
58 | | -busybox_dir := busybox-$(busybox_version) |
59 | | -busybox_tar := busybox-$(busybox_version).tar.bz2 |
60 | | -busybox_url := https://busybox.net/downloads/$(busybox_tar) |
61 | | -busybox_hash := 5a0fe06885ee1b805fb459ab6aaa023fe4f2eccee4fb8c0fd9a6c17c0daca2fc |
62 | | -busybox_config := config/busybox.config |
63 | | - |
64 | | -$(busybox_dir)/busybox: $(busybox_dir) $(busybox_dir)/.config |
65 | | - make -C "$(busybox_dir)" -j 8 |
66 | | - |
67 | | -$(busybox_dir): $(busybox_tar) |
68 | | - tar xvf "$(busybox_tar)" |
69 | | - |
70 | | -$(busybox_dir)/.config: $(busybox_config) |
71 | | - cp "$<" "$@" |
72 | | - make -C "$(busybox_dir)" oldconfig |
73 | | - |
74 | | -$(busybox_tar): |
75 | | - wget "$(busybox_url)" |
76 | | - sha256sum "$(busybox_tar)" |
77 | | - echo "$(busybox_hash)" |
78 | | - |
79 | | - |
80 | | -linux_version := 4.6.4 |
81 | | -linux_dir := linux-$(linux_version) |
82 | | -linux_tar := linux-$(linux_version).tar.xz |
83 | | -linux_url := https://cdn.kernel.org/pub/linux/kernel/v4.x/$(linux_tar) |
84 | | -linux_hash := 8568d41c7104e941989b14a380d167129f83db42c04e950d8d9337fe6012ff7e |
85 | | -linux_config := config/linux.config |
86 | | - |
87 | | -$(linux_dir): $(linux_tar) |
88 | | - tar xvf "$(linux_tar)" |
89 | | - |
90 | | -$(linux_dir)/.config: $(linux_config) |
91 | | - cp "$<" "$@" |
92 | | - make -C "$(linux_dir)" oldconfig |
93 | | - |
94 | | -bzImage: $(linux_dir)/arch/x86/boot/bzImage |
95 | | - |
96 | | -$(linux_dir)/arch/x86/boot/bzImage: \ |
97 | | - $(linux_dir) \ |
98 | | - $(linux_dir)/.config \ |
99 | | - initrd/bin/busybox \ |
100 | | - initrd/libs \ |
101 | | - |
102 | | - make -C "$(linux_dir)" bzImage |
103 | | - ls -Fla "$@" |
104 | | - |
105 | | -coreboot_version := 4.4 |
106 | | -coreboot_dir := coreboot-$(coreboot_version) |
107 | | -coreboot_tar := coreboot-$(coreboot_version).tar.xz |
108 | | -coreboot_url := https://www.coreboot.org/releases/$(coreboot_tar) |
109 | | -coreboot_config := config/coreboot.config |
110 | | - |
111 | | -coreboot-blobs_tar := coreboot-blobs-$(coreboot_version).tar.xz |
112 | | -coreboot-blobs_url := https://www.coreboot.org/releases/$(coreboot-blobs_tar) |
113 | | -coreboot-blobs_dir := coreboot-$(coreboot_version)/3rdparty/blobs |
114 | | -coreboot-blobs_hash := 43b993915c0f46a77ee7ddaa2dbe47581f399510632c62f2558dff931358d8ab |
115 | | -coreboot-blobs_canary := $(coreboot-blobs_dir)/documentation/binary_policy.md |
116 | | - |
117 | | - |
118 | | -$(coreboot_dir)/util/crossgcc/xgcc/bin/iasl: |
119 | | - echo '******* Building gcc (this might take a while) ******' |
120 | | - time make -C "$(coreboot_dir)" crossgcc |
121 | | - |
122 | | -$(coreboot_dir)/bzImage: $(linux_dir)/arch/x86/boot/bzImage |
123 | | - cp "$<" "$@" |
124 | | - |
125 | | -initrd.img: |
126 | | - ( \ |
127 | | - cd initrd && \ |
128 | | - find . \ |
129 | | - | cpio --quiet -H newc -o \ |
130 | | - ) | xz -9 > "$@" |
131 | | - |
132 | | -# initrd image is now included by the Linux kernel build process |
133 | | -initrd: \ |
134 | | - initrd/bin/busybox \ |
135 | | - initrd/sbin/kexec \ |
136 | | - initrd/libs |
137 | | - |
138 | | -initrd/bin/busybox: $(busybox_dir)/busybox |
139 | | - make -C "$(busybox_dir)" CONFIG_PREFIX="`pwd`/initrd" install |
140 | | - |
141 | | -initrd/sbin/kexec: $(kexec_dir)/build/sbin/kexec |
142 | | - -mkdir "`dirnname "$@"`" |
143 | | - cp "$<" "$@" |
144 | | - |
145 | | -INITRD_LIBS += \ |
146 | | - liblzma.so.5 \ |
147 | | - libz.so.1 \ |
148 | | - libc.so.6 \ |
149 | | - libdl.so.2 \ |
150 | | - |
151 | | -initrd/libs: |
152 | | - ./populate-lib ./initrd/lib/x86_64-linux-gnu/ initrd/bin/* initrd/sbin/* |
153 | | - |
154 | | - |
155 | | -$(coreboot_tar): |
156 | | - wget "$(coreboot_url)" |
157 | | - sha256sum "$(coreboot_tar)" |
158 | | - echo "$(coreboot_hash)" |
159 | | - |
160 | | -$(coreboot-blobs_tar): |
161 | | - wget "$(coreboot-blobs_url)" |
162 | | - sha256sum "$(coreboot-blobs_tar)" |
163 | | - echo "$(coreboot-blobs_hash)" |
164 | | - |
165 | | -$(coreboot_blobs_canary): $(coreboot-blobs_tar) |
166 | | - tar xvf "$(coreboot-blobs_tar)" |
167 | | - |
168 | | -$(coreboot_dir): $(coreboot_tar) |
169 | | - tar xvf "$(coreboot_tar)" |
170 | | - |
171 | | -$(coreboot_dir)/.config: $(coreboot_config) |
172 | | - cp "$<" "$@" |
173 | | - make -C "$(coreboot_dir)" oldconfig |
174 | | - |
175 | | -$(coreboot_dir)/build/coreboot.rom: \ |
176 | | - $(coreboot_dir) \ |
177 | | - $(coreboot_dir)/.config \ |
178 | | - $(coreboot_dir)/util/crossgcc/xgcc/bin/iasl \ |
179 | | - $(coreboot_dir)/bzImage \ |
180 | | - $(coreboot-blobs_canary) \ |
181 | | - |
182 | | - make -C "$(coreboot_dir)" |
183 | | - |
184 | | -heads-x230.rom: $(coreboot_dir)/build/coreboot.rom |
185 | | - dd if="$<" of="$@" bs=1M skip=8 |
186 | | - sha256sum "$@" |
187 | | - xxd -g 1 "$@" | head |
188 | | - xxd -g 1 "$@" | tail |
189 | | - |
190 | | -coreboot: heads-x230.rom |
191 | | - |
192 | | -FORCE: |
0 commit comments