forked from HW42/qubes-vmm-xen-stubdom-linux
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMakefile.stubdom
327 lines (286 loc) · 9.61 KB
/
Makefile.stubdom
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
include Makefile.vars
.PHONY: all full install clean
SHELL := bash
STUBDOM_BINDIR=/usr/libexec/xen/boot
VMLINUZ=build/linux/arch/x86/boot/bzImage
ROOTFS_IMG=build/rootfs/stubdom-linux-rootfs
# Stubdom disk content
STUBDOM_DISK_FILE= \
build/busybox/busybox \
build/qemu/build/qemu-system-i386 \
rootfs/init \
rootfs/qemu-ifup \
rootfs/qemu-ifdown \
helpers/add-fd \
helpers/vchan-socket-proxy
Q=scripts/quilt-wrapper
all: $(VMLINUZ) $(ROOTFS_IMG)
full: all
ifneq ($(filter full,$(MAKECMDGOALS)),)
PKG_CONFIG_LIBDIR=$(shell pwd)/build/pulseaudio:$(shell pwd)/build/libusb
export PKG_CONFIG_LIBDIR
QEMU_OPTIONS=--enable-libusb --enable-pa --audio-drv-list=pa
QEMU_EXTRA_CFLAGS+=-I$(shell pwd)/build/padist/usr/local/include \
-I$(shell pwd)/build/padist/usr/local/include/libusb-1.0
QEMU_EXTRA_LDFLAGS+=-Wl,-z,nodlopen -Wl,-z,nodump -Wl,-z,noexecstack \
-Wl,-rpath-link,$(shell pwd)/build/padist/lib/pulseaudio \
-L$(shell pwd)/build/padist/lib
ROOTFS_NAME=qemu-stubdom-linux-full-rootfs
KERNEL_NAME=qemu-stubdom-linux-full-kernel
KERNEL_CONFIG=[0-9][0-9]-*
FULL_BUILDDEPS=build/padist/usr/local/bin/pulseaudio \
build/libusb/.installed \
build/qrexec/agent/qrexec-agent
else
QEMU_OPTIONS=--disable-libusb --audio-drv-list=
QEMU_EXTRA_CFLAGS=
QEMU_EXTRA_LDFLAGS=
FULL_BUILDDEPS=
ROOTFS_NAME=qemu-stubdom-linux-rootfs
KERNEL_NAME=qemu-stubdom-linux-kernel
KERNEL_CONFIG=[0-4][0-9]-*
endif
BUSYBOX_PATCHES := $(shell $Q -l busybox)
build/busybox/.extracted: busybox-$(BUSYBOX_VERSION).tar.bz2
rm -rf build/busybox
mkdir -p build/busybox
tar -C build/busybox --strip-components=1 -xf $<
touch $@
build/busybox/.patched: build/busybox/.extracted busybox/patches/series $(BUSYBOX_PATCHES)
[ ! -d build/busybox/.patches ] || $Q -C build/busybox -. pop -a
rm -rf build/busybox/.patches
cp -aL busybox/patches build/busybox/.patches
$Q -C build/busybox -. push -a
touch $@
build/busybox/config.status: build/busybox/.patched
cp busybox/busybox.config build/busybox/.config
yes "" | $(MAKE) -C build/busybox oldconfig
touch $@
build/busybox/busybox: build/busybox/config.status
$(MAKE) $(MAKE_PARALLEL) -C build/busybox
strip --strip-unneeded build/busybox/busybox_unstripped
mv build/busybox/busybox_unstripped build/busybox/busybox
PULSEAUDIO_PATCHES := $(shell $Q -l pulseaudio)
build/pulseaudio/.extracted: pulseaudio-$(PULSEAUDIO_VERSION).tar.xz
rm -rf build/pulseaudio
mkdir -p build/pulseaudio
tar -C build/pulseaudio --strip-components=1 -xf $<
touch $@
build/pulseaudio/src/modules/module-vchan-sink.c: build/pulseaudio/.extracted
cp pulseaudio/gui-agent/pulse/*vchan-sink* build/pulseaudio/src/modules/
build/pulseaudio/.patched: build/pulseaudio/.extracted pulseaudio/patches/series $(PULSEAUDIO_PATCHES)
[ ! -d build/pulseaudio/.patches ] || $Q -C build/pulseaudio -. pop -a
rm -rf build/pulseaudio/.patches
cp -aL pulseaudio/patches build/pulseaudio/.patches
$Q -C build/pulseaudio -. push -a
touch $@
build/pulseaudio/config.status: build/pulseaudio/.patched build/pulseaudio/src/modules/module-vchan-sink.c
cd build/pulseaudio && aclocal && ./configure \
--disable-silent-rules \
--disable-static \
--disable-static-bins \
--disable-rpath \
--disable-oss-output \
--disable-coreaudio-output \
--disable-jack \
--disable-nls \
--disable-lirc \
--disable-tcpwrap \
--disable-bluez5 \
--disable-gconf \
--disable-gsettings \
--disable-neon-opt \
--disable-webrtc-aec \
--disable-systemd-daemon \
--disable-dbus \
--disable-gtk3 \
--disable-alsa \
--disable-esound \
--disable-largefile \
--disable-x11 \
--disable-oss-wrapper \
--without-caps \
--with-database=simple \
--without-fftw \
--without-speex \
--without-soxr \
--disable-manpages \
--disable-per-user-esound-socket \
--disable-gstreamer \
--disable-systemd-journal \
--disable-systemd-login \
--disable-systemd-daemon \
--disable-openssl \
--disable-udev \
--disable-ipv6 \
--disable-hal-compat \
--disable-tcpwrap \
--disable-asyncns \
--disable-waveout \
--enable-memfd \
--disable-tests \
--disable-glib2 \
--with-module-dir=/lib \
--libdir=/lib \
ac_cv_header_locale_h=no \
ac_cv_func_strtod_l=no \
ac_cv_header_langinfo_h=no \
ac_cv_func_shm_open=no \
ac_cv_func_fork=no \
ac_cv_func_getaddrinfo=no \
ac_cv_func_getuid=no \
ac_cv_func_seteuid=no \
ac_cv_func_setresuid=no \
ac_cv_func_setreuid=no \
ac_cv_header_pwd_h=no \
ac_cv_header_grp_h=no
build/padist/usr/local/bin/pulseaudio: build/pulseaudio/config.status
$(MAKE) $(MAKE_PARALLEL) install-strip -C build/pulseaudio DESTDIR=$(shell pwd)/build/padist
build/libusb/.extracted: libusb-$(LIBUSB_VERSION).tar.bz2
rm -rf build/libusb
mkdir -p build/libusb
tar -C build/libusb --strip-components=1 -xf $<
touch $@
build/libusb/config.status: build/libusb/.extracted
cd build/libusb && ./configure \
--disable-static \
--disable-udev \
--libdir=/lib
build/libusb/.installed: build/libusb/config.status
$(MAKE) $(MAKE_PARALLEL) -C build/libusb
$(MAKE) install-strip -C build/libusb DESTDIR=$(shell pwd)/build/padist
touch $@
build/qrexec/agent/qrexec-agent:
rm -rf build/qrexec
mkdir -p build
cp -a qrexec build/
make BACKEND_VMM=xen -C build/qrexec/libqrexec all
make BACKEND_VMM=xen -C build/qrexec/agent qrexec-client-vm qrexec-agent qrexec-fork-server
QEMU_PATCHES := $(shell $Q -l qemu)
build/qemu/.extracted: qemu-$(QEMU_VERSION).tar.xz
rm -rf build/qemu
mkdir -p build/qemu
tar -C build/qemu --strip-components=1 -xf $<
rm build/qemu/pc-bios/*.{rom,bin,dtb} # remove prebuilt binaries
touch $@
build/qemu/.patched: build/qemu/.extracted qemu/patches/series $(QEMU_PATCHES)
[ ! -d build/qemu/.patches ] || $Q -C build/qemu -. pop -a
rm -rf build/qemu/.patches
cp -aL qemu/patches build/qemu/.patches
$Q -C build/qemu -. push -a
touch $@
QEMU_GUI_AGENT_FILES := $(shell find qemu/gui-agent -type f \! \( -name '*.sw?' -o -name '*~' -o -name '.*' -o -name '*.patch' \) | sort)
build/qemu/.gui-agent-copied-in: build/qemu/.extracted $(QEMU_GUI_AGENT_FILES)
rm -rf build/qemu/ui/gui-agent
cp -a qemu/gui-agent build/qemu/ui/
# generates qubes-keycode2scancode.c
make -C build/qemu/ui/gui-agent/gui-agent-qemu/
touch $@
export QEMU_PKG_CONFIG_FLAGS=--with-path=$(shell pwd)/build/padist/lib/pkgconfig
build/qemu/build/config.status: build/qemu/.patched build/qemu/.gui-agent-copied-in $(FULL_BUILDDEPS)
mkdir -p build/qemu/build && cd build/qemu/build && ../configure \
--without-default-features \
--target-list=i386-softmmu \
--enable-xen \
--enable-xen-pci-passthrough \
--disable-werror \
--disable-sdl \
--disable-kvm \
--disable-gtk \
--disable-slirp \
--enable-pie \
--disable-docs \
--disable-vhost-net \
--disable-spice \
--disable-guest-agent \
--disable-smartcard \
--disable-vnc \
--disable-spice \
--enable-trace-backends=log \
--disable-gnutls \
--disable-nettle \
--disable-gcrypt \
--disable-vte \
--disable-curses \
--disable-cocoa \
--disable-virtfs \
--disable-brlapi \
--disable-curl \
--disable-rdma \
--disable-vde \
--disable-netmap \
--disable-linux-aio \
--disable-cap-ng \
--disable-attr \
--disable-rbd \
--disable-libiscsi \
--disable-libnfs \
--disable-usb-redir \
--disable-lzo \
--disable-snappy \
--disable-bzip2 \
--enable-seccomp \
--disable-coroutine-pool \
--disable-glusterfs \
--disable-tpm \
--disable-libssh \
--disable-numa \
--disable-qom-cast-debug \
--disable-virglrenderer \
--disable-tools \
--disable-replication \
--disable-opengl \
--disable-virglrenderer \
--disable-tcg \
--disable-crypto-afalg \
--disable-live-block-migration \
--disable-vhost-user \
--disable-vhost-crypto \
--disable-vdi \
--disable-bochs \
--disable-cloop \
--disable-dmg \
--disable-qcow1 \
--disable-parallels \
--disable-vvfat \
--disable-qed \
--disable-auth-pam \
--enable-rng-none \
${QEMU_OPTIONS} \
--cxx=/non-existent \
--extra-cflags="-DXEN_PT_LOGGING_ENABLED=1 ${QEMU_EXTRA_CFLAGS}" \
--extra-ldflags="${QEMU_EXTRA_LDFLAGS}" \
--prefix=/usr
build/qemu/build/qemu-system-i386: build/qemu/.patched build/qemu/build/config.status
$(MAKE) $(MAKE_PARALLEL) -C build/qemu/roms seavgabios-{cirrus,stdvga}
#$(MAKE) $(MAKE_PARALLEL) -C build/qemu/pc-bios/optionrom linuxboot.bin linuxboot_dma.bin
$(MAKE) $(MAKE_PARALLEL) -C build/qemu/build
strip --strip-unneeded $@
LINUX_PATCHES := $(shell $Q -l linux)
build/linux/.extracted: linux-$(LINUX_VERSION).tar
rm -rf build/linux
mkdir -p build/linux
tar -C build/linux --strip-components=1 -xf $<
touch $@
build/linux/.patched: build/linux/.extracted linux/patches/series $(LINUX_PATCHES)
[ ! -d build/linux/.patches ] || $Q -C build/linux -. pop -a
rm -rf build/linux/.patches
cp -a linux/patches build/linux/.patches
$Q -C build/linux -. push -a
touch $@
build/linux/.config: $(sort $(wildcard linux/config/[0-9][0-9]-*)) build/linux/.extracted
cd build/linux; env -u MAKEFLAGS ./scripts/kconfig/merge_config.sh -n /dev/null ../../linux/config/$(KERNEL_CONFIG)
$(VMLINUZ): build/linux/.patched build/linux/.config
$(MAKE) $(MAKE_PARALLEL) -C build/linux
helpers/vchan-socket-proxy helpers/add-fd: helpers/vchan-socket-proxy.c helpers/add-fd.c
$(MAKE) $(MAKE_PARALLEL) -C helpers
DRACUT_INSTALL=/usr/lib/dracut/dracut-install
rootfs/gen: $(DRACUT_INSTALL)
export DRACUT_INSTALL
$(ROOTFS_IMG): rootfs/gen $(STUBDOM_DISK_FILE)
env -u MAKELEVEL -u MAKEFLAGS -u MFLAGS ./$<
install: $(VMLINUZ) $(ROOTFS_IMG)
install -D -m 444 $(VMLINUZ) $(DESTDIR)$(STUBDOM_BINDIR)/$(KERNEL_NAME)
install -D -m 444 $(ROOTFS_IMG) $(DESTDIR)$(STUBDOM_BINDIR)/$(ROOTFS_NAME)
clean:
rm -rf build