pve-kernel-thunderx/Makefile

136 lines
4.5 KiB
Makefile
Raw Normal View History

KERNEL_MAJ=5
KERNEL_MIN=11
KERNEL_PATCHLEVEL=0
KREL=1
PKGREL=1
PKGRELLOCAL=1
PKGRELFULL=${PKGREL}
2018-03-05 14:42:44 +00:00
KERNEL_MAJMIN=$(KERNEL_MAJ).$(KERNEL_MIN)
KERNEL_VER=$(KERNEL_MAJMIN).$(KERNEL_PATCHLEVEL)
EXTRAVERSION=-${KREL}
# Append Linux flavor name to EXTRAVERSION
ifdef PVE_BUILD_FLAVOR
_ := $(info Using build flavor: ${PVE_BUILD_FLAVOR})
EXTRAVERSION:=${EXTRAVERSION}-${PVE_BUILD_FLAVOR}
endif
# Default to generic micro architecture
PVE_BUILD_TYPE ?= generic
ifneq (${PVE_BUILD_TYPE},generic)
_ := $(info Using build type: ${PVE_BUILD_TYPE})
PKGRELFULL:=${PKGRELFULL}+${PVE_BUILD_TYPE}${PKGRELLOCAL}
endif
KVNAME=${KERNEL_VER}${EXTRAVERSION}
PACKAGE=pve-edge-kernel-${KVNAME}
HDRPACKAGE=pve-edge-headers-${KVNAME}
ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
# amd64/x86_64/x86 share the arch subdirectory in the kernel, 'x86' so we need
# a mapping
KERNEL_ARCH=x86
ifneq (${ARCH}, amd64)
KERNEL_ARCH=${ARCH}
endif
2017-06-20 07:51:41 +00:00
GITVERSION:=$(shell git rev-parse HEAD)
BUILD_DIR=build
2021-03-15 19:34:24 +00:00
KERNEL_SRC=linux
KERNEL_SRC_SUBMODULE=$(KERNEL_SRC)
KERNEL_CFG_ORG=config-${KERNEL_VER}.org
2021-03-15 19:34:24 +00:00
ZFSONLINUX_SUBMODULE=zfs/
ZFSDIR=pkg-zfs
MODULES=modules
MODULE_DIRS=${ZFSDIR}
# exported to debian/rules via debian/rules.d/dirs.mk
DIRS=KERNEL_SRC ZFSDIR MODULES
DST_DEB=${PACKAGE}_${KERNEL_VER}-${PKGRELFULL}_${ARCH}.deb
HDR_DEB=${HDRPACKAGE}_${KERNEL_VER}-${PKGRELFULL}_${ARCH}.deb
LINUX_TOOLS_DEB=linux-tools-$(KERNEL_MAJMIN)_${KERNEL_VER}-${PKGRELFULL}_${ARCH}.deb
DEBS=${DST_DEB} ${HDR_DEB} ${LINUX_TOOLS_DEB}
2020-04-28 21:01:54 +00:00
all: deb release.txt artifacts.txt
2017-08-02 12:45:53 +00:00
deb: ${DEBS}
2020-04-28 18:22:14 +00:00
release.txt:
echo "${KVNAME}" > release.txt
2020-04-28 21:01:54 +00:00
echo "${KERNEL_VER}" >> release.txt
echo "${PKGREL}" >> release.txt
echo "${ARCH}" >> release.txt
2020-04-28 18:22:14 +00:00
echo "${PVE_BUILD_FLAVOR}" >> release.txt
echo "${PVE_BUILD_TYPE}" >> release.txt
2020-04-28 21:01:54 +00:00
artifacts.txt:
echo "${DST_DEB}" > artifacts.txt
echo "${HDR_DEB}" >> artifacts.txt
echo "${LINUX_TOOLS_DEB}" >> artifacts.txt
${LINUX_TOOLS_DEB} ${HDR_DEB}: ${DST_DEB}
${DST_DEB}: ${BUILD_DIR}.prepared
cd ${BUILD_DIR}; dpkg-buildpackage --jobs=auto -b -uc -us
${BUILD_DIR}.prepared: $(addsuffix .prepared,${KERNEL_SRC} ${MODULES} debian)
touch $@
debian.prepared: debian
rm -rf ${BUILD_DIR}/debian
mkdir -p ${BUILD_DIR}
cp -a debian ${BUILD_DIR}/debian
echo "git clone git@github.com:fabianishere/pve-kernel-edge.git\\ngit checkout ${GITVERSION}" > ${BUILD_DIR}/debian/SOURCE
@$(foreach dir, ${DIRS},echo "${dir}=${${dir}}" >> ${BUILD_DIR}/debian/rules.d/env.mk;)
echo "KVNAME=${KVNAME}" >> ${BUILD_DIR}/debian/rules.d/env.mk
echo "KERNEL_MAJMIN=${KERNEL_MAJMIN}" >> ${BUILD_DIR}/debian/rules.d/env.mk
cd ${BUILD_DIR}; debian/rules debian/control
ifneq (${PVE_BUILD_TYPE},generic)
cd ${BUILD_DIR}; debchange -l +${PVE_BUILD_TYPE} -D edge --force-distribution -U -M "Specialization for ${PVE_BUILD_TYPE}"
endif
touch $@
2020-08-08 11:08:32 +00:00
PVE_PATCHES=$(wildcard patches/pve/*.patch)
${KERNEL_SRC}.prepared: ${KERNEL_SRC_SUBMODULE}
rm -rf ${BUILD_DIR}/${KERNEL_SRC} $@
mkdir -p ${BUILD_DIR}
2018-03-09 10:27:15 +00:00
cp -a ${KERNEL_SRC_SUBMODULE} ${BUILD_DIR}/${KERNEL_SRC}
# TODO: split for archs, track and diff in our repository?
cat ${BUILD_DIR}/${KERNEL_SRC}/debian.master/config/config.common.ubuntu ${BUILD_DIR}/${KERNEL_SRC}/debian.master/config/${ARCH}/config.common.${ARCH} ${BUILD_DIR}/${KERNEL_SRC}/debian.master/config/${ARCH}/config.flavour.generic > ${KERNEL_CFG_ORG}
cp ${KERNEL_CFG_ORG} ${BUILD_DIR}/${KERNEL_SRC}/.config
sed -i ${BUILD_DIR}/${KERNEL_SRC}/Makefile -e 's/^EXTRAVERSION.*$$/EXTRAVERSION=${EXTRAVERSION}/'
rm -rf ${BUILD_DIR}/${KERNEL_SRC}/debian ${BUILD_DIR}/${KERNEL_SRC}/debian.master
2020-08-08 11:08:32 +00:00
set -e; cd ${BUILD_DIR}/${KERNEL_SRC}; for patch in ${PVE_PATCHES}; do echo "applying PVE patch '$$patch'" && patch -p1 < ../../$${patch}; done
touch $@
${MODULES}.prepared: $(addsuffix .prepared,${MODULE_DIRS})
touch $@
2020-08-08 11:08:32 +00:00
ZFS_PATCHES=$(wildcard patches/zfs/*.patch)
${ZFSDIR}.prepared: ${ZFSONLINUX_SUBMODULE}
rm -rf ${BUILD_DIR}/${MODULES}/${ZFSDIR} ${BUILD_DIR}/${MODULES}/tmp $@
mkdir -p ${BUILD_DIR}/${MODULES}/tmp
cp -a ${ZFSONLINUX_SUBMODULE}/* ${BUILD_DIR}/${MODULES}/tmp
2020-08-08 11:08:32 +00:00
set -e; cd ${BUILD_DIR}/${MODULES}/tmp/upstream; for patch in ${ZFS_PATCHES}; do echo "applying patch '$$patch'" && patch -p1 < ../../../../$${patch}; done
cd ${BUILD_DIR}/${MODULES}/tmp; make kernel
rm -rf ${BUILD_DIR}/${MODULES}/tmp
touch ${ZFSDIR}.prepared
.PHONY: clean
clean:
rm -rf *~ build *.prepared ${KERNEL_CFG_ORG}
rm -f *.deb *.ddeb *.changes *.buildinfo release.txt artifacts.txt
rm -f debian/control debian/pve-edge-*.postinst debian/pve-edge-*.prerm debian/pve-edge-*.postrm debian/rules.d/env.mk