CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Add Makefile
authorJohn Vogel <jvogel4@stny.rr.com>
Sat, 14 May 2016 02:44:24 +0000 (22:44 -0400)
committerJohn Vogel <jvogel4@stny.rr.com>
Sat, 14 May 2016 02:44:24 +0000 (22:44 -0400)
Originally based on Makefile for raspberrypi.

Makefile [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..84a3ced
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,148 @@
+#
+# src/kernel/Makefile
+#
+
+TARGET = arm-crux-linux-gnueabihf
+
+PWD = $(shell pwd)
+WORK = $(PWD)/work
+CROSSTOOLS = /devel/crux-arm/toolchain/crosstools
+
+KERNEL_BRANCH = 4.5.y
+KERNEL_VERSION = 4.5.4
+PATCH_VERSION = 20160513
+
+CONFIG_FILE = config-$(KERNEL_VERSION)-raspberrypi2_$(PATCH_VERSION)
+PATCH_FILE = linux-$(KERNEL_BRANCH)-rpi-$(PATCH_VERSION).patch
+KERNEL_TARBALL = linux-$(KERNEL_VERSION).tar.xz
+
+
+.PHONY: all clean config files image map menuconfig modules
+
+all: image modules map dtb
+
+clean: image-clean modules-clean map-clean dtb-clean
+
+distclean: clean image-distclean modules-distclean dtb-distclean map-distclean
+
+$(PWD)/$(KERNEL_TARBALL):
+       wget -P $(PWD) https://www.kernel.org/pub/linux/kernel/v4.x/$(KERNEL_TARBALL)
+       touch $@
+
+$(PWD)/$(PATCH_FILE):
+       wget -P $(PWD) http://stygian.me/crux-arm/distfiles/$(PATCH_FILE)
+       touch $@
+
+$(PWD)/$(CONFIG_FILE):
+       wget -P $(PWD) http://stygian.me/crux-arm/distfiles/$(CONFIG_FILE)
+       touch $@
+
+files: $(PWD)/$(KERNEL_TARBALL) $(PWD)/$(PATCH_FILE) $(PWD)/$(CONFIG_FILE)
+
+$(WORK)/linux-$(KERNEL_VERSION):
+       bsdtar -C $(WORK) -xf $(PWD)/$(KERNEL_TARBALL)
+       patch -d $(WORK)/linux-$(KERNEL_VERSION) -p1 -i $(PWD)/$(PATCH_FILE)
+       sed -e 's|LINUX_COMPILE_BY=.*|LINUX_COMPILE_BY=devel|' \
+           -e 's|LINUX_COMPILE_HOST=.*|LINUX_COMPILE_HOST=crux-arm.nu|' \
+           -i $(WORK)/linux-$(KERNEL_VERSION)/scripts/mkcompile_h
+       touch $@
+
+$(WORK)/linux-$(KERNEL_VERSION)/.config: $(WORK)/linux-$(KERNEL_VERSION)
+       cp -v $(PWD)/$(CONFIG_FILE) $@
+       touch $@
+
+config: files $(WORK)/linux-$(KERNEL_VERSION)/.config
+
+$(WORK)/zImage-$(KERNEL_VERSION): config
+       cd $(WORK)/linux-$(KERNEL_VERSION) && \
+               export PATH=$(CROSSTOOLS)/bin:$$PATH && \
+               export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
+               make ARCH=arm CROSS_COMPILE=$(TARGET)- zImage
+       cp -v $(WORK)/linux-$(KERNEL_VERSION)/arch/arm/boot/zImage $@
+       touch $@
+
+$(WORK)/kernel7-$(KERNEL_VERSION).img: $(WORK)/zImage-$(KERNEL_VERSION)
+       chmod +x $(WORK)/linux-$(KERNEL_VERSION)/scripts/mkknlimg
+       cd $(WORK)/linux-$(KERNEL_VERSION) && \
+               ./scripts/mkknlimg $(WORK)/zImage-$(KERNEL_VERSION) $@
+       touch $@
+
+image: $(WORK)/kernel7-$(KERNEL_VERSION).img
+
+image-clean:
+       rm -vf $(WORK)/zImage-$(KERNEL_VERSION)
+       rm -vf $(WORK)/kernel7-$(KERNEL_VERSION).img
+       if [ -d $(WORK)/linux-$(KERNEL_VERSION)/.config ]; then \
+               cd $(WORK)/linux-$(KERNEL_VERSION) && \
+                       export PATH=$(CROSSTOOLS)/bin:$$PATH && \
+                       export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
+                       make ARCH=arm CROSS_COMPILE=$(TARGET)- clean ; \
+       fi
+
+image-distclean: image-clean
+       rm -vrf $(WORK)/linux-$(KERNEL_VERSION)
+
+$(WORK)/dtb-$(KERNEL_VERSION): $(WORK)/linux-$(KERNEL_VERSION)
+       cd $(WORK)/linux-$(KERNEL_VERSION) && \
+               export PATH=$(CROSSTOOLS)/bin:$$PATH && \
+               export LD_LIBRARY_PATH=$(CROSSTOOLS):$$LD_LIBRARY_PATH && \
+               make ARCH=arm CROSS_COMPILE=$(TARGET)- dtbs
+       rm -rf $(WORK)/dtb
+       mkdir -p $(WORK)/dtb/overlays
+       cp $(WORK)/linux-$(KERNEL_VERSION)/arch/arm/boot/dts/*.dtb $(WORK)/dtb
+       cp $(WORK)/linux-$(KERNEL_VERSION)/arch/arm/boot/dts/overlays/*.dtb* $(WORK)/dtb/overlays
+       mv $(WORK)/dtb $(WORK)/dtb-$(KERNEL_VERSION)
+
+$(WORK)/dtb-$(KERNEL_VERSION).tar.xz: $(WORK)/dtb-$(KERNEL_VERSION)
+       cd $(WORK)/dtb-$(KERNEL_VERSION) && \
+               bsdtar --uid 0 --gid 0 -cvJf $(WORK)/dtb-$(KERNEL_VERSION).tar.xz *
+
+dtb: $(WORK)/dtb-$(KERNEL_VERSION).tar.xz
+
+dtb-clean:
+       rm -vf $(WORK)/dtb-$(KERNEL_VERSION).tar.xz
+       rm -vrf $(WORK)/dtb-$(KERNEL_VERSION)
+
+dtb-distclean: dtb-clean
+
+$(WORK)/modules-$(KERNEL_VERSION): $(WORK)/linux-$(KERNEL_VERSION)
+       cd $(WORK)/linux-$(KERNEL_VERSION) && \
+               export PATH=$(CROSSTOOLS)/bin:$$PATH && \
+               export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)/lib:$$LD_LIBRARY_PATH && \
+               make ARCH=arm CROSS_COMPILE=$(TARGET)- modules && \
+               make ARCH=arm CROSS_COMPILE=$(TARGET)- INSTALL_MOD_PATH=$(WORK)/modules-$(KERNEL_VERSION) modules_install
+       rm -f $(WORK)/modules-$(KERNEL_VERSION)/lib/modules/$(KERNEL_VERSION)/{source,build}
+       touch $(WORK)/modules-$(KERNEL_VERSION)
+
+$(WORK)/modules-$(KERNEL_VERSION).tar.xz: $(WORK)/modules-$(KERNEL_VERSION)
+       cd $(WORK)/modules-$(KERNEL_VERSION) && \
+               bsdtar --uid 0 --gid 0 -cvJf $(WORK)/modules-$(KERNEL_VERSION).tar.xz *
+       touch $(WORK)/modules-$(KERNEL_VERSION).tar.xz
+
+modules: $(WORK)/modules-$(KERNEL_VERSION).tar.xz
+
+modules-clean:
+       rm -vf $(WORK)/modules-$(KERNEL_VERSION).tar.xz
+       rm -vrf $(WORK)/modules-$(KERNEL_VERSION)
+
+modules-distclean: modules-clean
+
+$(WORK)/System.map-$(KERNEL_VERSION): $(WORK)/zImage-$(KERNEL_VERSION)
+       cp $(WORK)/linux-$(KERNEL_VERSION)/System.map $(WORK)/System.map-$(KERNEL_VERSION)
+       touch $(WORK)/System.map-$(KERNEL_VERSION)
+
+map: $(WORK)/System.map-$(KERNEL_VERSION)
+
+map-clean:
+       rm -vf $(WORK)/System.map-$(KERNEL_VERSION)
+
+map-distclean: map-clean
+
+menuconfig: $(WORK)/linux-$(KERNEL_VERSION)
+       cd $(WORK)/linux-$(KERNEL_VERSION) && \
+               export PATH=$(CROSSTOOLS)/bin:$$PATH && \
+               export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
+               make ARCH=arm CROSS_COMPILE=$(TARGET)- menuconfig
+       touch $(WORK)/linux-$(KERNEL_VERSION)
+
+# End of file