makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 pwd)
  22. PBUILDER_CHROOT=$(PRAWNOS_ROOT)/build/prawnos-pbuilder-armhf-base.tgz
  23. PBUILDER_RC=$(PRAWNOS_ROOT)/resources/BuildResources/pbuilder/prawnos-pbuilder.rc
  24. # Otherwise errors are ignored when output is piped to tee:
  25. SHELL=/bin/bash -o pipefail
  26. #Usage:
  27. #run make image
  28. #this will generate two images named OUTNAME and OUTNAME-BASE
  29. #-BASE is only the filesystem with no kernel.
  30. #if you make any changes to the kernel or kernel config with make kernel_config
  31. #run kernel_inject
  32. #:::::::::::::::::::::::::::::: cleaning ::::::::::::::::::::::::::::::
  33. .PHONY: clean
  34. clean:
  35. @echo "Enter one of:"
  36. @echo " clean_kernel - which deletes the untar'd kernel folder from build"
  37. @echo " clean_ath - which deletes the untar'd ath9k driver folder from build"
  38. @echo " clean_img - which deletes the built PrawnOS image, this is ran when make image is ran"
  39. @echo " clean_basefs - which deletes the built PrawnOS base image"
  40. @echo " clean_initramfs - which deletes the built PrawnOS initramfs image that gets injected into the kernel"
  41. @echo " clean_all - which does all of the above"
  42. @echo " in most cases none of these need to be used manually as most cleanup steps are handled automatically"
  43. .PHONY: clean_kernel
  44. clean_kernel:
  45. rm -rf build/linux-$(KVER)
  46. .PHONY: clean_ath
  47. clean_ath:
  48. rm -rf build/open-ath9k-htc-firmware
  49. .PHONY: clean_img
  50. clean_img:
  51. rm -f $(OUTNAME)
  52. .PHONY: clean_basefs
  53. clean_basefs:
  54. rm -r $(BASE)
  55. .PHONY: clean_initramfs
  56. clean_initramfs:
  57. rm -r build/PrawnOS-initramfs.cpio.gz
  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. #:::::::::::::::::::::::::::::: premake prep ::::::::::::::::::::::::::::::
  70. .PHONY: build_dirs
  71. build_dirs:
  72. mkdir -p build/logs/
  73. #:::::::::::::::::::::::::::::: kernel ::::::::::::::::::::::::::::::::::::
  74. .PHONY: kernel
  75. kernel:
  76. $(MAKE) build_dirs
  77. rm -rf build/logs/kernel-log.txt
  78. ./scripts/buildKernel.sh $(KVER) 2>&1 | tee build/logs/kernel-log.txt
  79. .PHONY: kernel_config
  80. kernel_config:
  81. scripts/crossmenuconfig.sh $(KVER)
  82. .PHONY: patch_kernel
  83. patch_kernel:
  84. scripts/patchKernel.sh
  85. #:::::::::::::::::::::::::::::: initramfs :::::::::::::::::::::::::::::::::
  86. .PHONY: initramfs
  87. initramfs:
  88. $(MAKE) build_dirs
  89. rm -rf build/logs/initramfs-log.txt
  90. ./scripts/buildInitramFs.sh $(BASE) 2>&1 | tee build/logs/initramfs-log.txt
  91. #:::::::::::::::::::::::::::::: filesystem ::::::::::::::::::::::::::::::::
  92. #makes the base filesystem image without kernel. Only make a new one if the base image isnt present
  93. .PHONY: filesystem
  94. filesystem:
  95. $(MAKE) build_dirs
  96. rm -rf build/logs/fs-log.txt
  97. $(MAKE) pbuilder_create
  98. [ -f $(BASE) ] || ./scripts/buildFilesystem.sh $(KVER) $(DEBIAN_SUITE) $(BASE) 2>&1 | tee build/logs/fs-log.txt
  99. #:::::::::::::::::::::::::::::: image management ::::::::::::::::::::::::::
  100. .PHONY: kernel_inject
  101. kernel_inject: #Targets an already built .img and swaps the old kernel with the newly compiled kernel
  102. scripts/injectKernelIntoFS.sh $(KVER) $(OUTNAME)
  103. .PHONY: kernel_update
  104. kernel_update:
  105. $(MAKE) clean_img
  106. $(MAKE) initramfs
  107. $(MAKE) kernel
  108. cp $(BASE) $(OUTNAME)
  109. $(MAKE) kernel_inject
  110. .PHONY: image
  111. image:
  112. $(MAKE) clean_img
  113. $(MAKE) filesystem
  114. $(MAKE) initramfs
  115. $(MAKE) kernel
  116. cp $(BASE) $(OUTNAME)
  117. $(MAKE) kernel_inject
  118. #:::::::::::::::::::::::::::::: pbuilder management :::::::::::::::::::::::
  119. .PHONY: pbuilder_create
  120. pbuilder_create:
  121. $(MAKE) $(PBUILDER_CHROOT)
  122. $(PBUILDER_CHROOT): $(PBUILDER_RC)
  123. pbuilder create --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)
  124. #TODO: should only update if not updated for a day
  125. .PHONY: pbuilder_update
  126. pbuilder_update:
  127. pbuilder update --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)