Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Makefile for FunKey-OS
  2. #
  3. # Copyright (C) 2020 by Michel Stempin <michel.stempin@funkey-project.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. BRMAKE = buildroot/utils/brmake -C buildroot
  20. BR = make -C buildroot
  21. # Strip quotes and then whitespaces
  22. qstrip = $(strip $(subst ",,$(1)))
  23. #"))
  24. # MESSAGE Macro -- display a message in bold type
  25. MESSAGE = echo "$(shell date +%Y-%m-%dT%H:%M:%S) $(TERM_BOLD)\#\#\# $(call qstrip,$(1))$(TERM_RESET)"
  26. TERM_BOLD := $(shell tput smso 2>/dev/null)
  27. TERM_RESET := $(shell tput rmso 2>/dev/null)
  28. .PHONY: fun source image update defconfig clean distclean
  29. .IGNORE: _Makefile_
  30. all: image update
  31. @:
  32. _Makefile_:
  33. @:
  34. %/Makefile:
  35. @:
  36. buildroot: buildroot/.git
  37. @:
  38. buildroot/.git:
  39. @$(call MESSAGE,"Getting buildroot")
  40. @git submodule init
  41. @git submodule update
  42. fun: buildroot Recovery/output/.config FunKey/output/.config
  43. @$(call MESSAGE,"Making fun")
  44. @$(call MESSAGE,"Making fun in Recovery")
  45. @$(BRMAKE) BR2_EXTERNAL=../Recovery O=../Recovery/output
  46. @$(call MESSAGE,"Making fun in FunKey")
  47. @$(BRMAKE) BR2_EXTERNAL=../FunKey O=../FunKey/output
  48. FunKey/%: FunKey/output/.config
  49. @$(call MESSAGE,"Making $(notdir $@) in $(subst /,,$(dir $@))")
  50. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output $(notdir $@)
  51. Recovery/%: Recovery/output/.config
  52. @$(call MESSAGE,"Making $(notdir $@) in $(subst /,,$(dir $@))")
  53. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output $(notdir $@)
  54. #%: FunKey/output/.config
  55. # @$(call MESSAGE,"Making $@ in FunKey")
  56. # @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output $@
  57. source:
  58. @$(call MESSAGE,"Getting sources")
  59. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output source
  60. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output source
  61. image: fun
  62. @$(call MESSAGE,"Creating disk image")
  63. @rm -rf root tmp
  64. @mkdir -p root tmp
  65. @./Recovery/output/host/bin/genimage --loglevel 0 --inputpath .
  66. @rm -rf root tmp
  67. image-prod: fun
  68. @$(call MESSAGE,"Creating disk image")
  69. @rm -rf root tmp
  70. @mkdir -p root tmp
  71. @./Recovery/output/host/bin/genimage --loglevel 0 --config "genimage-prod.cfg" --inputpath .
  72. @rm -rf root tmp
  73. update: fun
  74. @$(call MESSAGE,"Creating update file")
  75. @rm -rf tmp
  76. @mkdir -p tmp
  77. @cp FunKey/board/funkey/sw-description tmp/
  78. @cp FunKey/board/funkey/update_partition tmp/
  79. @cd FunKey/output/images && \
  80. rm -f rootfs.ext2.gz && \
  81. gzip -k rootfs.ext2 &&\
  82. mv rootfs.ext2.gz ../../../tmp/
  83. @cd tmp && \
  84. echo sw-description rootfs.ext2.gz update_partition | \
  85. tr " " "\n" | \
  86. cpio -o -H crc --quiet > ../images/FunKey-rootfs-$(shell cat FunKey/board/funkey/rootfs-overlay/etc/sw-versions | cut -f 2).fwu
  87. @rm -rf tmp
  88. defconfig:
  89. @$(call MESSAGE,"Updating default configs")
  90. @$(call MESSAGE,"Updating default configs in Recovery")
  91. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output savedefconfig linux-update-defconfig uboot-update-defconfig busybox-update-config
  92. @$(call MESSAGE,"Updating default configs in FunKey")
  93. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output savedefconfig linux-update-defconfig busybox-update-config
  94. clean:
  95. @$(call MESSAGE,"Clean everything")
  96. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output distclean
  97. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output distclean
  98. @rm -f br.log
  99. distclean: clean
  100. @$(call MESSAGE,"Really clean everything")
  101. @rm -rf download images
  102. FunKey/output/.config:
  103. @$(call MESSAGE,"Configure FunKey")
  104. @mkdir -p FunKey/board/funkey/patches
  105. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output funkey_defconfig
  106. Recovery/output/.config:
  107. @$(call MESSAGE,"Configure Recovery")
  108. @mkdir -p Recovery/board/funkey/patches
  109. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output recovery_defconfig