Jumpdrive/Makefile

114 lines
3.4 KiB
Makefile
Raw Normal View History

2020-03-16 14:49:12 +00:00
CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
2020-03-17 18:19:34 +00:00
all: pine64-pinephone.img.xz pine64-pinetab.img.xz
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
pine64-pinephone.img: fat-pine64-pinephone.img u-boot-sunxi-with-spl.bin
rm -f $@
truncate --size 50M $@
parted -s $@ mktable msdos
parted -s $@ mkpart primary fat32 2048s 100%
parted -s $@ set 1 boot on
dd if=u-boot-sunxi-with-spl.bin of=$@ bs=8k seek=1
dd if=fat-$@ of=$@ seek=1024 bs=1k
fat-pine64-pinephone.img: initramfs-pine64-pinephone.gz kernel-sunxi.gz pine64-pinephone.scr dtbs/sunxi/sun50i-a64-pinephone.dtb
@echo "MKFS $@"
@rm -f $@
@truncate --size 40M $@
@mkfs.fat -F32 $@
@mcopy -i $@ kernel-sunxi.gz ::Image.gz
@mcopy -i $@ dtbs/sunxi/sun50i-a64-pinephone.dtb ::sun50i-a64-pinephone.dtb
@mcopy -i $@ initramfs-pine64-pinephone.gz ::initramfs.gz
@mcopy -i $@ pine64-pinephone.scr ::boot.scr
pine64-pinetab.img: fat-pine64-pinetab.img u-boot-sunxi-with-spl.bin
rm -f $@
truncate --size 50M $@
parted -s $@ mktable msdos
parted -s $@ mkpart primary fat32 2048s 100%
parted -s $@ set 1 boot on
dd if=u-boot-sunxi-with-spl.bin of=$@ bs=8k seek=1
dd if=fat-$@ of=$@ seek=1024 bs=1k
fat-pine64-pinetab.img: initramfs-pine64-pinetab.gz kernel-sunxi.gz pine64-pinetab.scr dtbs/sunxi/sun50i-a64-pinetab.dtb
@echo "MKFS $@"
@rm -f $@
@truncate --size 40M $@
@mkfs.fat -F32 $@
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
@mcopy -i $@ kernel-sunxi.gz ::Image.gz
@mcopy -i $@ dtbs/sunxi/sun50i-a64-pinetab.dtb ::sun50i-a64-pinetab.dtb
@mcopy -i $@ initramfs-pine64-pinetab.gz ::initramfs.gz
@mcopy -i $@ pine64-pinetab.scr ::boot.scr
%.img.xz: %.img
@echo "XZ $@"
@xz -c $< > $@
2020-03-16 14:49:12 +00:00
initramfs/bin/busybox: src/busybox src/busybox_config
2020-03-17 18:19:34 +00:00
@echo "MAKE $@"
@mkdir -p build/busybox
@cp src/busybox_config build/busybox/.config
@$(MAKE) -C src/busybox O=../../build/busybox $(CROSS_FLAGS)
@cp build/busybox/busybox initramfs/bin/busybox
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
splash/%.ppm.gz: splash/%.ppm
@echo "GZ $@"
@gzip < $< > $@
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
initramfs-%.cpio: initramfs/bin/busybox initramfs/init initramfs/init_functions.sh splash/%.ppm.gz splash/%-error.ppm.gz
@echo "CPIO $@"
@rm -rf initramfs-$*
@cp -r initramfs initramfs-$*
@cp src/info-$*.sh initramfs-$*/info.sh
@cp splash/$*.ppm.gz initramfs-$*/splash.ppm.gz
@cp splash/$*-error.ppm.gz initramfs-$*/error.ppm.gz
@cp src/info-$*.sh initramfs-$*/info.sh
@cd initramfs-$*; find . | cpio -H newc -o > ../$@
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
initramfs-%.gz: initramfs-%.cpio
@echo "GZ $@"
@gzip < $< > $@
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
kernel-sunxi.gz: src/linux_config
@echo "MAKE $@"
@mkdir -p build/linux-sunxi
@mkdir -p dtbs/sunxi
@cp src/linux_config build/linux-sunxi/.config
@$(MAKE) -C src/linux O=../../build/linux-sunxi $(CROSS_FLAGS) olddefconfig
@$(MAKE) -C src/linux O=../../build/linux-sunxi $(CROSS_FLAGS)
@cp build/linux-sunxi/arch/arm64/boot/Image.gz $@
@cp build/linux-sunxi/arch/arm64/boot/dts/allwinner/*.dtb dtbs/sunxi/
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
%.scr: src/%.txt
@echo "MKIMG $@"
@mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $< $@
2020-03-16 14:49:12 +00:00
u-boot-sunxi-with-spl.bin:
2020-03-17 18:19:34 +00:00
@echo "WGET $@"
@wget http://dl-cdn.alpinelinux.org/alpine/edge/main/aarch64/u-boot-pine64-2020.01-r0.apk
@tar -xvf u-boot-pine64-2020.01-r0.apk usr/share/u-boot/pine64-lts/u-boot-sunxi-with-spl.bin --strip-components 4
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
.PHONY: clean cleanfast
cleanfast:
@rm -rvf build
2020-04-15 00:10:13 +00:00
@rm -rvf initramfs-*/
2020-03-17 18:19:34 +00:00
@rm -vf *.img
@rm -vf *.img.xz
@rm -vf *.apk
@rm -vf *.bin
@rm -vf *.cpio
@rm -vf *.gz
@rm -vf *.scr
@rm -vf splash/*.gz
2020-03-16 14:49:12 +00:00
2020-03-17 18:19:34 +00:00
clean: cleanfast
@rm -vf kernel*.gz
@rm -vf initramfs/bin/busybox
@rm -vrf dtbs