makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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_packages
  56. 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. #:::::::::::::::::::::::::::::: kernel ::::::::::::::::::::::::::::::::::::
  75. .PHONY: kernel
  76. kernel:
  77. $(MAKE) build_dirs
  78. rm -rf build/logs/kernel-log.txt
  79. ./scripts/buildKernel.sh $(KVER) 2>&1 | tee build/logs/kernel-log.txt
  80. .PHONY: kernel_config
  81. kernel_config:
  82. scripts/crossmenuconfig.sh $(KVER)
  83. .PHONY: patch_kernel
  84. patch_kernel:
  85. scripts/patchKernel.sh
  86. #:::::::::::::::::::::::::::::: initramfs :::::::::::::::::::::::::::::::::
  87. .PHONY: initramfs
  88. initramfs:
  89. $(MAKE) build_dirs
  90. rm -rf build/logs/initramfs-log.txt
  91. ./scripts/buildInitramFs.sh $(BASE) 2>&1 | tee build/logs/initramfs-log.txt
  92. #:::::::::::::::::::::::::::::: filesystem ::::::::::::::::::::::::::::::::
  93. #makes the base filesystem image without kernel. Only make a new one if the base image isnt present
  94. .PHONY: filesystem
  95. filesystem:
  96. $(MAKE) build_dirs
  97. rm -rf build/logs/fs-log.txt
  98. $(MAKE) pbuilder_create
  99. [ -f $(BASE) ] || ./scripts/buildFilesystem.sh $(KVER) $(DEBIAN_SUITE) $(BASE) 2>&1 | tee build/logs/fs-log.txt
  100. #:::::::::::::::::::::::::::::: packages ::::::::::::::::::::::::::::::::
  101. .PHONY: packages
  102. packages:
  103. cd packages && $(MAKE)
  104. .PHONY: packages_install
  105. install_packages:
  106. cd packages && $(MAKE) install INSTALL_TARGET=/tmp/
  107. #:::::::::::::::::::::::::::::: image management ::::::::::::::::::::::::::
  108. .PHONY: kernel_inject
  109. kernel_inject: #Targets an already built .img and swaps the old kernel with the newly compiled kernel
  110. scripts/injectKernelIntoFS.sh $(KVER) $(OUTNAME)
  111. .PHONY: kernel_update
  112. kernel_update:
  113. $(MAKE) clean_img
  114. $(MAKE) initramfs
  115. $(MAKE) kernel
  116. cp $(BASE) $(OUTNAME)
  117. $(MAKE) kernel_inject
  118. .PHONY: image
  119. image:
  120. $(MAKE) clean_img
  121. $(MAKE) filesystem
  122. $(MAKE) initramfs
  123. $(MAKE) kernel
  124. cp $(BASE) $(OUTNAME)
  125. $(MAKE) kernel_inject
  126. #:::::::::::::::::::::::::::::: pbuilder management :::::::::::::::::::::::
  127. .PHONY: pbuilder_create
  128. pbuilder_create:
  129. $(MAKE) $(PBUILDER_CHROOT)
  130. $(PBUILDER_CHROOT):
  131. pbuilder create --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)
  132. #TODO: should only update if not updated for a day
  133. .PHONY: pbuilder_update
  134. pbuilder_update:
  135. pbuilder update --basetgz $(PBUILDER_CHROOT) --configfile $(PBUILDER_RC)