Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. PICOLIN_LINUX_SRC=linux-4.4
  2. PICOLIN_LINUX_PKG=linux-4.4.tar.xz
  3. PICOLIN_LINUX_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz
  4. PICOLIN_BUSYBOX_SRC=busybox-1.24.1
  5. PICOLIN_BUSYBOX_PKG=busybox-1.24.1.tar.bz2
  6. PICOLIN_BUSYBOX_URL=http://busybox.net/downloads/busybox-1.24.1.tar.bz2
  7. all: setup picolin-kernel picolin-initrd
  8. boot:
  9. qemu-system-x86_64 -enable-kvm -kernel out/bzImage -initrd out/initrd -append init=/bin/sh
  10. # build linux kernel
  11. picolin-kernel: out/bzImage
  12. out/bzImage: src/$(PICOLIN_LINUX_SRC)/.config
  13. cd "src/$(PICOLIN_LINUX_SRC)" && make -j2
  14. cp "src/$(PICOLIN_LINUX_SRC)/arch/x86/boot/bzImage" out/bzImage
  15. # build initial ramdisk
  16. picolin-initrd: out/initrd
  17. out/initrd: src/$(PICOLIN_BUSYBOX_SRC)/busybox rootfs
  18. cd src/rootfs && find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../../out/initrd
  19. rootfs: src/$(PICOLIN_BUSYBOX_SRC)/busybox
  20. mkdir -p src/rootfs
  21. rm -r src/rootfs/* || true
  22. cd src/rootfs && mkdir -p bin sbin etc proc sys usr/bin usr/sbin
  23. cp -av src/$(PICOLIN_BUSYBOX_SRC)/_install/* src/rootfs/
  24. src/$(PICOLIN_BUSYBOX_SRC)/busybox: src/$(PICOLIN_BUSYBOX_SRC)/.config
  25. cd "src/$(PICOLIN_BUSYBOX_SRC)" && make -j2 && make install
  26. # download packages and uncompress
  27. setup: download uncompress
  28. uncompress: src/$(PICOLIN_LINUX_SRC)/README src/$(PICOLIN_BUSYBOX_SRC)/README
  29. download: pkg/$(PICOLIN_LINUX_PKG) pkg/$(PICOLIN_BUSYBOX_PKG)
  30. src/$(PICOLIN_LINUX_SRC)/README:
  31. cd src && tar xvf "../pkg/$(PICOLIN_LINUX_PKG)"
  32. cd src/$(PICOLIN_LINUX_SRC) && ln -s ../../etc/linux-config .config
  33. src/$(PICOLIN_BUSYBOX_SRC)/README:
  34. cd src && tar xvf "../pkg/$(PICOLIN_BUSYBOX_PKG)"
  35. cd src/$(PICOLIN_BUSYBOX_SRC) && ln -s ../../etc/busybox-config .config
  36. pkg/$(PICOLIN_LINUX_PKG):
  37. cd pkg && wget "$(PICOLIN_LINUX_URL)"
  38. pkg/$(PICOLIN_BUSYBOX_PKG):
  39. cd pkg && wget "$(PICOLIN_BUSYBOX_URL)"