Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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: update
  31. @:
  32. _Makefile_:
  33. @:
  34. %/Makefile:
  35. @:
  36. buildroot: buildroot/README
  37. @:
  38. buildroot/README:
  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. update: fun
  68. @$(call MESSAGE,"Creating update file")
  69. @rm -rf tmp
  70. @mkdir -p tmp
  71. @cp FunKey/board/funkey/sw-description tmp/
  72. @tar -C FunKey/output/images -zcf tmp/rootfs.ext2.tar.gz rootfs.ext2
  73. @cd tmp && \
  74. echo sw-description rootfs.ext2.tar.gz | \
  75. tr " " "\n" | \
  76. cpio -o -H crc --quiet > ../images/FunKey-$(shell cat FunKey/board/funkey/rootfs-overlay/etc/sw-versions | cut -f 2).swu
  77. @rm -rf tmp
  78. defconfig:
  79. @$(call MESSAGE,"Updating default configs")
  80. @$(call MESSAGE,"Updating default configs in Recovery")
  81. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output savedefconfig linux-update-defconfig uboot-update-defconfig busybox-update-config
  82. @$(call MESSAGE,"Updating default configs in FunKey")
  83. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output savedefconfig linux-update-defconfig uboot-update-defconfig busybox-update-config
  84. clean:
  85. @$(call MESSAGE,"Clean everything")
  86. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output distclean
  87. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output distclean
  88. distclean: clean
  89. @$(call MESSAGE,"Really clean everything")
  90. @rm -rf download images
  91. FunKey/output/.config:
  92. @$(call MESSAGE,"Configure FunKey")
  93. @mkdir -p FunKey/board/funkey/patches
  94. @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output funkey_defconfig
  95. Recovery/output/.config:
  96. @$(call MESSAGE,"Configure Recovery")
  97. @mkdir -p Recovery/board/funkey/patches
  98. @$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output recovery_defconfig