162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci# 362306a36Sopenharmony_ci# Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciPWD := $(shell pwd) 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci# Set these from the environment to override 862306a36Sopenharmony_ciKERNEL_PATH ?= $(PWD)/../../../../.. 962306a36Sopenharmony_ciBUILD_PATH ?= $(PWD)/build/$(ARCH) 1062306a36Sopenharmony_ciDISTFILES_PATH ?= $(PWD)/distfiles 1162306a36Sopenharmony_ciNR_CPUS ?= 4 1262306a36Sopenharmony_ciARCH ?= 1362306a36Sopenharmony_ciCBUILD := $(shell gcc -dumpmachine) 1462306a36Sopenharmony_ciHOST_ARCH := $(firstword $(subst -, ,$(CBUILD))) 1562306a36Sopenharmony_ciifeq ($(ARCH),) 1662306a36Sopenharmony_ciARCH := $(HOST_ARCH) 1762306a36Sopenharmony_ciendif 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ciMIRROR := https://download.wireguard.com/qemu-test/distfiles/ 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciKERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug) 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cidefault: qemu 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci# variable name, tarball project name, version, tarball extension, default URI base 2662306a36Sopenharmony_cidefine tar_download = 2762306a36Sopenharmony_ci$(1)_VERSION := $(3) 2862306a36Sopenharmony_ci$(1)_NAME := $(2)-$$($(1)_VERSION) 2962306a36Sopenharmony_ci$(1)_TAR := $(DISTFILES_PATH)/$$($(1)_NAME)$(4) 3062306a36Sopenharmony_ci$(1)_PATH := $(BUILD_PATH)/$$($(1)_NAME) 3162306a36Sopenharmony_ci$(call file_download,$$($(1)_NAME)$(4),$(5),$(6)) 3262306a36Sopenharmony_ciendef 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cidefine file_download = 3562306a36Sopenharmony_ci$(DISTFILES_PATH)/$(1): | $(4) 3662306a36Sopenharmony_ci mkdir -p $(DISTFILES_PATH) 3762306a36Sopenharmony_ci 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' 3862306a36Sopenharmony_ciendef 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci$(eval $(call tar_download,IPERF,iperf,3.11,.tar.gz,https://downloads.es.net/pub/iperf/,de8cb409fad61a0574f4cb07eb19ce1159707403ac2dc01b5d175e91240b7e5f)) 4162306a36Sopenharmony_ci$(eval $(call tar_download,BASH,bash,5.1.16,.tar.gz,https://ftp.gnu.org/gnu/bash/,5bac17218d3911834520dad13cd1f85ab944e1c09ae1aba55906be1f8192f558)) 4262306a36Sopenharmony_ci$(eval $(call tar_download,IPROUTE2,iproute2,5.17.0,.tar.gz,https://www.kernel.org/pub/linux/utils/net/iproute2/,bda331d5c4606138892f23a565d78fca18919b4d508a0b7ca8391c2da2db68b9)) 4362306a36Sopenharmony_ci$(eval $(call tar_download,IPTABLES,iptables,1.8.7,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,c109c96bb04998cd44156622d36f8e04b140701ec60531a10668cfdff5e8d8f0)) 4462306a36Sopenharmony_ci$(eval $(call tar_download,NMAP,nmap,7.92,.tgz,https://nmap.org/dist/,064183ea642dc4c12b1ab3b5358ce1cef7d2e7e11ffa2849f16d339f5b717117)) 4562306a36Sopenharmony_ci$(eval $(call tar_download,IPUTILS,iputils,s20190709,.tar.gz,https://github.com/iputils/iputils/archive/s20190709.tar.gz/#,a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a)) 4662306a36Sopenharmony_ci$(eval $(call tar_download,WIREGUARD_TOOLS,wireguard-tools,1.0.20210914,.tar.xz,https://git.zx2c4.com/wireguard-tools/snapshot/,97ff31489217bb265b7ae850d3d0f335ab07d2652ba1feec88b734bc96bd05ac)) 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciexport CFLAGS := -O3 -pipe 4962306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 5062306a36Sopenharmony_ciCFLAGS += -march=native 5162306a36Sopenharmony_ciendif 5262306a36Sopenharmony_ciexport LDFLAGS := 5362306a36Sopenharmony_ciexport CPPFLAGS := 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ciQEMU_VPORT_RESULT := 5662306a36Sopenharmony_ciifeq ($(ARCH),aarch64) 5762306a36Sopenharmony_ciCHOST := aarch64-linux-musl 5862306a36Sopenharmony_ciQEMU_ARCH := aarch64 5962306a36Sopenharmony_ciKERNEL_ARCH := arm64 6062306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image 6162306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 6262306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 6362306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 6462306a36Sopenharmony_cielse 6562306a36Sopenharmony_ciQEMU_MACHINE := -cpu max -machine virt 6662306a36Sopenharmony_ciCFLAGS += -march=armv8-a 6762306a36Sopenharmony_ciendif 6862306a36Sopenharmony_cielse ifeq ($(ARCH),aarch64_be) 6962306a36Sopenharmony_ciCHOST := aarch64_be-linux-musl 7062306a36Sopenharmony_ciQEMU_ARCH := aarch64 7162306a36Sopenharmony_ciKERNEL_ARCH := arm64 7262306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image 7362306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 7462306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 7562306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 7662306a36Sopenharmony_cielse 7762306a36Sopenharmony_ciQEMU_MACHINE := -cpu max -machine virt 7862306a36Sopenharmony_ciCFLAGS += -march=armv8-a 7962306a36Sopenharmony_ciendif 8062306a36Sopenharmony_cielse ifeq ($(ARCH),arm) 8162306a36Sopenharmony_ciCHOST := arm-linux-musleabi 8262306a36Sopenharmony_ciQEMU_ARCH := arm 8362306a36Sopenharmony_ciKERNEL_ARCH := arm 8462306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage 8562306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 8662306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 8762306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 8862306a36Sopenharmony_cielse 8962306a36Sopenharmony_ciQEMU_MACHINE := -cpu max -machine virt 9062306a36Sopenharmony_ciCFLAGS += -march=armv7-a -mabi=aapcs-linux 9162306a36Sopenharmony_ciendif 9262306a36Sopenharmony_cielse ifeq ($(ARCH),armeb) 9362306a36Sopenharmony_ciCHOST := armeb-linux-musleabi 9462306a36Sopenharmony_ciQEMU_ARCH := arm 9562306a36Sopenharmony_ciKERNEL_ARCH := arm 9662306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage 9762306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 9862306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 9962306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm 10062306a36Sopenharmony_cielse 10162306a36Sopenharmony_ciQEMU_MACHINE := -cpu max -machine virt 10262306a36Sopenharmony_ciCFLAGS += -march=armv7-a -mabi=aapcs-linux 10362306a36Sopenharmony_ciLDFLAGS += -Wl,--be8 10462306a36Sopenharmony_ciendif 10562306a36Sopenharmony_cielse ifeq ($(ARCH),x86_64) 10662306a36Sopenharmony_ciCHOST := x86_64-linux-musl 10762306a36Sopenharmony_ciQEMU_ARCH := x86_64 10862306a36Sopenharmony_ciKERNEL_ARCH := x86_64 10962306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage 11062306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 11162306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 11262306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine microvm,accel=kvm,pit=off,pic=off,rtc=off -no-acpi 11362306a36Sopenharmony_cielse 11462306a36Sopenharmony_ciQEMU_MACHINE := -cpu max -machine microvm -no-acpi 11562306a36Sopenharmony_ciendif 11662306a36Sopenharmony_cielse ifeq ($(ARCH),i686) 11762306a36Sopenharmony_ciCHOST := i686-linux-musl 11862306a36Sopenharmony_ciQEMU_ARCH := i386 11962306a36Sopenharmony_ciKERNEL_ARCH := x86 12062306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage 12162306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 12262306a36Sopenharmony_ciifeq ($(subst x86_64,i686,$(HOST_ARCH)),$(ARCH)) 12362306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine microvm,accel=kvm,pit=off,pic=off,rtc=off -no-acpi 12462306a36Sopenharmony_cielse 12562306a36Sopenharmony_ciQEMU_MACHINE := -cpu coreduo -machine microvm -no-acpi 12662306a36Sopenharmony_ciendif 12762306a36Sopenharmony_cielse ifeq ($(ARCH),mips64) 12862306a36Sopenharmony_ciCHOST := mips64-linux-musl 12962306a36Sopenharmony_ciQEMU_ARCH := mips64 13062306a36Sopenharmony_ciKERNEL_ARCH := mips 13162306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 13262306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 13362306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine malta,accel=kvm 13462306a36Sopenharmony_ciCFLAGS += -EB 13562306a36Sopenharmony_cielse 13662306a36Sopenharmony_ciQEMU_MACHINE := -cpu MIPS64R2-generic -machine malta -smp 1 13762306a36Sopenharmony_ciCFLAGS += -march=mips64r2 -EB 13862306a36Sopenharmony_ciendif 13962306a36Sopenharmony_cielse ifeq ($(ARCH),mips64el) 14062306a36Sopenharmony_ciCHOST := mips64el-linux-musl 14162306a36Sopenharmony_ciQEMU_ARCH := mips64el 14262306a36Sopenharmony_ciKERNEL_ARCH := mips 14362306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 14462306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 14562306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine malta,accel=kvm 14662306a36Sopenharmony_ciCFLAGS += -EL 14762306a36Sopenharmony_cielse 14862306a36Sopenharmony_ciQEMU_MACHINE := -cpu MIPS64R2-generic -machine malta -smp 1 14962306a36Sopenharmony_ciCFLAGS += -march=mips64r2 -EL 15062306a36Sopenharmony_ciendif 15162306a36Sopenharmony_cielse ifeq ($(ARCH),mips) 15262306a36Sopenharmony_ciCHOST := mips-linux-musl 15362306a36Sopenharmony_ciQEMU_ARCH := mips 15462306a36Sopenharmony_ciKERNEL_ARCH := mips 15562306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 15662306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 15762306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine malta,accel=kvm 15862306a36Sopenharmony_ciCFLAGS += -EB 15962306a36Sopenharmony_cielse 16062306a36Sopenharmony_ciQEMU_MACHINE := -cpu 24Kf -machine malta -smp 1 16162306a36Sopenharmony_ciCFLAGS += -march=mips32r2 -EB 16262306a36Sopenharmony_ciendif 16362306a36Sopenharmony_cielse ifeq ($(ARCH),mipsel) 16462306a36Sopenharmony_ciCHOST := mipsel-linux-musl 16562306a36Sopenharmony_ciQEMU_ARCH := mipsel 16662306a36Sopenharmony_ciKERNEL_ARCH := mips 16762306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 16862306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 16962306a36Sopenharmony_ciQEMU_MACHINE := -cpu host -machine malta,accel=kvm 17062306a36Sopenharmony_ciCFLAGS += -EL 17162306a36Sopenharmony_cielse 17262306a36Sopenharmony_ciQEMU_MACHINE := -cpu 24Kf -machine malta -smp 1 17362306a36Sopenharmony_ciCFLAGS += -march=mips32r2 -EL 17462306a36Sopenharmony_ciendif 17562306a36Sopenharmony_cielse ifeq ($(ARCH),powerpc64) 17662306a36Sopenharmony_ciCHOST := powerpc64-linux-musl 17762306a36Sopenharmony_ciQEMU_ARCH := ppc64 17862306a36Sopenharmony_ciKERNEL_ARCH := powerpc 17962306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 18062306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 18162306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine pseries 18262306a36Sopenharmony_cielse 18362306a36Sopenharmony_ciQEMU_MACHINE := -machine pseries -device spapr-rng,rng=rng -object rng-random,id=rng 18462306a36Sopenharmony_ciendif 18562306a36Sopenharmony_cielse ifeq ($(ARCH),powerpc64le) 18662306a36Sopenharmony_ciCHOST := powerpc64le-linux-musl 18762306a36Sopenharmony_ciQEMU_ARCH := ppc64 18862306a36Sopenharmony_ciKERNEL_ARCH := powerpc 18962306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 19062306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 19162306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine pseries 19262306a36Sopenharmony_cielse 19362306a36Sopenharmony_ciQEMU_MACHINE := -machine pseries -device spapr-rng,rng=rng -object rng-random,id=rng 19462306a36Sopenharmony_ciendif 19562306a36Sopenharmony_cielse ifeq ($(ARCH),powerpc) 19662306a36Sopenharmony_ciCHOST := powerpc-linux-musl 19762306a36Sopenharmony_ciQEMU_ARCH := ppc 19862306a36Sopenharmony_ciKERNEL_ARCH := powerpc 19962306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/powerpc/boot/uImage 20062306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 20162306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine ppce500 20262306a36Sopenharmony_cielse 20362306a36Sopenharmony_ciQEMU_MACHINE := -machine ppce500 20462306a36Sopenharmony_ciendif 20562306a36Sopenharmony_cielse ifeq ($(ARCH),m68k) 20662306a36Sopenharmony_ciCHOST := m68k-linux-musl 20762306a36Sopenharmony_ciQEMU_ARCH := m68k 20862306a36Sopenharmony_ciKERNEL_ARCH := m68k 20962306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 21062306a36Sopenharmony_ciKERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/m68k.config) 21162306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 21262306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 21362306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine virt -append $(KERNEL_CMDLINE) 21462306a36Sopenharmony_cielse 21562306a36Sopenharmony_ciQEMU_MACHINE := -machine virt -smp 1 -append $(KERNEL_CMDLINE) 21662306a36Sopenharmony_ciendif 21762306a36Sopenharmony_cielse ifeq ($(ARCH),riscv64) 21862306a36Sopenharmony_ciCHOST := riscv64-linux-musl 21962306a36Sopenharmony_ciQEMU_ARCH := riscv64 22062306a36Sopenharmony_ciKERNEL_ARCH := riscv 22162306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/riscv/boot/Image 22262306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 22362306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 22462306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine virt 22562306a36Sopenharmony_cielse 22662306a36Sopenharmony_ciQEMU_MACHINE := -cpu rv64 -machine virt 22762306a36Sopenharmony_ciendif 22862306a36Sopenharmony_cielse ifeq ($(ARCH),riscv32) 22962306a36Sopenharmony_ciCHOST := riscv32-linux-musl 23062306a36Sopenharmony_ciQEMU_ARCH := riscv32 23162306a36Sopenharmony_ciKERNEL_ARCH := riscv 23262306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/riscv/boot/Image 23362306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-device 23462306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 23562306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine virt 23662306a36Sopenharmony_cielse 23762306a36Sopenharmony_ciQEMU_MACHINE := -cpu rv32 -machine virt 23862306a36Sopenharmony_ciendif 23962306a36Sopenharmony_cielse ifeq ($(ARCH),s390x) 24062306a36Sopenharmony_ciCHOST := s390x-linux-musl 24162306a36Sopenharmony_ciQEMU_ARCH := s390x 24262306a36Sopenharmony_ciKERNEL_ARCH := s390 24362306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/s390/boot/bzImage 24462306a36Sopenharmony_ciKERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/s390x.config) 24562306a36Sopenharmony_ciQEMU_VPORT_RESULT := virtio-serial-ccw 24662306a36Sopenharmony_ciifeq ($(HOST_ARCH),$(ARCH)) 24762306a36Sopenharmony_ciQEMU_MACHINE := -cpu host,accel=kvm -machine s390-ccw-virtio -append $(KERNEL_CMDLINE) 24862306a36Sopenharmony_cielse 24962306a36Sopenharmony_ciQEMU_MACHINE := -cpu max -machine s390-ccw-virtio -append $(KERNEL_CMDLINE) 25062306a36Sopenharmony_ciendif 25162306a36Sopenharmony_cielse ifeq ($(ARCH),um) 25262306a36Sopenharmony_ciCHOST := $(HOST_ARCH)-linux-musl 25362306a36Sopenharmony_ciKERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux 25462306a36Sopenharmony_ciKERNEL_ARCH := um 25562306a36Sopenharmony_ciKERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/um.config) 25662306a36Sopenharmony_cielse 25762306a36Sopenharmony_ci$(error I only build: x86_64, i686, arm, armeb, aarch64, aarch64_be, mips, mipsel, mips64, mips64el, powerpc64, powerpc64le, powerpc, m68k, riscv64, riscv32, s390x, um) 25862306a36Sopenharmony_ciendif 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ciTOOLCHAIN_FILENAME := $(CHOST)-cross.tgz 26162306a36Sopenharmony_ciTOOLCHAIN_TAR := $(DISTFILES_PATH)/$(TOOLCHAIN_FILENAME) 26262306a36Sopenharmony_ciTOOLCHAIN_PATH := $(BUILD_PATH)/$(CHOST)-cross 26362306a36Sopenharmony_ciTOOLCHAIN_DIR := https://download.wireguard.com/qemu-test/toolchains/20211123/ 26462306a36Sopenharmony_ci$(eval $(call file_download,toolchain-sha256sums-20211123,$(TOOLCHAIN_DIR)SHA256SUMS#,83da033fd8c798df476c21d9612da2dfb896ec62fbed4ceec5eefc0e56b3f0c8)) 26562306a36Sopenharmony_ci$(eval $(call file_download,$(TOOLCHAIN_FILENAME),$(TOOLCHAIN_DIR),,$(DISTFILES_PATH)/toolchain-sha256sums-20211123)) 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ciSTRIP := $(CHOST)-strip 26862306a36Sopenharmony_ciCROSS_COMPILE_FLAG := --build=$(CBUILD) --host=$(CHOST) 26962306a36Sopenharmony_ci$(info Building for $(CHOST) using $(CBUILD)) 27062306a36Sopenharmony_ciifneq ($(ARCH),um) 27162306a36Sopenharmony_ciexport CROSS_COMPILE := $(CHOST)- 27262306a36Sopenharmony_ciendif 27362306a36Sopenharmony_ciexport PATH := $(TOOLCHAIN_PATH)/bin:$(PATH) 27462306a36Sopenharmony_ciexport CC := $(CHOST)-gcc 27562306a36Sopenharmony_ciCCACHE_PATH := $(shell which ccache 2>/dev/null) 27662306a36Sopenharmony_ciifneq ($(CCACHE_PATH),) 27762306a36Sopenharmony_ciexport KBUILD_BUILD_TIMESTAMP := Fri Jun 5 15:58:00 CEST 2015 27862306a36Sopenharmony_ciexport PATH := $(TOOLCHAIN_PATH)/bin/ccache:$(PATH) 27962306a36Sopenharmony_ciexport CCACHE_SLOPPINESS := file_macro,time_macros 28062306a36Sopenharmony_ciexport CCACHE_DIR ?= $(PWD)/ccache 28162306a36Sopenharmony_ciendif 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ciUSERSPACE_DEPS := $(TOOLCHAIN_PATH)/.installed $(TOOLCHAIN_PATH)/$(CHOST)/include/linux/.installed 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_cicomma := , 28662306a36Sopenharmony_cibuild: $(KERNEL_BZIMAGE) 28762306a36Sopenharmony_ciqemu: $(KERNEL_BZIMAGE) 28862306a36Sopenharmony_ci rm -f $(BUILD_PATH)/result 28962306a36Sopenharmony_ciifneq ($(ARCH),um) 29062306a36Sopenharmony_ci timeout --foreground 20m qemu-system-$(QEMU_ARCH) \ 29162306a36Sopenharmony_ci -nodefaults \ 29262306a36Sopenharmony_ci -nographic \ 29362306a36Sopenharmony_ci -smp $(NR_CPUS) \ 29462306a36Sopenharmony_ci $(QEMU_MACHINE) \ 29562306a36Sopenharmony_ci -m $$(grep -q CONFIG_DEBUG_KMEMLEAK=y $(KERNEL_BUILD_PATH)/.config && echo 1G || echo 256M) \ 29662306a36Sopenharmony_ci -serial stdio \ 29762306a36Sopenharmony_ci -chardev file,path=$(BUILD_PATH)/result,id=result \ 29862306a36Sopenharmony_ci $(if $(QEMU_VPORT_RESULT),-device $(QEMU_VPORT_RESULT) -device virtserialport$(comma)chardev=result,-serial chardev:result) \ 29962306a36Sopenharmony_ci -no-reboot \ 30062306a36Sopenharmony_ci -monitor none \ 30162306a36Sopenharmony_ci -kernel $< 30262306a36Sopenharmony_cielse 30362306a36Sopenharmony_ci timeout --foreground 20m $< \ 30462306a36Sopenharmony_ci $(KERNEL_CMDLINE) \ 30562306a36Sopenharmony_ci mem=$$(grep -q CONFIG_DEBUG_KMEMLEAK=y $(KERNEL_BUILD_PATH)/.config && echo 1G || echo 256M) \ 30662306a36Sopenharmony_ci noreboot \ 30762306a36Sopenharmony_ci con1=fd:51 51>$(BUILD_PATH)/result </dev/null 2>&1 | cat 30862306a36Sopenharmony_ciendif 30962306a36Sopenharmony_ci grep -Fq success $(BUILD_PATH)/result 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci$(BUILD_PATH)/init-cpio-spec.txt: $(TOOLCHAIN_PATH)/.installed $(BUILD_PATH)/init 31262306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 31362306a36Sopenharmony_ci echo "file /init $(BUILD_PATH)/init 755 0 0" > $@ 31462306a36Sopenharmony_ci echo "file /init.sh $(PWD)/../netns.sh 755 0 0" >> $@ 31562306a36Sopenharmony_ci echo "dir /dev 755 0 0" >> $@ 31662306a36Sopenharmony_ci echo "nod /dev/console 644 0 0 c 5 1" >> $@ 31762306a36Sopenharmony_ci echo "dir /bin 755 0 0" >> $@ 31862306a36Sopenharmony_ci echo "file /bin/iperf3 $(IPERF_PATH)/src/iperf3 755 0 0" >> $@ 31962306a36Sopenharmony_ci echo "file /bin/wg $(WIREGUARD_TOOLS_PATH)/src/wg 755 0 0" >> $@ 32062306a36Sopenharmony_ci echo "file /bin/bash $(BASH_PATH)/bash 755 0 0" >> $@ 32162306a36Sopenharmony_ci echo "file /bin/ip $(IPROUTE2_PATH)/ip/ip 755 0 0" >> $@ 32262306a36Sopenharmony_ci echo "file /bin/ss $(IPROUTE2_PATH)/misc/ss 755 0 0" >> $@ 32362306a36Sopenharmony_ci echo "file /bin/ping $(IPUTILS_PATH)/ping 755 0 0" >> $@ 32462306a36Sopenharmony_ci echo "file /bin/ncat $(NMAP_PATH)/ncat/ncat 755 0 0" >> $@ 32562306a36Sopenharmony_ci echo "file /bin/xtables-legacy-multi $(IPTABLES_PATH)/iptables/xtables-legacy-multi 755 0 0" >> $@ 32662306a36Sopenharmony_ci echo "slink /bin/iptables xtables-legacy-multi 777 0 0" >> $@ 32762306a36Sopenharmony_ci echo "slink /bin/ping6 ping 777 0 0" >> $@ 32862306a36Sopenharmony_ci echo "dir /lib 755 0 0" >> $@ 32962306a36Sopenharmony_ci echo "file /lib/libc.so $(TOOLCHAIN_PATH)/$(CHOST)/lib/libc.so 755 0 0" >> $@ 33062306a36Sopenharmony_ci echo "slink $$($(CHOST)-readelf -p .interp '$(BUILD_PATH)/init'| grep -o '/lib/.*') libc.so 777 0 0" >> $@ 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci$(KERNEL_BUILD_PATH)/.config: $(TOOLCHAIN_PATH)/.installed kernel.config arch/$(ARCH).config 33362306a36Sopenharmony_ci mkdir -p $(KERNEL_BUILD_PATH) 33462306a36Sopenharmony_ci cp kernel.config $(KERNEL_BUILD_PATH)/minimal.config 33562306a36Sopenharmony_ci printf 'CONFIG_NR_CPUS=$(NR_CPUS)\nCONFIG_INITRAMFS_SOURCE="$(BUILD_PATH)/init-cpio-spec.txt"\n' >> $(KERNEL_BUILD_PATH)/minimal.config 33662306a36Sopenharmony_ci cat arch/$(ARCH).config >> $(KERNEL_BUILD_PATH)/minimal.config 33762306a36Sopenharmony_ci $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) allnoconfig 33862306a36Sopenharmony_ci cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config $(KERNEL_BUILD_PATH)/minimal.config 33962306a36Sopenharmony_ci $(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,) 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci$(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 34262306a36Sopenharmony_ci $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) 34362306a36Sopenharmony_ci.PHONY: $(KERNEL_BZIMAGE) 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci$(TOOLCHAIN_PATH)/$(CHOST)/include/linux/.installed: | $(KERNEL_BUILD_PATH)/.config $(TOOLCHAIN_PATH)/.installed 34662306a36Sopenharmony_ciifneq ($(ARCH),um) 34762306a36Sopenharmony_ci rm -rf $(TOOLCHAIN_PATH)/$(CHOST)/include/linux 34862306a36Sopenharmony_ci $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) INSTALL_HDR_PATH=$(TOOLCHAIN_PATH)/$(CHOST) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) headers_install 34962306a36Sopenharmony_ciendif 35062306a36Sopenharmony_ci touch $@ 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ci$(TOOLCHAIN_PATH)/.installed: $(TOOLCHAIN_TAR) 35362306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 35462306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 35562306a36Sopenharmony_ci $(STRIP) -s $(TOOLCHAIN_PATH)/$(CHOST)/lib/libc.so 35662306a36Sopenharmony_ciifneq ($(CCACHE_PATH),) 35762306a36Sopenharmony_ci mkdir -p $(TOOLCHAIN_PATH)/bin/ccache 35862306a36Sopenharmony_ci ln -s $(CCACHE_PATH) $(TOOLCHAIN_PATH)/bin/ccache/$(CC) 35962306a36Sopenharmony_ciendif 36062306a36Sopenharmony_ci touch $@ 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci$(IPERF_PATH)/.installed: $(IPERF_TAR) 36362306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 36462306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 36562306a36Sopenharmony_ci sed -i '1s/^/#include <stdint.h>/' $(IPERF_PATH)/src/cjson.h $(IPERF_PATH)/src/timer.h 36662306a36Sopenharmony_ci sed -i -r 's/-p?g//g' $(IPERF_PATH)/src/Makefile* 36762306a36Sopenharmony_ci touch $@ 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci$(IPERF_PATH)/src/iperf3: | $(IPERF_PATH)/.installed $(USERSPACE_DEPS) 37062306a36Sopenharmony_ci cd $(IPERF_PATH) && autoreconf -fi 37162306a36Sopenharmony_ci cd $(IPERF_PATH) && CFLAGS="$(CFLAGS) -D_GNU_SOURCE" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --with-openssl=no 37262306a36Sopenharmony_ci $(MAKE) -C $(IPERF_PATH) 37362306a36Sopenharmony_ci $(STRIP) -s $@ 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ci$(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR) 37662306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 37762306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 37862306a36Sopenharmony_ci touch $@ 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_ci$(WIREGUARD_TOOLS_PATH)/src/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(USERSPACE_DEPS) 38162306a36Sopenharmony_ci $(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src wg 38262306a36Sopenharmony_ci $(STRIP) -s $@ 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci$(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS) 38562306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 38662306a36Sopenharmony_ci $(CC) -o $@ $(CFLAGS) $(LDFLAGS) -std=gnu11 $< 38762306a36Sopenharmony_ci $(STRIP) -s $@ 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_ci$(IPUTILS_PATH)/.installed: $(IPUTILS_TAR) 39062306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 39162306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 39262306a36Sopenharmony_ci touch $@ 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci$(IPUTILS_PATH)/ping: | $(IPUTILS_PATH)/.installed $(USERSPACE_DEPS) 39562306a36Sopenharmony_ci sed -i /atexit/d $(IPUTILS_PATH)/ping.c 39662306a36Sopenharmony_ci 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) 39762306a36Sopenharmony_ci $(STRIP) -s $@ 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ci$(BASH_PATH)/.installed: $(BASH_TAR) 40062306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 40162306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 40262306a36Sopenharmony_ci touch $@ 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ci$(BASH_PATH)/bash: | $(BASH_PATH)/.installed $(USERSPACE_DEPS) 40562306a36Sopenharmony_ci 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 40662306a36Sopenharmony_ci $(MAKE) -C $(BASH_PATH) 40762306a36Sopenharmony_ci $(STRIP) -s $@ 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ci$(IPROUTE2_PATH)/.installed: $(IPROUTE2_TAR) 41062306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 41162306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 41262306a36Sopenharmony_ci 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 41362306a36Sopenharmony_ci 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 41462306a36Sopenharmony_ci touch $@ 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci$(IPROUTE2_PATH)/ip/ip: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS) 41762306a36Sopenharmony_ci $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ ip/ip 41862306a36Sopenharmony_ci $(STRIP) -s $@ 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci$(IPROUTE2_PATH)/misc/ss: | $(IPROUTE2_PATH)/.installed $(USERSPACE_DEPS) 42162306a36Sopenharmony_ci $(MAKE) -C $(IPROUTE2_PATH) PREFIX=/ misc/ss 42262306a36Sopenharmony_ci $(STRIP) -s $@ 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci$(IPTABLES_PATH)/.installed: $(IPTABLES_TAR) 42562306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 42662306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 42762306a36Sopenharmony_ci sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure 42862306a36Sopenharmony_ci touch $@ 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci$(IPTABLES_PATH)/iptables/xtables-legacy-multi: | $(IPTABLES_PATH)/.installed $(USERSPACE_DEPS) 43162306a36Sopenharmony_ci 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 43262306a36Sopenharmony_ci $(MAKE) -C $(IPTABLES_PATH) 43362306a36Sopenharmony_ci $(STRIP) -s $@ 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_ci$(NMAP_PATH)/.installed: $(NMAP_TAR) 43662306a36Sopenharmony_ci mkdir -p $(BUILD_PATH) 43762306a36Sopenharmony_ci flock -s $<.lock tar -C $(BUILD_PATH) -xf $< 43862306a36Sopenharmony_ci touch $@ 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci$(NMAP_PATH)/ncat/ncat: | $(NMAP_PATH)/.installed $(USERSPACE_DEPS) 44162306a36Sopenharmony_ci 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 44262306a36Sopenharmony_ci $(MAKE) -C $(NMAP_PATH)/libpcap 44362306a36Sopenharmony_ci $(MAKE) -C $(NMAP_PATH)/ncat 44462306a36Sopenharmony_ci $(STRIP) -s $@ 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ciclean: 44762306a36Sopenharmony_ci rm -rf $(BUILD_PATH) 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_cidistclean: clean 45062306a36Sopenharmony_ci rm -rf $(DISTFILES_PATH) 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_cicacheclean: clean 45362306a36Sopenharmony_ciifneq ($(CCACHE_DIR),) 45462306a36Sopenharmony_ci rm -rf $(CCACHE_DIR) 45562306a36Sopenharmony_ciendif 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_cimenuconfig: $(KERNEL_BUILD_PATH)/.config 45862306a36Sopenharmony_ci $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) menuconfig 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ci.PHONY: qemu build clean distclean cacheclean menuconfig 46162306a36Sopenharmony_ci.DELETE_ON_ERROR: 462