makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # This file is part of PrawnOS (https://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_packages
  56. clean_packages:
  57. cd packages && $(MAKE) clean
  58. .PHONY: clean_pbuilder
  59. clean_pbuilder:
  60. rm -r build/prawnos-pbuilder-armhf-base.tgz
  61. .PHONY: clean_all
  62. clean_all:
  63. $(MAKE) clean_kernel
  64. $(MAKE) clean_ath
  65. $(MAKE) clean_img
  66. $(MAKE) clean_basefs
  67. $(MAKE) clean_initramfs
  68. $(MAKE) clean_pbuilder
  69. $(MAKE) clean_packages
  70. #:::::::::::::::::::::::::::::: premake prep ::::::::::::::::::::::::::::::
  71. .PHONY: build_dirs
  72. build_dirs:
  73. mkdir -p build/logs/
  74. mkdir -p build/apt-cache/
  75. #:::::::::::::::::::::::::::::: kernel ::::::::::::::::::::::::::::::::::::
  76. .PHONY: kernel
  77. kernel:
  78. $(MAKE) build_dirs
  79. rm -rf build/logs/kernel-log.txt
  80. ./scripts/buildKernel.sh $(KVER) 2>&1 | tee build/logs/kernel-log.txt
  81. .PHONY: kernel_config
  82. kernel_config:
  83. scripts/crossmenuconfig.sh $(KVER)
  84. .PHONY: patch_kernel
  85. patch_kernel:
  86. scripts/patchKernel.sh
  87. #:::::::::::::::::::::::::::::: initramfs :::::::::::::::::::::::::::::::::
  88. .PHONY: initramfs
  89. initramfs:
  90. $(MAKE) build_dirs
  91. rm -rf build/logs/initramfs-log.txt
  92. ./scripts/buildInitramFs.sh $(BASE) 2>&1 | tee build/logs/initramfs-log.txt
  93. #:::::::::::::::::::::::::::::: filesystem ::::::::::::::::::::::::::::::::
  94. #makes the base filesystem image without kernel. Only make a new one if the base image isnt present
  95. .PHONY: filesystem
  96. filesystem:
  97. $(MAKE) build_dirs
  98. rm -rf build/logs/fs-log.txt
  99. $(MAKE) pbuilder_create
  100. $(MAKE) packages
  101. [ -f $(BASE) ] || ./scripts/buildFilesystem.sh $(KVER) $(DEBIAN_SUITE) $(BASE) $(PRAWNOS_ROOT) 2>&1 | tee build/logs/fs-log.txt
  102. #:::::::::::::::::::::::::::::: packages ::::::::::::::::::::::::::::::::
  103. .PHONY: packages
  104. packages:
  105. cd packages && $(MAKE)
  106. .PHONY: packages_install
  107. packages_install:
  108. ifndef INSTALL_TARGET
  109. $(error INSTALL_TARGET is not set)
  110. endif
  111. cd packages && $(MAKE) install INSTALL_TARGET=$(INSTALL_TARGET)
  112. #:::::::::::::::::::::::::::::: image management ::::::::::::::::::::::::::
  113. .PHONY: kernel_inject
  114. kernel_inject: #Targets an already built .img and swaps the old kernel with the newly compiled kernel
  115. scripts/injectKernelIntoFS.sh $(KVER) $(OUTNAME)
  116. .PHONY: kernel_update
  117. kernel_update:
  118. $(MAKE) clean_img
  119. $(MAKE) initramfs
  120. $(MAKE) kernel
  121. cp $(BASE) $(OUTNAME)
  122. $(MAKE) kernel_inject
  123. .PHONY: image
  124. image:
  125. $(MAKE) clean_img
  126. $(MAKE) filesystem
  127. $(MAKE) initramfs
  128. $(MAKE) kernel
  129. cp $(BASE) $(OUTNAME)
  130. $(MAKE) kernel_inject
  131. #:::::::::::::::::::::::::::::: pbuilder management :::::::::::::::::::::::
  132. .PHONY: pbuilder_create
  133. pbuilder_create:
  134. $(MAKE) $(PBUILDER_CHROOT)
  135. $(PBUILDER_CHROOT):
  136. pbuilder create --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)
  137. #TODO: should only update if not updated for a day
  138. .PHONY: pbuilder_update
  139. pbuilder_update:
  140. pbuilder update --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)