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 7# Set these from the environment to override 8KERNEL_PATH ?= $(PWD)/../../../../.. 9BUILD_PATH ?= $(PWD)/build/$(ARCH) 10DISTFILES_PATH ?= $(PWD)/distfiles 11NR_CPUS ?= 4 12ARCH ?= 13CBUILD := $(shell gcc -dumpmachine) 14HOST_ARCH := $(firstword $(subst -, ,$(CBUILD))) 15ifeq ($(ARCH),) 16ARCH := $(HOST_ARCH) 17endif 18 19MIRROR := https://download.wireguard.com/qemu-test/distfiles/ 20 21KERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug) 22rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) 23WIREGUARD_SOURCES := $(call rwildcard,$(KERNEL_PATH)/drivers/net/wireguard/,*) 24 25default: qemu 26 27# variable name, tarball project name, version, tarball extension, default URI base 28define tar_download = 29$(1)_VERSION := $(3) 30$(1)_NAME := $(2)-$$($(1)_VERSION) 31$(1)_TAR := $(DISTFILES_PATH)/$$($(1)_NAME)$(4) 32$(1)_PATH := $(BUILD_PATH)/$$($(1)_NAME) 33$(call file_download,$$($(1)_NAME)$(4),$(5),$(6)) 34endef 35 36define file_download = 37$(DISTFILES_PATH)/$(1): | $(4) 38 mkdir -p $(DISTFILES_PATH) 39 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 ([ -n "$(4)" ] && sed -n "s#^\([a-f0-9]\{64\}\) \($(1)\)\$$$$#\1 $(DISTFILES_PATH)/\2.tmp#p" "$(4)" || echo "$(3) $$@.tmp") | sha256sum -c -; then mv $$@.tmp $$@; else rm -f $$@.tmp; exit 71; fi' 40endef 41 42$(eval $(call tar_download,IPERF,iperf,3.11,.tar.gz,https://downloads.es.net/pub/iperf/,de8cb409fad61a0574f4cb07eb19ce1159707403ac2dc01b5d175e91240b7e5f)) 43$(eval $(call tar_download,BASH,bash,5.1.16,.tar.gz,https://ftp.gnu.org/gnu/bash/,5bac17218d3911834520dad13cd1f85ab944e1c09ae1aba55906be1f8192f558)) 44$(eval $(call tar_download,IPROUTE2,iproute2,5.17.0,.tar.gz,https://www.kernel.org/pub/linux/utils/net/iproute2/,bda331d5c4606138892f23a565d78fca18919b4d508a0b7ca8391c2da2db68b9)) 45$(eval $(call tar_download,IPTABLES,iptables,1.8.7,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,c109c96bb04998cd44156622d36f8e04b140701ec60531a10668cfdff5e8d8f0)) 46$(eval $(call tar_download,NMAP,nmap,7.92,.tgz,https://nmap.org/dist/,064183ea642dc4c12b1ab3b5358ce1cef7d2e7e11ffa2849f16d339f5b717117)) 47$(eval $(call tar_download,IPUTILS,iputils,s20190709,.tar.gz,https://github.com/iputils/iputils/archive/s20190709.tar.gz/#,a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a)) 48$(eval $(call tar_download,WIREGUARD_TOOLS,wireguard-tools,1.0.20210914,.tar.xz,https://git.zx2c4.com/wireguard-tools/snapshot/,97ff31489217bb265b7ae850d3d0f335ab07d2652ba1feec88b734bc96bd05ac)) 49 50export CFLAGS := -O3 -pipe 51ifeq ($(HOST_ARCH),$(ARCH)) 52CFLAGS += -march=native 53endif 54export LDFLAGS := 55export CPPFLAGS := 56 57QEMU_VPORT_RESULT := 58ifeq ($(ARCH),aarch64) 59CHOST := aarch64-linux-musl 60QEMU_ARCH := aarch64 61KERNEL_ARCH := arm64 62KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image 63QEMU_VPORT_RESULT := virtio-serial-device 64ifeq ($(HOST_ARCH),$(ARCH)) 65QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 66else 67QEMU_MACHINE := -cpu cortex-a53 -machine virt 68CFLAGS += -march=armv8-a -mtune=cortex-a53 69endif 70else ifeq ($(ARCH),aarch64_be) 71CHOST := aarch64_be-linux-musl 72QEMU_ARCH := aarch64 73KERNEL_ARCH := arm64 74KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image 75QEMU_VPORT_RESULT := virtio-serial-device 76ifeq ($(HOST_ARCH),$(ARCH)) 77QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 78else 79QEMU_MACHINE := -cpu cortex-a53 -machine virt 80CFLAGS += -march=armv8-a -mtune=cortex-a53 81endif 82else ifeq ($(ARCH),arm) 83CHOST := arm-linux-musleabi 84QEMU_ARCH := arm 85KERNEL_ARCH := arm 86KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage 87QEMU_VPORT_RESULT := virtio-serial-device 88ifeq ($(HOST_ARCH),$(ARCH)) 89QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 90else 91QEMU_MACHINE := -cpu cortex-a15 -machine virt 92CFLAGS += -march=armv7-a -mtune=cortex-a15 -mabi=aapcs-linux 93endif 94else ifeq ($(ARCH),armeb) 95CHOST := armeb-linux-musleabi 96QEMU_ARCH := arm 97KERNEL_ARCH := arm 98KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage 99QEMU_VPORT_RESULT := virtio-serial-device 100ifeq ($(HOST_ARCH),$(ARCH)) 101QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 102else 103QEMU_MACHINE := -cpu cortex-a15 -machine virt 104CFLAGS += -march=armv7-a -mabi=aapcs-linux # We don't pass -mtune=cortex-a15 due to a compiler bug on big endian. 105LDFLAGS += -Wl,--be8 106endif 107else ifeq ($(ARCH),x86_64) 108CHOST := x86_64-linux-musl 109QEMU_ARCH := x86_64 110KERNEL_ARCH := x86_64 111KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage 112ifeq ($(HOST_ARCH),$(ARCH)) 113QEMU_MACHINE := -cpu host -machine q35,accel=kvm 114else 115QEMU_MACHINE := -cpu Skylake-Server -machine q35 116CFLAGS += -march=skylake-avx512 117endif 118else ifeq ($(ARCH),i686) 119CHOST := i686-linux-musl 120QEMU_ARCH := i386 121KERNEL_ARCH := x86 122KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage 123ifeq ($(subst x86_64,i686,$(HOST_ARCH)),$(ARCH)) 124QEMU_MACHINE := -cpu host -machine q35,accel=kvm 125else 126QEMU_MACHINE := -cpu coreduo -machine q35 127CFLAGS += -march=prescott 128endif 129else ifeq ($(ARCH),mips64) 130CHOST := mips64-linux-musl 131QEMU_ARCH := mips64 132KERNEL_ARCH := mips 133KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 134ifeq ($(HOST_ARCH),$(ARCH)) 135QEMU_MACHINE := -cpu host -machine malta,accel=kvm 136CFLAGS += -EB 137else 138QEMU_MACHINE := -cpu MIPS64R2-generic -machine malta -smp 1 139CFLAGS += -march=mips64r2 -EB 140endif 141else ifeq ($(ARCH),mips64el) 142CHOST := mips64el-linux-musl 143QEMU_ARCH := mips64el 144KERNEL_ARCH := mips 145KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 146ifeq ($(HOST_ARCH),$(ARCH)) 147QEMU_MACHINE := -cpu host -machine malta,accel=kvm 148CFLAGS += -EL 149else 150QEMU_MACHINE := -cpu MIPS64R2-generic -machine malta -smp 1 151CFLAGS += -march=mips64r2 -EL 152endif 153else ifeq ($(ARCH),mips) 154CHOST := mips-linux-musl 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) 166CHOST := mipsel-linux-musl 167QEMU_ARCH := mipsel 168KERNEL_ARCH := mips 169KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 170ifeq ($(HOST_ARCH),$(ARCH)) 171QEMU_MACHINE := -cpu host -machine malta,accel=kvm 172CFLAGS += -EL 173else 174QEMU_MACHINE := -cpu 24Kf -machine malta -smp 1 175CFLAGS += -march=mips32r2 -EL 176endif 177else ifeq ($(ARCH),powerpc64) 178CHOST := powerpc64-linux-musl 179QEMU_ARCH := ppc64 180KERNEL_ARCH := powerpc 181KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 182ifeq ($(HOST_ARCH),$(ARCH)) 183QEMU_MACHINE := -cpu host,accel=kvm -machine pseries 184else 185QEMU_MACHINE := -machine pseries 186endif 187else ifeq ($(ARCH),powerpc64le) 188CHOST := powerpc64le-linux-musl 189QEMU_ARCH := ppc64 190KERNEL_ARCH := powerpc 191KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 192ifeq ($(HOST_ARCH),$(ARCH)) 193QEMU_MACHINE := -cpu host,accel=kvm -machine pseries 194else 195QEMU_MACHINE := -machine pseries 196endif 197else ifeq ($(ARCH),powerpc) 198CHOST := powerpc-linux-musl 199QEMU_ARCH := ppc 200KERNEL_ARCH := powerpc 201KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/powerpc/boot/uImage 202ifeq ($(HOST_ARCH),$(ARCH)) 203QEMU_MACHINE := -cpu host,accel=kvm -machine ppce500 204else 205QEMU_MACHINE := -machine ppce500 206endif 207else ifeq ($(ARCH),m68k) 208CHOST := m68k-linux-musl 209QEMU_ARCH := m68k 210KERNEL_ARCH := m68k 211KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 212KERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/m68k.config) 213ifeq ($(HOST_ARCH),$(ARCH)) 214QEMU_MACHINE := -cpu host,accel=kvm -machine q800 -append $(KERNEL_CMDLINE) 215else 216QEMU_MACHINE := -machine q800 -smp 1 -append $(KERNEL_CMDLINE) 217endif 218else ifeq ($(ARCH),riscv64) 219CHOST := riscv64-linux-musl 220QEMU_ARCH := riscv64 221KERNEL_ARCH := riscv 222KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/riscv/boot/Image 223QEMU_VPORT_RESULT := virtio-serial-device 224ifeq ($(HOST_ARCH),$(ARCH)) 225QEMU_MACHINE := -cpu host,accel=kvm -machine virt 226else 227QEMU_MACHINE := -cpu rv64 -machine virt 228endif 229else ifeq ($(ARCH),riscv32) 230CHOST := riscv32-linux-musl 231QEMU_ARCH := riscv32 232KERNEL_ARCH := riscv 233KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/riscv/boot/Image 234QEMU_VPORT_RESULT := virtio-serial-device 235ifeq ($(HOST_ARCH),$(ARCH)) 236QEMU_MACHINE := -cpu host,accel=kvm -machine virt 237else 238QEMU_MACHINE := -cpu rv32 -machine virt 239endif 240else ifeq ($(ARCH),s390x) 241CHOST := s390x-linux-musl 242QEMU_ARCH := s390x 243KERNEL_ARCH := s390 244KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/s390/boot/bzImage 245KERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/s390x.config) 246QEMU_VPORT_RESULT := virtio-serial-ccw 247ifeq ($(HOST_ARCH),$(ARCH)) 248QEMU_MACHINE := -cpu host,accel=kvm -machine s390-ccw-virtio -append $(KERNEL_CMDLINE) 249else 250QEMU_MACHINE := -machine s390-ccw-virtio -append $(KERNEL_CMDLINE) 251endif 252else 253$(error I only build: x86_64, i686, arm, armeb, aarch64, aarch64_be, mips, mipsel, mips64, mips64el, powerpc64, powerpc64le, powerpc, m68k, riscv64, riscv32, s390x) 254endif 255 256TOOLCHAIN_FILENAME := $(CHOST)-cross.tgz 257TOOLCHAIN_TAR := $(DISTFILES_PATH)/$(TOOLCHAIN_FILENAME) 258TOOLCHAIN_PATH := $(BUILD_PATH)/$(CHOST)-cross 259TOOLCHAIN_DIR := https://download.wireguard.com/qemu-test/toolchains/20211123/ 260$(eval $(call file_download,toolchain-sha256sums-20211123,$(TOOLCHAIN_DIR)SHA256SUMS#,83da033fd8c798df476c21d9612da2dfb896ec62fbed4ceec5eefc0e56b3f0c8)) 261$(eval $(call file_download,$(TOOLCHAIN_FILENAME),$(TOOLCHAIN_DIR),,$(DISTFILES_PATH)/toolchain-sha256sums-20211123)) 262 263STRIP := $(CHOST)-strip 264CROSS_COMPILE_FLAG := --build=$(CBUILD) --host=$(CHOST) 265$(info Building for $(CHOST) using $(CBUILD)) 266export CROSS_COMPILE := $(CHOST)- 267export PATH := $(TOOLCHAIN_PATH)/bin:$(PATH) 268export CC := $(CHOST)-gcc 269CCACHE_PATH := $(shell which ccache 2>/dev/null) 270ifneq ($(CCACHE_PATH),) 271export KBUILD_BUILD_TIMESTAMP := Fri Jun 5 15:58:00 CEST 2015 272export PATH := $(TOOLCHAIN_PATH)/bin/ccache:$(PATH) 273export CCACHE_SLOPPINESS := file_macro,time_macros 274export CCACHE_DIR ?= $(PWD)/ccache 275endif 276 277USERSPACE_DEPS := $(TOOLCHAIN_PATH)/.installed $(TOOLCHAIN_PATH)/$(CHOST)/include/linux/.installed 278 279comma := , 280build: $(KERNEL_BZIMAGE) 281qemu: $(KERNEL_BZIMAGE) 282 rm -f $(BUILD_PATH)/result 283 timeout --foreground 20m qemu-system-$(QEMU_ARCH) \ 284 -nodefaults \ 285 -nographic \ 286 -smp $(NR_CPUS) \ 287 $(QEMU_MACHINE) \ 288 -m $$(grep -q CONFIG_DEBUG_KMEMLEAK=y $(KERNEL_BUILD_PATH)/.config && echo 1G || echo 256M) \ 289 -serial stdio \ 290 -chardev file,path=$(BUILD_PATH)/result,id=result \ 291 $(if $(QEMU_VPORT_RESULT),-device $(QEMU_VPORT_RESULT) -device virtserialport$(comma)chardev=result,-serial chardev:result) \ 292 -no-reboot \ 293 -monitor none \ 294 -kernel $< 295 grep -Fq success $(BUILD_PATH)/result 296 297$(BUILD_PATH)/init-cpio-spec.txt: $(TOOLCHAIN_PATH)/.installed $(BUILD_PATH)/init 298 mkdir -p $(BUILD_PATH) 299 echo "file /init $(BUILD_PATH)/init 755 0 0" > $@ 300 echo "file /init.sh $(PWD)/../netns.sh 755 0 0" >> $@ 301 echo "dir /dev 755 0 0" >> $@ 302 echo "nod /dev/console 644 0 0 c 5 1" >> $@ 303 echo "dir /bin 755 0 0" >> $@ 304 echo "file /bin/iperf3 $(IPERF_PATH)/src/iperf3 755 0 0" >> $@ 305 echo "file /bin/wg $(WIREGUARD_TOOLS_PATH)/src/wg 755 0 0" >> $@ 306 echo "file /bin/bash $(BASH_PATH)/bash 755 0 0" >> $@ 307 echo "file /bin/ip $(IPROUTE2_PATH)/ip/ip 755 0 0" >> $@ 308 echo "file /bin/ss $(IPROUTE2_PATH)/misc/ss 755 0 0" >> $@ 309 echo "file /bin/ping $(IPUTILS_PATH)/ping 755 0 0" >> $@ 310 echo "file /bin/ncat $(NMAP_PATH)/ncat/ncat 755 0 0" >> $@ 311 echo "file /bin/xtables-legacy-multi $(IPTABLES_PATH)/iptables/xtables-legacy-multi 755 0 0" >> $@ 312 echo "slink /bin/iptables xtables-legacy-multi 777 0 0" >> $@ 313 echo "slink /bin/ping6 ping 777 0 0" >> $@ 314 echo "dir /lib 755 0 0" >> $@ 315 echo "file /lib/libc.so $(TOOLCHAIN_PATH)/$(CHOST)/lib/libc.so 755 0 0" >> $@ 316 echo "slink $$($(CHOST)-readelf -p .interp '$(BUILD_PATH)/init'| grep -o '/lib/.*') libc.so 777 0 0" >> $@ 317 318$(KERNEL_BUILD_PATH)/.config: $(TOOLCHAIN_PATH)/.installed kernel.config arch/$(ARCH).config 319 mkdir -p $(KERNEL_BUILD_PATH) 320 cp kernel.config $(KERNEL_BUILD_PATH)/minimal.config 321 printf 'CONFIG_NR_CPUS=$(NR_CPUS)\nCONFIG_INITRAMFS_SOURCE="$(BUILD_PATH)/init-cpio-spec.txt"\n' >> $(KERNEL_BUILD_PATH)/minimal.config 322 cat arch/$(ARCH).config >> $(KERNEL_BUILD_PATH)/minimal.config 323 $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) allnoconfig 324 cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config $(KERNEL_BUILD_PATH)/minimal.config 325 $(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,) 326 327$(KERNEL_BZIMAGE): $(TOOLCHAIN_PATH)/.installed $(KERNEL_BUILD_PATH)/.config $(BUILD_PATH)/init-cpio-spec.txt $(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) 328 $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) 329 330$(TOOLCHAIN_PATH)/$(CHOST)/include/linux/.installed: | $(KERNEL_BUILD_PATH)/.config $(TOOLCHAIN_PATH)/.installed 331 rm -rf $(TOOLCHAIN_PATH)/$(CHOST)/include/linux 332 $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) INSTALL_HDR_PATH=$(TOOLCHAIN_PATH)/$(CHOST) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) headers_install 333 touch $@ 334 335$(TOOLCHAIN_PATH)/.installed: $(TOOLCHAIN_TAR) 336 mkdir -p $(BUILD_PATH) 337 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 338 $(STRIP) -s $(TOOLCHAIN_PATH)/$(CHOST)/lib/libc.so 339ifneq ($(CCACHE_PATH),) 340 mkdir -p $(TOOLCHAIN_PATH)/bin/ccache 341 ln -s $(CCACHE_PATH) $(TOOLCHAIN_PATH)/bin/ccache/$(CC) 342endif 343 touch $@ 344 345$(IPERF_PATH)/.installed: $(IPERF_TAR) 346 mkdir -p $(BUILD_PATH) 347 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 348 sed -i '1s/^/#include <stdint.h>/' $(IPERF_PATH)/src/cjson.h $(IPERF_PATH)/src/timer.h 349 sed -i -r 's/-p?g//g' $(IPERF_PATH)/src/Makefile* 350 touch $@ 351 352$(IPERF_PATH)/src/iperf3: | $(IPERF_PATH)/.installed $(USERSPACE_DEPS) 353 cd $(IPERF_PATH) && autoreconf -fi 354 cd $(IPERF_PATH) && CFLAGS="$(CFLAGS) -D_GNU_SOURCE" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --with-openssl=no 355 $(MAKE) -C $(IPERF_PATH) 356 $(STRIP) -s $@ 357 358$(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR) 359 mkdir -p $(BUILD_PATH) 360 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 361 touch $@ 362 363$(WIREGUARD_TOOLS_PATH)/src/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(USERSPACE_DEPS) 364 $(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src wg 365 $(STRIP) -s $@ 366 367$(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS) 368 mkdir -p $(BUILD_PATH) 369 $(CC) -o $@ $(CFLAGS) $(LDFLAGS) -std=gnu11 $< 370 $(STRIP) -s $@ 371 372$(IPUTILS_PATH)/.installed: $(IPUTILS_TAR) 373 mkdir -p $(BUILD_PATH) 374 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 375 touch $@ 376 377$(IPUTILS_PATH)/ping: | $(IPUTILS_PATH)/.installed $(USERSPACE_DEPS) 378 sed -i /atexit/d $(IPUTILS_PATH)/ping.c 379 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) 380 $(STRIP) -s $@ 381 382$(BASH_PATH)/.installed: $(BASH_TAR) 383 mkdir -p $(BUILD_PATH) 384 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 385 touch $@ 386 387$(BASH_PATH)/bash: | $(BASH_PATH)/.installed $(USERSPACE_DEPS) 388 cd $(BASH_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --without-bash-malloc --disable-debugger --disable-help-builtin --disable-history --disable-progcomp --disable-readline --disable-mem-scramble 389 $(MAKE) -C $(BASH_PATH) 390 $(STRIP) -s $@ 391 392$(IPROUTE2_PATH)/.installed: $(IPROUTE2_TAR) 393 mkdir -p $(BUILD_PATH) 394 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 395 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 -DHAVE_HANDLE_AT\n' > $(IPROUTE2_PATH)/config.mk 396 printf 'libutil.a.done:\n\tflock -x $$@.lock $$(MAKE) -C lib\n\ttouch $$@\nip/ip: libutil.a.done\n\t$$(MAKE) -C ip ip\nmisc/ss: libutil.a.done\n\t$$(MAKE) -C misc ss\n' >> $(IPROUTE2_PATH)/Makefile 397 touch $@ 398 399$(IPROUTE2_PATH)/ip/ip: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS) 400 $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ ip/ip 401 $(STRIP) -s $@ 402 403$(IPROUTE2_PATH)/misc/ss: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS) 404 $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ misc/ss 405 $(STRIP) -s $@ 406 407$(IPTABLES_PATH)/.installed: $(IPTABLES_TAR) 408 mkdir -p $(BUILD_PATH) 409 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 410 sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure 411 touch $@ 412 413$(IPTABLES_PATH)/iptables/xtables-legacy-multi: | $(IPTABLES_PATH)/.installed $(USERSPACE_DEPS) 414 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 415 $(MAKE) -C $(IPTABLES_PATH) 416 $(STRIP) -s $@ 417 418$(NMAP_PATH)/.installed: $(NMAP_TAR) 419 mkdir -p $(BUILD_PATH) 420 flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 421 touch $@ 422 423$(NMAP_PATH)/ncat/ncat: | $(NMAP_PATH)/.installed $(USERSPACE_DEPS) 424 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 425 $(MAKE) -C $(NMAP_PATH)/libpcap 426 $(MAKE) -C $(NMAP_PATH)/ncat 427 $(STRIP) -s $@ 428 429clean: 430 rm -rf $(BUILD_PATH) 431 432distclean: clean 433 rm -rf $(DISTFILES_PATH) 434 435cacheclean: clean 436ifneq ($(CCACHE_DIR),) 437 rm -rf $(CCACHE_DIR) 438endif 439 440menuconfig: $(KERNEL_BUILD_PATH)/.config 441 $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) menuconfig 442 443.PHONY: qemu build clean distclean cacheclean menuconfig 444.DELETE_ON_ERROR: 445