-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
executable file
·189 lines (152 loc) · 6.71 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
PROJECT ?= dom0-HW
# options: x86 arm
TOOLCHAIN_TARGET ?= arm
# options: see tool/create_builddir
GENODE_TARGET ?= focnados_panda
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 -qO- https://nextcloud.os.in.tum.de/s/9idiw8BLbuwp35z/download | tar xj -C .
#
# ================================================================
# ================================================================
# Download Genode external sources. Only needs to be done once per system.
PORTS_LST = focnados libc lwip stdcxx dde_linux
ports:
ifeq (jenkins, $(USER))
./genode/tool/ports/prepare_port -j $(PORTS_LST)
else
./genode/tool/ports/prepare_port -j4 $(PORTS_LST)
endif
#
# ================================================================
# ================================================================
# Genode build process. Rebuild subtargets as needed.
# ================================================================
# Link the genode-world repository into genode/repos/world.
world:
ln -sfn $(shell pwd)/genode-world $(shell pwd)/genode/repos/world
#
# ================================================================
CUSTOM_REPOS = $(wildcard genode-*) $(wildcard ../genode-*) toolchain-host
build_dir: world
# Create build directory
genode/tool/create_builddir $(GENODE_TARGET) BUILD_DIR=$(VAGRANT_GENODE_BUILD_DIR)
# Uncomment libports and dde_linux from etc/build.conf
for repo in libports dde_linux world ; do \
sed -i "/$$repo/s/^#REPOSITORIES/REPOSITORIES/g" $(VAGRANT_BUILD_CONF) ; \
done
# Add our custom repositories to etc/build.conf
for repo in $(CUSTOM_REPOS); do \
echo "REPOSITORIES += \$$(GENODE_DIR)/../$$repo" >> $(VAGRANT_BUILD_CONF) ; \
done
# Speedup of the build process
echo "MAKE += -j4" >> $(VAGRANT_BUILD_CONF)
# Add toolchain path to etc/specs.conf
ifneq (,$(findstring if13praktikum, $(shell groups)))
echo "CROSS_DEV_PREFIX=/var/tmp/usr/local/genode-gcc/bin/genode-arm-" >> $(VAGRANT_TOOLS_CONF)
endif
jenkins_build_dir: world
# Create build directory
genode/tool/create_builddir $(GENODE_TARGET) BUILD_DIR=$(JENKINS_GENODE_BUILD_DIR)
# Uncomment libports and dde_linux from etc/build.conf
for repo in libports dde_linux world ; do \
sed -i "/$$repo/s/^#REPOSITORIES/REPOSITORIES/g" $(JENKINS_BUILD_CONF) ; \
done
# Add our custom repositories to etc/build.conf
for repo in $(CUSTOM_REPOS); do \
echo "REPOSITORIES += \$$(GENODE_DIR)/../$$repo" >> $(JENKINS_BUILD_CONF) ; \
done
# Speedup of the build process
ifeq (jenkins, $(USER))
echo "MAKE += -j" >> $(JENKINS_BUILD_CONF)
else
echo "MAKE += -j4" >> $(JENKINS_BUILD_CONF)
endif
# Add toolchain path to etc/specs.conf
echo "CROSS_DEV_PREFIX=$(shell pwd)/usr/local/genode-gcc/bin/genode-arm-" >> $(JENKINS_TOOLS_CONF)
# 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:
$(MAKE) -C $(VAGRANT_GENODE_BUILD_DIR) cleanall
jenkins_clean:
$(MAKE) -C $(JENKINS_GENODE_BUILD_DIR) cleanall
#
# ================================================================
# ================================================================
# 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 -qq
sudo apt-get install -qq 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 tftpd-hpa isc-dhcp-server
#
# ================================================================
# ================================================================
# VDE setup. Do once per system session. DHCP is optional.
vde: vde-stop
@vde_switch -d -s /tmp/switch1 -M /tmp/mgmt
@sudo vde_tunctl -u $(USER) -t tap0
@sudo ip link set dev tap0 address 76:5e:06:6a:7e:87
@sudo ifconfig tap0 10.200.40.10 up
@vde_plug2tap --daemon -s /tmp/switch1 tap0
@sudo cp config-data/dhcpd.conf /etc/dhcp/dhcpd.conf
@sudo cp config-data/isc-dhcp-server /etc/default/isc-dhcp-server
@sudo service isc-dhcp-server start
vde-stop:
@-pkill vde_switch
@-sudo vde_tunctl -d tap0
@-rm -rf /tmp/switch1
@sudo service isc-dhcp-server stop
#Needs rework to use isc-dhcp instead
dhcp: dhcp-stop
@slirpvde -d -s /tmp/switch1 -dhcp
dhcp-stop:
@-pkill slirpvde
# Cleanup network shenanigans.
clean-network: dhcp-stop vde-stop
#
# ================================================================
# ================================================================
# Compile task for toolchain host
tasks:
for task in cond_42 cond_mod hey idle linpack namaste pi tumatmul ; do \
$(MAKE) -C $(JENKINS_GENODE_BUILD_DIR) $$task ; \
cp $(JENKINS_GENODE_BUILD_DIR)/$$task/$$task toolchain-host/host_dom0 ; \
done