| #!/usr/bin/make -f |
| # -*- makefile -*- |
| |
| # Uncomment this to turn on verbose mode. |
| export DH_VERBOSE = 1 |
| |
| VERSION := 4.19.125-mtk |
| |
| ARCH := arm64 |
| CROSS_COMPILE := aarch64-linux-gnu- |
| |
| KERNEL_OPTIONS := \ |
| ARCH=${ARCH} \ |
| CROSS_COMPILE=${CROSS_COMPILE} \ |
| LOCALVERSION=-mtk |
| |
| LDFLAGS := |
| BUILD_DIR := $(CURDIR)/debian/build |
| DESTDIR := $(CURDIR)/debian/linux-image-$(VERSION) |
| DESTDIR_HEADERS := $(CURDIR)/debian/linux-headers-$(VERSION) |
| DESTDIR_KBUILD := $(CURDIR)/debian/linux-kbuild-$(VERSION) |
| |
| %: |
| dh $@ |
| |
| override_dh_auto_clean: |
| true |
| |
| override_dh_auto_build: |
| cp debian/defconfig .config |
| +make $(KERNEL_OPTIONS) olddefconfig |
| +make $(KERNEL_OPTIONS) -j$(shell nproc) Image.gz modules dtbs |
| |
| /usr/bin/mkimage -D "-I dts -O dtb -p 1024" -f debian/kernel-fit-image.its boot.img |
| |
| override_dh_auto_install: |
| +make $(KERNEL_OPTIONS) INSTALL_MOD_PATH=$(DESTDIR) modules_install |
| rm $(DESTDIR)/lib/modules/$(VERSION)/build |
| rm $(DESTDIR)/lib/modules/$(VERSION)/source |
| |
| install -d $(DESTDIR)/boot |
| cp arch/$(ARCH)/boot/Image $(DESTDIR)/boot/vmlinuz-$(VERSION) |
| cp System.map $(DESTDIR)/boot/System.map-$(VERSION) |
| cp .config $(DESTDIR)/boot/config-$(VERSION) |
| install -p -m 755 boot.img $(DESTDIR)/boot |
| cp arch/arm64/boot/dts/mediatek/mt8167-coral.dtb ${DESTDIR}/boot |
| cp arch/arm64/boot/dts/mediatek/mt8167-coral-evt1-overlay.dtb ${DESTDIR}/boot/coral-evt1.dtbo |
| cp arch/arm64/boot/dts/mediatek/mt8167-coral-display-overlay.dtb ${DESTDIR}/boot/coral-display.dtbo |
| cp arch/arm64/boot/dts/mediatek/mt8167-coral-otg-overlay.dtb ${DESTDIR}/boot/coral-otg.dtbo |
| |
| install -d $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION) |
| install -d $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION)/arch/arm |
| install -d $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION)/arch/$(ARCH)/kernel |
| |
| cp -a .config $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION) |
| cp -a Module.symvers $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION) |
| cp -a include $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION) |
| cp -a arch/$(ARCH)/include $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION)/arch/$(ARCH) |
| cp -a arch/arm/include $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION)/arch/arm |
| cp -a Makefile $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION) |
| |
| ( \ |
| find arch/$(ARCH) -maxdepth 1 -name 'Makefile*' -print; \ |
| find arch/$(ARCH) \( -name 'module.lds' -o -name 'Kbuild.platforms' -o -name 'Platform' \) -print; \ |
| find $$(find arch/$(ARCH) \( -name include -o -name scripts \) -type d -print) -print; \ |
| ) | cpio -pdm $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION) |
| |
| |
| # Clean up any leftover x86 artifacts from the kernel build, and then build scripts |
| find $(CURDIR)/scripts -type f | xargs file | grep 'x86-' | awk '{print $$1}' | tr -d ':' | xargs rm -f |
| mkdir -p $(BUILD_DIR)/build-tools/scripts |
| $(MAKE) $(KERNEL_OPTIONS) \ |
| CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- \ |
| -C $(BUILD_DIR)/build-tools/scripts -f $(CURDIR)/debian/rules.d/scripts/Makefile \ |
| top_rulesdir=$(CURDIR)/debian/rules.d \ |
| top_srcdir=$(CURDIR) \ |
| OUTDIR=scripts \ |
| install \ |
| DESTDIR=$(DESTDIR_KBUILD) \ |
| prefix=/usr/lib/linux-kbuild-$(VERSION) |
| |
| install -d $(DESTDIR_HEADERS)/lib/modules/$(VERSION) |
| ln -s /usr/src/linux-headers-$(VERSION) $(DESTDIR_HEADERS)/lib/modules/$(VERSION)/build |
| ln -s /usr/lib/linux-kbuild-$(VERSION)/scripts $(DESTDIR_HEADERS)/usr/src/linux-headers-$(VERSION)/scripts |
| |
| override_dh_installudev: |
| dh_installudev --name=pvr --priority 99 |