xref: /linux/tools/testing/selftests/wireguard/qemu/Makefile (revision cbac924200b838cfb8d8b1415113d788089dc50b)
1# SPDX-License-Identifier: GPL-2.0
2#
3# Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4
5PWD := $(shell pwd)
6
7CHOST := $(shell gcc -dumpmachine)
8HOST_ARCH := $(firstword $(subst -, ,$(CHOST)))
9ifneq (,$(ARCH))
10CBUILD := $(subst -gcc,,$(lastword $(subst /, ,$(firstword $(wildcard $(foreach bindir,$(subst :, ,$(PATH)),$(bindir)/$(ARCH)-*-gcc))))))
11ifeq (,$(CBUILD))
12$(error The toolchain for $(ARCH) is not installed)
13endif
14else
15CBUILD := $(CHOST)
16ARCH := $(firstword $(subst -, ,$(CBUILD)))
17endif
18
19# Set these from the environment to override
20KERNEL_PATH ?= $(PWD)/../../../../..
21BUILD_PATH ?= $(PWD)/build/$(ARCH)
22DISTFILES_PATH ?= $(PWD)/distfiles
23NR_CPUS ?= 4
24
25MIRROR := https://download.wireguard.com/qemu-test/distfiles/
26
27default: qemu
28
29# variable name, tarball project name, version, tarball extension, default URI base
30define tar_download =
31$(1)_VERSION := $(3)
32$(1)_NAME := $(2)-$$($(1)_VERSION)
33$(1)_TAR := $(DISTFILES_PATH)/$$($(1)_NAME)$(4)
34$(1)_PATH := $(BUILD_PATH)/$$($(1)_NAME)
35$(call file_download,$$($(1)_NAME)$(4),$(5),$(6))
36endef
37
38define file_download =
39$(DISTFILES_PATH)/$(1):
40	mkdir -p $(DISTFILES_PATH)
41	flock -x $$@.lock -c '[ -f $$@ ] && exit 0; wget -O $$@.tmp $(MIRROR)$(1) || wget -O $$@.tmp $(2)$(1) || rm -f $$@.tmp; [ -f $$@.tmp ] || exit 1; if echo "$(3)  $$@.tmp" | sha256sum -c -; then mv $$@.tmp $$@; else rm -f $$@.tmp; exit 71; fi'
42endef
43
44$(eval $(call tar_download,MUSL,musl,1.2.0,.tar.gz,https://musl.libc.org/releases/,c6de7b191139142d3f9a7b5b702c9cae1b5ee6e7f57e582da9328629408fd4e8))
45$(eval $(call tar_download,IPERF,iperf,3.7,.tar.gz,https://downloads.es.net/pub/iperf/,d846040224317caf2f75c843d309a950a7db23f9b44b94688ccbe557d6d1710c))
46$(eval $(call tar_download,BASH,bash,5.0,.tar.gz,https://ftp.gnu.org/gnu/bash/,b4a80f2ac66170b2913efbfb9f2594f1f76c7b1afd11f799e22035d63077fb4d))
47$(eval $(call tar_download,IPROUTE2,iproute2,5.6.0,.tar.xz,https://www.kernel.org/pub/linux/utils/net/iproute2/,1b5b0e25ce6e23da7526ea1da044e814ad85ba761b10dd29c2b027c056b04692))
48$(eval $(call tar_download,IPTABLES,iptables,1.8.4,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,993a3a5490a544c2cbf2ef15cf7e7ed21af1845baf228318d5c36ef8827e157c))
49$(eval $(call tar_download,NMAP,nmap,7.80,.tar.bz2,https://nmap.org/dist/,fcfa5a0e42099e12e4bf7a68ebe6fde05553383a682e816a7ec9256ab4773faa))
50$(eval $(call tar_download,IPUTILS,iputils,s20190709,.tar.gz,https://github.com/iputils/iputils/archive/s20190709.tar.gz/#,a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a))
51$(eval $(call tar_download,WIREGUARD_TOOLS,wireguard-tools,1.0.20200206,.tar.xz,https://git.zx2c4.com/wireguard-tools/snapshot/,f5207248c6a3c3e3bfc9ab30b91c1897b00802ed861e1f9faaed873366078c64))
52
53KERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug)
54rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
55WIREGUARD_SOURCES := $(call rwildcard,$(KERNEL_PATH)/drivers/net/wireguard/,*)
56
57export CFLAGS ?= -O3 -pipe
58export LDFLAGS ?=
59export CPPFLAGS := -I$(BUILD_PATH)/include
60
61ifeq ($(HOST_ARCH),$(ARCH))
62CROSS_COMPILE_FLAG := --host=$(CHOST)
63CFLAGS += -march=native
64STRIP := strip
65else
66$(info Cross compilation: building for $(CBUILD) using $(CHOST))
67CROSS_COMPILE_FLAG := --build=$(CBUILD) --host=$(CHOST)
68export CROSS_COMPILE=$(CBUILD)-
69STRIP := $(CBUILD)-strip
70endif
71ifeq ($(ARCH),aarch64)
72QEMU_ARCH := aarch64
73KERNEL_ARCH := arm64
74KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image
75ifeq ($(HOST_ARCH),$(ARCH))
76QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
77else
78QEMU_MACHINE := -cpu cortex-a53 -machine virt
79CFLAGS += -march=armv8-a -mtune=cortex-a53
80endif
81else ifeq ($(ARCH),aarch64_be)
82QEMU_ARCH := aarch64
83KERNEL_ARCH := arm64
84KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image
85ifeq ($(HOST_ARCH),$(ARCH))
86QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
87else
88QEMU_MACHINE := -cpu cortex-a53 -machine virt
89CFLAGS += -march=armv8-a -mtune=cortex-a53
90endif
91else ifeq ($(ARCH),arm)
92QEMU_ARCH := arm
93KERNEL_ARCH := arm
94KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage
95ifeq ($(HOST_ARCH),$(ARCH))
96QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
97else
98QEMU_MACHINE := -cpu cortex-a15 -machine virt
99CFLAGS += -march=armv7-a -mtune=cortex-a15 -mabi=aapcs-linux
100endif
101else ifeq ($(ARCH),armeb)
102QEMU_ARCH := arm
103KERNEL_ARCH := arm
104KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage
105ifeq ($(HOST_ARCH),$(ARCH))
106QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
107else
108QEMU_MACHINE := -cpu cortex-a15 -machine virt
109CFLAGS += -march=armv7-a -mabi=aapcs-linux # We don't pass -mtune=cortex-a15 due to a compiler bug on big endian.
110LDFLAGS += -Wl,--be8
111endif
112else ifeq ($(ARCH),x86_64)
113QEMU_ARCH := x86_64
114KERNEL_ARCH := x86_64
115KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage
116ifeq ($(HOST_ARCH),$(ARCH))
117QEMU_MACHINE := -cpu host -machine q35,accel=kvm
118else
119QEMU_MACHINE := -cpu Skylake-Server -machine q35
120CFLAGS += -march=skylake-avx512
121endif
122else ifeq ($(ARCH),i686)
123QEMU_ARCH := i386
124KERNEL_ARCH := x86
125KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage
126ifeq ($(subst x86_64,i686,$(HOST_ARCH)),$(ARCH))
127QEMU_MACHINE := -cpu host -machine q35,accel=kvm
128else
129QEMU_MACHINE := -cpu coreduo -machine q35
130CFLAGS += -march=prescott
131endif
132else ifeq ($(ARCH),mips64)
133QEMU_ARCH := mips64
134KERNEL_ARCH := mips
135KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
136ifeq ($(HOST_ARCH),$(ARCH))
137QEMU_MACHINE := -cpu host -machine malta,accel=kvm
138CFLAGS += -EB
139else
140QEMU_MACHINE := -cpu MIPS64R2-generic -machine malta -smp 1
141CFLAGS += -march=mips64r2 -EB
142endif
143else ifeq ($(ARCH),mips64el)
144QEMU_ARCH := mips64el
145KERNEL_ARCH := mips
146KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
147ifeq ($(HOST_ARCH),$(ARCH))
148QEMU_MACHINE := -cpu host -machine malta,accel=kvm
149CFLAGS += -EL
150else
151QEMU_MACHINE := -cpu MIPS64R2-generic -machine malta -smp 1
152CFLAGS += -march=mips64r2 -EL
153endif
154else ifeq ($(ARCH),mips)
155QEMU_ARCH := mips
156KERNEL_ARCH := mips
157KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
158ifeq ($(HOST_ARCH),$(ARCH))
159QEMU_MACHINE := -cpu host -machine malta,accel=kvm
160CFLAGS += -EB
161else
162QEMU_MACHINE := -cpu 24Kf -machine malta -smp 1
163CFLAGS += -march=mips32r2 -EB
164endif
165else ifeq ($(ARCH),mipsel)
166QEMU_ARCH := mipsel
167KERNEL_ARCH := mips
168KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
169ifeq ($(HOST_ARCH),$(ARCH))
170QEMU_MACHINE := -cpu host -machine malta,accel=kvm
171CFLAGS += -EL
172else
173QEMU_MACHINE := -cpu 24Kf -machine malta -smp 1
174CFLAGS += -march=mips32r2 -EL
175endif
176else ifeq ($(ARCH),powerpc64le)
177QEMU_ARCH := ppc64
178KERNEL_ARCH := powerpc
179KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
180ifeq ($(HOST_ARCH),$(ARCH))
181QEMU_MACHINE := -cpu host,accel=kvm -machine pseries
182else
183QEMU_MACHINE := -machine pseries
184endif
185CFLAGS += -mcpu=powerpc64le -mlong-double-64
186else ifeq ($(ARCH),powerpc)
187QEMU_ARCH := ppc
188KERNEL_ARCH := powerpc
189KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/powerpc/boot/uImage
190ifeq ($(HOST_ARCH),$(ARCH))
191QEMU_MACHINE := -cpu host,accel=kvm -machine ppce500
192else
193QEMU_MACHINE := -machine ppce500
194endif
195CFLAGS += -mcpu=powerpc -mlong-double-64 -msecure-plt
196else ifeq ($(ARCH),m68k)
197QEMU_ARCH := m68k
198KERNEL_ARCH := m68k
199KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
200KERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/m68k.config)
201ifeq ($(HOST_ARCH),$(ARCH))
202QEMU_MACHINE := -cpu host,accel=kvm -machine q800 -smp 1 -append $(KERNEL_CMDLINE)
203else
204QEMU_MACHINE := -machine q800 -smp 1 -append $(KERNEL_CMDLINE)
205endif
206else
207$(error I only build: x86_64, i686, arm, armeb, aarch64, aarch64_be, mips, mipsel, mips64, mips64el, powerpc64le, powerpc, m68k)
208endif
209
210REAL_CC := $(CBUILD)-gcc
211MUSL_CC := $(BUILD_PATH)/musl-gcc
212export CC := $(MUSL_CC)
213USERSPACE_DEPS := $(MUSL_CC) $(BUILD_PATH)/include/.installed $(BUILD_PATH)/include/linux/.installed
214
215build: $(KERNEL_BZIMAGE)
216qemu: $(KERNEL_BZIMAGE)
217	rm -f $(BUILD_PATH)/result
218	timeout --foreground 20m qemu-system-$(QEMU_ARCH) \
219		-nodefaults \
220		-nographic \
221		-smp $(NR_CPUS) \
222		$(QEMU_MACHINE) \
223		-m $$(grep -q CONFIG_DEBUG_KMEMLEAK=y $(KERNEL_BUILD_PATH)/.config && echo 1G || echo 256M) \
224		-serial stdio \
225		-serial file:$(BUILD_PATH)/result \
226		-no-reboot \
227		-monitor none \
228		-kernel $<
229	grep -Fq success $(BUILD_PATH)/result
230
231$(BUILD_PATH)/init-cpio-spec.txt:
232	mkdir -p $(BUILD_PATH)
233	echo "file /init $(BUILD_PATH)/init 755 0 0" > $@
234	echo "file /init.sh $(PWD)/../netns.sh 755 0 0" >> $@
235	echo "dir /dev 755 0 0" >> $@
236	echo "nod /dev/console 644 0 0 c 5 1" >> $@
237	echo "dir /bin 755 0 0" >> $@
238	echo "file /bin/iperf3 $(IPERF_PATH)/src/iperf3 755 0 0" >> $@
239	echo "file /bin/wg $(WIREGUARD_TOOLS_PATH)/src/wg 755 0 0" >> $@
240	echo "file /bin/bash $(BASH_PATH)/bash 755 0 0" >> $@
241	echo "file /bin/ip $(IPROUTE2_PATH)/ip/ip 755 0 0" >> $@
242	echo "file /bin/ss $(IPROUTE2_PATH)/misc/ss 755 0 0" >> $@
243	echo "file /bin/ping $(IPUTILS_PATH)/ping 755 0 0" >> $@
244	echo "file /bin/ncat $(NMAP_PATH)/ncat/ncat 755 0 0" >> $@
245	echo "file /bin/xtables-legacy-multi $(IPTABLES_PATH)/iptables/xtables-legacy-multi 755 0 0" >> $@
246	echo "slink /bin/iptables xtables-legacy-multi 777 0 0" >> $@
247	echo "slink /bin/ping6 ping 777 0 0" >> $@
248	echo "dir /lib 755 0 0" >> $@
249	echo "file /lib/libc.so $(MUSL_PATH)/lib/libc.so 755 0 0" >> $@
250	echo "slink /lib/ld-linux.so.1 libc.so 777 0 0" >> $@
251
252$(KERNEL_BUILD_PATH)/.config: kernel.config arch/$(ARCH).config
253	mkdir -p $(KERNEL_BUILD_PATH)
254	cp kernel.config $(KERNEL_BUILD_PATH)/minimal.config
255	printf 'CONFIG_NR_CPUS=$(NR_CPUS)\nCONFIG_INITRAMFS_SOURCE="$(BUILD_PATH)/init-cpio-spec.txt"\n' >> $(KERNEL_BUILD_PATH)/minimal.config
256	cat arch/$(ARCH).config >> $(KERNEL_BUILD_PATH)/minimal.config
257	$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) allnoconfig
258	cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config $(KERNEL_BUILD_PATH)/minimal.config
259	$(if $(findstring yes,$(DEBUG_KERNEL)),cp debug.config $(KERNEL_BUILD_PATH) && cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config debug.config,)
260
261$(KERNEL_BZIMAGE): $(KERNEL_BUILD_PATH)/.config $(BUILD_PATH)/init-cpio-spec.txt $(MUSL_PATH)/lib/libc.so $(IPERF_PATH)/src/iperf3 $(IPUTILS_PATH)/ping $(BASH_PATH)/bash $(IPROUTE2_PATH)/misc/ss $(IPROUTE2_PATH)/ip/ip $(IPTABLES_PATH)/iptables/xtables-legacy-multi $(NMAP_PATH)/ncat/ncat $(WIREGUARD_TOOLS_PATH)/src/wg $(BUILD_PATH)/init ../netns.sh $(WIREGUARD_SOURCES)
262	$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
263
264$(BUILD_PATH)/include/linux/.installed: | $(KERNEL_BUILD_PATH)/.config
265	$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) INSTALL_HDR_PATH=$(BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) headers_install
266	touch $@
267
268$(MUSL_PATH)/lib/libc.so: $(MUSL_TAR)
269	mkdir -p $(BUILD_PATH)
270	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
271	cd $(MUSL_PATH) && CC=$(REAL_CC) ./configure --prefix=/ --disable-static --build=$(CBUILD)
272	$(MAKE) -C $(MUSL_PATH)
273	$(STRIP) -s $@
274
275$(BUILD_PATH)/include/.installed: $(MUSL_PATH)/lib/libc.so
276	$(MAKE) -C $(MUSL_PATH) DESTDIR=$(BUILD_PATH) install-headers
277	touch $@
278
279$(MUSL_CC): $(MUSL_PATH)/lib/libc.so
280	sh $(MUSL_PATH)/tools/musl-gcc.specs.sh $(BUILD_PATH)/include $(MUSL_PATH)/lib /lib/ld-linux.so.1 > $(BUILD_PATH)/musl-gcc.specs
281	printf '#!/bin/sh\nexec "$(REAL_CC)" --specs="$(BUILD_PATH)/musl-gcc.specs" "$$@"\n' > $(BUILD_PATH)/musl-gcc
282	chmod +x $(BUILD_PATH)/musl-gcc
283
284$(IPERF_PATH)/.installed: $(IPERF_TAR)
285	mkdir -p $(BUILD_PATH)
286	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
287	sed -i '1s/^/#include <stdint.h>/' $(IPERF_PATH)/src/cjson.h $(IPERF_PATH)/src/timer.h
288	sed -i -r 's/-p?g//g' $(IPERF_PATH)/src/Makefile*
289	touch $@
290
291$(IPERF_PATH)/src/iperf3: | $(IPERF_PATH)/.installed $(USERSPACE_DEPS)
292	cd $(IPERF_PATH) && CFLAGS="$(CFLAGS) -D_GNU_SOURCE" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --with-openssl=no
293	$(MAKE) -C $(IPERF_PATH)
294	$(STRIP) -s $@
295
296$(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR)
297	mkdir -p $(BUILD_PATH)
298	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
299	touch $@
300
301$(WIREGUARD_TOOLS_PATH)/src/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(USERSPACE_DEPS)
302	$(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src wg
303	$(STRIP) -s $@
304
305$(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS)
306	mkdir -p $(BUILD_PATH)
307	$(MUSL_CC) -o $@ $(CFLAGS) $(LDFLAGS) -std=gnu11 $<
308	$(STRIP) -s $@
309
310$(IPUTILS_PATH)/.installed: $(IPUTILS_TAR)
311	mkdir -p $(BUILD_PATH)
312	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
313	touch $@
314
315$(IPUTILS_PATH)/ping: | $(IPUTILS_PATH)/.installed $(USERSPACE_DEPS)
316	sed -i /atexit/d $(IPUTILS_PATH)/ping.c
317	cd $(IPUTILS_PATH) && $(CC) $(CFLAGS) -std=c99 -o $@ ping.c ping_common.c ping6_common.c iputils_common.c -D_GNU_SOURCE -D'IPUTILS_VERSION(f)=f' -lresolv $(LDFLAGS)
318	$(STRIP) -s $@
319
320$(BASH_PATH)/.installed: $(BASH_TAR)
321	mkdir -p $(BUILD_PATH)
322	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
323	touch $@
324
325$(BASH_PATH)/bash: | $(BASH_PATH)/.installed $(USERSPACE_DEPS)
326	cd $(BASH_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --without-bash-malloc --disable-debugger --disable-help-builtin --disable-history --disable-multibyte --disable-progcomp --disable-readline --disable-mem-scramble
327	$(MAKE) -C $(BASH_PATH)
328	$(STRIP) -s $@
329
330$(IPROUTE2_PATH)/.installed: $(IPROUTE2_TAR)
331	mkdir -p $(BUILD_PATH)
332	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
333	printf 'CC:=$(CC)\nPKG_CONFIG:=pkg-config\nTC_CONFIG_XT:=n\nTC_CONFIG_ATM:=n\nTC_CONFIG_IPSET:=n\nIP_CONFIG_SETNS:=y\nHAVE_ELF:=n\nHAVE_MNL:=n\nHAVE_BERKELEY_DB:=n\nHAVE_LATEX:=n\nHAVE_PDFLATEX:=n\nCFLAGS+=-DHAVE_SETNS\n' > $(IPROUTE2_PATH)/config.mk
334	printf 'lib: snapshot\n\t$$(MAKE) -C lib\nip/ip: lib\n\t$$(MAKE) -C ip ip\nmisc/ss: lib\n\t$$(MAKE) -C misc ss\n' >> $(IPROUTE2_PATH)/Makefile
335	touch $@
336
337$(IPROUTE2_PATH)/ip/ip: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS)
338	$(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ ip/ip
339	$(STRIP) -s $@
340
341$(IPROUTE2_PATH)/misc/ss: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS)
342	$(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ misc/ss
343	$(STRIP) -s $@
344
345$(IPTABLES_PATH)/.installed: $(IPTABLES_TAR)
346	mkdir -p $(BUILD_PATH)
347	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
348	sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure
349	touch $@
350
351$(IPTABLES_PATH)/iptables/xtables-legacy-multi: | $(IPTABLES_PATH)/.installed $(USERSPACE_DEPS)
352	cd $(IPTABLES_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --disable-nftables --disable-bpf-compiler --disable-nfsynproxy --disable-libipq --disable-connlabel --with-kernel=$(BUILD_PATH)/include
353	$(MAKE) -C $(IPTABLES_PATH)
354	$(STRIP) -s $@
355
356$(NMAP_PATH)/.installed: $(NMAP_TAR)
357	mkdir -p $(BUILD_PATH)
358	flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
359	touch $@
360
361$(NMAP_PATH)/ncat/ncat: | $(NMAP_PATH)/.installed $(USERSPACE_DEPS)
362	cd $(NMAP_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --without-ndiff --without-zenmap --without-nping --with-libpcap=included --with-libpcre=included --with-libdnet=included --without-liblua --with-liblinear=included --without-nmap-update --without-openssl --with-pcap=linux --without-libssh
363	$(MAKE) -C $(NMAP_PATH)/libpcap
364	$(MAKE) -C $(NMAP_PATH)/ncat
365	$(STRIP) -s $@
366
367clean:
368	rm -rf $(BUILD_PATH)
369
370distclean: clean
371	rm -rf $(DISTFILES_PATH)
372
373menuconfig: $(KERNEL_BUILD_PATH)/.config
374	$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) menuconfig
375
376.PHONY: qemu build clean distclean menuconfig
377.DELETE_ON_ERROR:
378