makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. # This file is part of PrawnOS (http://www.prawnos.com)
  2. # Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
  3. # PrawnOS is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License version 2
  5. # as published by the Free Software Foundation.
  6. # PrawnOS is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  12. KVER=5.4.29
  13. ifeq ($(DEBIAN_SUITE),)
  14. DEBIAN_SUITE=buster
  15. endif
  16. ifeq ($(PRAWNOS_SUITE),)
  17. PRAWNOS_SUITE=Shiba
  18. endif
  19. OUTNAME=PrawnOS-$(PRAWNOS_SUITE)-c201.img
  20. BASE=$(OUTNAME)-BASE
  21. PRAWNOS_ROOT := $(shell git rev-parse --show-toplevel)
  22. include $(PRAWNOS_ROOT)/scripts/common.mk
  23. #Usage:
  24. #run make image
  25. #this will generate two images named OUTNAME and OUTNAME-BASE
  26. #-BASE is only the filesystem with no kernel.
  27. #if you make any changes to the kernel or kernel config with make kernel_config
  28. #run kernel_inject
  29. #:::::::::::::::::::::::::::::: cleaning ::::::::::::::::::::::::::::::
  30. .PHONY: clean
  31. clean:
  32. @echo "Enter one of:"
  33. @echo " clean_kernel - which deletes the untar'd kernel folder from build"
  34. @echo " clean_ath - which deletes the untar'd ath9k driver folder from build"
  35. @echo " clean_img - which deletes the built PrawnOS image, this is ran when make image is ran"
  36. @echo " clean_basefs - which deletes the built PrawnOS base image"
  37. @echo " clean_initramfs - which deletes the built PrawnOS initramfs image that gets injected into the kernel"
  38. @echo " clean_all - which does all of the above"
  39. @echo " in most cases none of these need to be used manually as most cleanup steps are handled automatically"
  40. .PHONY: clean_kernel
  41. clean_kernel:
  42. rm -rf build/linux-$(KVER)
  43. .PHONY: clean_ath
  44. clean_ath:
  45. rm -rf build/open-ath9k-htc-firmware
  46. .PHONY: clean_img
  47. clean_img:
  48. rm -f $(OUTNAME)
  49. .PHONY: clean_basefs
  50. clean_basefs:
  51. rm -r $(BASE)
  52. .PHONY: clean_initramfs
  53. clean_initramfs:
  54. rm -r build/PrawnOS-initramfs.cpio.gz
  55. .PHONY: clean_pbuilder
  56. clean_pbuilder:
  57. rm -r build/prawnos-pbuilder-armhf-base.tgz
  58. .PHONY: clean_all
  59. clean_all:
  60. $(MAKE) clean_kernel
  61. $(MAKE) clean_ath
  62. $(MAKE) clean_img
  63. $(MAKE) clean_basefs
  64. $(MAKE) clean_initramfs
  65. $(MAKE) clean_pbuilder
  66. #:::::::::::::::::::::::::::::: premake prep ::::::::::::::::::::::::::::::
  67. .PHONY: build_dirs
  68. build_dirs:
  69. mkdir -p build/logs/
  70. #:::::::::::::::::::::::::::::: kernel ::::::::::::::::::::::::::::::::::::
  71. .PHONY: kernel
  72. kernel:
  73. $(MAKE) build_dirs
  74. rm -rf build/logs/kernel-log.txt
  75. ./scripts/buildKernel.sh $(KVER) 2>&1 | tee build/logs/kernel-log.txt
  76. .PHONY: kernel_config
  77. kernel_config:
  78. scripts/crossmenuconfig.sh $(KVER)
  79. .PHONY: patch_kernel
  80. patch_kernel:
  81. scripts/patchKernel.sh
  82. #:::::::::::::::::::::::::::::: initramfs :::::::::::::::::::::::::::::::::
  83. .PHONY: initramfs
  84. initramfs:
  85. $(MAKE) build_dirs
  86. rm -rf build/logs/initramfs-log.txt
  87. ./scripts/buildInitramFs.sh $(BASE) 2>&1 | tee build/logs/initramfs-log.txt
  88. #:::::::::::::::::::::::::::::: filesystem ::::::::::::::::::::::::::::::::
  89. #makes the base filesystem image without kernel. Only make a new one if the base image isnt present
  90. .PHONY: filesystem
  91. filesystem:
  92. $(MAKE) build_dirs
  93. rm -rf build/logs/fs-log.txt
  94. $(MAKE) pbuilder_create
  95. [ -f $(BASE) ] || ./scripts/buildFilesystem.sh $(KVER) $(DEBIAN_SUITE) $(BASE) 2>&1 | tee build/logs/fs-log.txt
  96. #:::::::::::::::::::::::::::::: packages ::::::::::::::::::::::::::::::::
  97. .PHONY: packages
  98. packages:
  99. cd packages && $(MAKE)
  100. #:::::::::::::::::::::::::::::: image management ::::::::::::::::::::::::::
  101. .PHONY: kernel_inject
  102. kernel_inject: #Targets an already built .img and swaps the old kernel with the newly compiled kernel
  103. scripts/injectKernelIntoFS.sh $(KVER) $(OUTNAME)
  104. .PHONY: kernel_update
  105. kernel_update:
  106. $(MAKE) clean_img
  107. $(MAKE) initramfs
  108. $(MAKE) kernel
  109. cp $(BASE) $(OUTNAME)
  110. $(MAKE) kernel_inject
  111. .PHONY: image
  112. image:
  113. $(MAKE) clean_img
  114. $(MAKE) filesystem
  115. $(MAKE) initramfs
  116. $(MAKE) kernel
  117. cp $(BASE) $(OUTNAME)
  118. $(MAKE) kernel_inject
  119. #:::::::::::::::::::::::::::::: pbuilder management :::::::::::::::::::::::
  120. .PHONY: pbuilder_create
  121. pbuilder_create:
  122. $(MAKE) $(PBUILDER_CHROOT)
  123. $(PBUILDER_CHROOT):
  124. pbuilder create --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)
  125. #TODO: should only update if not updated for a day
  126. .PHONY: pbuilder_update
  127. pbuilder_update:
  128. pbuilder update --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)