-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
175 lines (144 loc) · 6.96 KB
/
Makefile
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
PROJECT ?= savm
# options: x86 arm
TOOLCHAIN_TARGET ?= arm
# options: see tool/create_builddir
GENODE_TARGET ?= foc_x86_64
ifneq (,$(findstring if13praktikum, $(shell groups)))
VAGRANT_BUILD_DIR ?= $(shell pwd)/build
else
VAGRANT_BUILD_DIR ?= /build
endif
VAGRANT_TOOLCHAIN_BUILD_DIR ?= $(VAGRANT_BUILD_DIR)/toolchain-$(TOOLCHAIN_TARGET)
VAGRANT_GENODE_BUILD_DIR ?= $(VAGRANT_BUILD_DIR)/genode-$(GENODE_TARGET)
VAGRANT_BUILD_CONF = $(VAGRANT_GENODE_BUILD_DIR)/etc/build.conf
VAGRANT_TOOLS_CONF = $(VAGRANT_GENODE_BUILD_DIR)/etc/tools.conf
JENKINS_BUILD_DIR ?= build
JENKINS_TOOLCHAIN_BUILD_DIR ?= $(JENKINS_BUILD_DIR)/toolchain-$(TOOLCHAIN_TARGET)
JENKINS_GENODE_BUILD_DIR ?= $(JENKINS_BUILD_DIR)/genode-$(GENODE_TARGET)
JENKINS_BUILD_CONF = $(JENKINS_GENODE_BUILD_DIR)/etc/build.conf
JENKINS_TOOLS_CONF = $(JENKINS_GENODE_BUILD_DIR)/etc/tools.conf
vagrant: ports build_dir
jenkins: foc jenkins_build_dir
# ================================================================
# Genode toolchain. Only needs to be done once per target (x86/arm).
toolchain:
wget https://nextcloud.os.in.tum.de/s/9idiw8BLbuwp35z/download -O toolchain
tar xfj toolchain -C .
#
# ================================================================
# ================================================================
# Download Genode external sources. Only needs to be done once per system.
ports:
./genode/tool/ports/prepare_port libc stdcxx lwip openssl zlib libmosquitto libprotobuf dde_ipxe dde_linux foc
#
# ================================================================
# ================================================================
# Genode build process. Rebuild subtargets as needed.
build_dir:
#workaround for changing target on compiled libs
rm -rf genode/contrib/libmosquitto*
rm -rf genode/controb/libprotobuf*
./genode/tool/ports/prepare_port libmosquitto libprotobuf
#end workaround
genode/tool/create_builddir $(GENODE_TARGET) BUILD_DIR=$(VAGRANT_GENODE_BUILD_DIR)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/libports\n' >> $(VAGRANT_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/dde_linux\n' >> $(VAGRANT_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/../tools/QEMU-SA-VM\n' >> $(VAGRANT_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/../ecu/autonomousParking\n' >> $(VAGRANT_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/world\n' >> $(VAGRANT_BUILD_CONF)
ifneq (,$(findstring x86_64, $(GENODE_TARGET)))
sed -i "s/QEMU_OPT/\#QEMU_OPT/" $(VAGRANT_BUILD_CONF)
printf "QEMU_OPT += -enable-kvm\n" >> $(VAGRANT_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/dde_ipxe\n' >> $(VAGRANT_BUILD_CONF)
endif
printf 'MAKE += -j4' >> $(VAGRANT_BUILD_CONF)
ifneq (,$(findstring if13praktikum, $(shell groups)))
ifneq (,$(findstring x86_64, $(GENODE_TARGET)))
echo "CROSS_DEV_PREFIX=$(shell pwd)/usr/local/genode-gcc/bin/genode-x86-" >> $(VAGRANT_TOOLS_CONF)
else
echo "CROSS_DEV_PREFIX=$(shell pwd)/usr/local/genode-gcc/bin/genode-arm-" >> $(VAGRANT_TOOLS_CONF)
endif
endif
jenkins_build_dir:
#workaround for changing target on compiled libs
rm -rf genode/contrib/libmosquitto*
rm -rf genode/controb/libprotobuf*
./genode/tool/ports/prepare_port libmosquitto libprotobuf
#end workaround
genode/tool/create_builddir $(GENODE_TARGET) BUILD_DIR=$(JENKINS_GENODE_BUILD_DIR)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/libports\n' >> $(JENKINS_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/dde_linux\n' >> $(JENKINS_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/../tools/QEMU-SA-VM\n' >> $(JENKINS_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/../ecu/autonomousParking\n' >> $(JENKINS_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/world\n' >> $(JENKINS_BUILD_CONF)
ifneq (,$(findstring x86_64, $(GENODE_TARGET)))
sed -i "s/QEMU_OPT/\#QEMU_OPT/" $(JENKINS_BUILD_CONF)
printf "QEMU_OPT += -enable-kvm\n" >> $(JENKINS_BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/dde_ipxe\n' >> $(JENKINS_BUILD_CONF)
endif
printf 'MAKE += -j\n' >> $(JENKINS_BUILD_CONF)
ifneq (,$(findstring x86_64, $(GENODE_TARGET)))
echo "CROSS_DEV_PREFIX=$(shell pwd)/usr/local/genode-gcc/bin/genode-x86-" >> $(JENKINS_TOOLS_CONF)
else
echo "CROSS_DEV_PREFIX=$(shell pwd)/usr/local/genode-gcc/bin/genode-arm-" >> $(JENKINS_TOOLS_CONF)
endif
# Delete build directory for all target systems. In some cases, subfolders in the contrib directory might be corrupted. Remove manually and re-prepare if necessary.
clean:
rm -rf $(VAGRANT_GENODE_BUILD_DIR)
jenkins_clean:
rm -rf $(JENKINS_GENODE_BUILD_DIR)
#
# ================================================================
# ================================================================
# Run Genode with an active dom0 server.
run:
$(MAKE) -C $(VAGRANT_GENODE_BUILD_DIR) run/$(PROJECT) #declare which run file to run
rm -f /var/lib/tftpboot/image.elf
rm -f /var/lib/tftpboot/modules.list
rm -rf /var/lib/tftpboot/genode
cp $(VAGRANT_GENODE_BUILD_DIR)/var/run/$(PROJECT)/image.elf /var/lib/tftpboot/
cp $(VAGRANT_GENODE_BUILD_DIR)/var/run/$(PROJECT)/modules.list /var/lib/tftpboot/
cp -R $(VAGRANT_GENODE_BUILD_DIR)/var/run/$(PROJECT)/genode /var/lib/tftpboot/
jenkins_run:
$(MAKE) -C $(JENKINS_GENODE_BUILD_DIR) run/$(PROJECT) #declare which run file to run
rm -f /var/lib/tftpboot/image.elf
rm -f /var/lib/tftpboot/modules.list
rm -rf /var/lib/tftpboot/genode
cp $(JENKINS_GENODE_BUILD_DIR)/var/run/$(PROJECT)/image.elf /var/lib/tftpboot/
cp $(JENKINS_GENODE_BUILD_DIR)/var/run/$(PROJECT)/modules.list /var/lib/tftpboot/
cp -R $(JENKINS_GENODE_BUILD_DIR)/var/run/$(PROJECT)/genode /var/lib/tftpboot/
#
# ================================================================
# ================================================================
# Requiered packages for relaunched systems
packages:
sudo apt-get update
sudo apt-get install libncurses5-dev texinfo autogen autoconf2.64 g++ libexpat1-dev flex bison gperf cmake libxml2-dev libtool zlib1g-dev libglib2.0-dev make pkg-config gawk subversion expect git libxml2-utils syslinux xsltproc yasm iasl lynx unzip qemu
#
# ================================================================
# ================================================================
# VDE setup. Do once per system session. DHCP is optional.
vde: vde-stop
@vde_switch -d -s /tmp/switch1
@sudo vde_tunctl -u $(USER) -t tap0
@sudo ip addr add 10.0.2.1/24 dev tap0
@sudo ip link set up dev tap0
@vde_plug2tap --daemon -s /tmp/switch1 tap0
vde-stop:
@-pkill vde_switch
@-sudo vde_tunctl -d tap0
@-rm -rf /tmp/switch1
dhcp: dhcp-stop
@slirpvde -d -s /tmp/switch1 -dhcp
dhcp-stop:
@-pkill slirpvde
qemu:
wget https://download.qemu.org/qemu-4.0.0.tar.xz
tar xJf qemu-4.0.0.tar.xz
cd qemu-4.0.0/ && ./configure --enable-vde --target-list=arm-softmmu,x86_64-softmmu
make -C qemu-4.0.0/ -j4
sudo make -C qemu-4.0.0/ install
# Cleanup network shenanigans.
clean-network: dhcp-stop vde-stop
#
# ================================================================