Makefile 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. all:
  2. LC_ALL:=C
  3. LANG:=C
  4. export LC_ALL LANG
  5. empty:=
  6. space:= $(empty) $(empty)
  7. GLUONMAKE = $(SUBMAKE) -C $(GLUON_OPENWRTDIR) -f $(GLUONDIR)/Makefile
  8. ifneq ($(OPENWRT_BUILD),1)
  9. GLUONDIR:=${CURDIR}
  10. include $(GLUONDIR)/include/gluon.mk
  11. TOPDIR:=$(GLUON_OPENWRTDIR)
  12. export TOPDIR
  13. GLUON_TARGET ?= ar71xx-generic
  14. export GLUON_TARGET
  15. update: FORCE
  16. $(GLUONDIR)/scripts/update.sh $(GLUONDIR)
  17. $(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
  18. patch: FORCE
  19. $(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
  20. unpatch: FORCE
  21. $(GLUONDIR)/scripts/unpatch.sh $(GLUONDIR)
  22. update-patches: FORCE
  23. $(GLUONDIR)/scripts/update.sh $(GLUONDIR)
  24. $(GLUONDIR)/scripts/update-patches.sh $(GLUONDIR)
  25. $(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
  26. -include $(TOPDIR)/include/host.mk
  27. _SINGLE=export MAKEFLAGS=$(space);
  28. override OPENWRT_BUILD=1
  29. override GLUON_TOOLS=1
  30. GREP_OPTIONS=
  31. export OPENWRT_BUILD GLUON_TOOLS GREP_OPTIONS
  32. -include $(TOPDIR)/include/debug.mk
  33. -include $(TOPDIR)/include/depends.mk
  34. include $(GLUONDIR)/include/toplevel.mk
  35. define GluonProfile
  36. image/$(1): FORCE
  37. +@$$(GLUONMAKE) $$@
  38. endef
  39. define GluonModel
  40. endef
  41. include $(GLUONDIR)/targets/targets.mk
  42. CheckExternal := test -d $(GLUON_OPENWRTDIR) || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
  43. gluon-tools: FORCE
  44. +@$(SUBMAKE) -C $(TOPDIR) prepare-tmpinfo OPENWRT_BUILD=0 V=s$(OPENWRT_VERBOSE)
  45. +@$(GLUONMAKE) gluon-tools GLUON_TOOLS=0
  46. all: gluon-tools
  47. +@$(GLUONMAKE) prepare
  48. +@$(GLUONMAKE) images
  49. download prepare images: gluon-tools
  50. +@$(GLUONMAKE) $@
  51. tools/% toolchain/% package/% target/%: gluon-tools
  52. +@$(GLUONMAKE) $@
  53. manifest: gluon-tools
  54. [ -n "$(GLUON_BRANCH)" ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
  55. +@$(GLUONMAKE) $@
  56. dirclean: clean
  57. @$(CheckExternal)
  58. +@$(SUBMAKE) -C $(TOPDIR) -r dirclean
  59. cleanall: clean
  60. @$(CheckExternal)
  61. +@$(SUBMAKE) -C $(TOPDIR) -r clean
  62. clean:
  63. @$(CheckExternal)
  64. +@$(GLUONMAKE) clean
  65. else
  66. include $(GLUONDIR)/include/gluon.mk
  67. include $(TOPDIR)/include/host.mk
  68. include rules.mk
  69. include $(INCLUDE_DIR)/depends.mk
  70. include $(INCLUDE_DIR)/subdir.mk
  71. include package/Makefile
  72. include tools/Makefile
  73. include toolchain/Makefile
  74. PROFILES :=
  75. PROFILE_PACKAGES :=
  76. define Profile
  77. $(eval $(call Profile/Default))
  78. $(eval $(call Profile/$(1)))
  79. $(1)_PACKAGES := $(PACKAGES)
  80. endef
  81. define GluonProfile
  82. PROFILES += $(1)
  83. PROFILE_PACKAGES += $(filter-out -%,$($(1)_PACKAGES) $(2) $(GLUON_$(1)_SITE_PACKAGES))
  84. GLUON_$(1)_DEFAULT_PACKAGES := $(2)
  85. GLUON_$(1)_MODELS :=
  86. endef
  87. define GluonModel
  88. GLUON_$(1)_MODELS += $(2)
  89. GLUON_$(1)_MODEL_$(2) := $(3)
  90. endef
  91. include $(GLUONDIR)/targets/targets.mk
  92. BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
  93. override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
  94. gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared
  95. include $(INCLUDE_DIR)/target.mk
  96. gluon-tools: $(STAGING_DIR_HOST)/bin/stat
  97. $(BUILD_DIR)/.prepared: Makefile
  98. @mkdir -p $$(dirname $@)
  99. @touch $@
  100. $(toolchain/stamp-install): $(tools/stamp-install)
  101. $(package/stamp-compile): $(package/stamp-cleanup)
  102. clean: FORCE
  103. rm -rf $(GLUON_BUILDDIR)
  104. refresh_feeds: FORCE
  105. export MAKEFLAGS=V=s$(OPENWRT_VERBOSE); \
  106. export SCAN_COOKIE=; \
  107. scripts/feeds uninstall -a; \
  108. scripts/feeds update -a; \
  109. scripts/feeds install -a
  110. export GLUON_GENERATE := $(GLUONDIR)/scripts/generate.sh
  111. export GLUON_CONFIGURE := $(GLUONDIR)/scripts/configure.pl
  112. feeds: FORCE
  113. ( \
  114. [ ! -f $(GLUON_SITEDIR)/modules ] || . $(GLUON_SITEDIR)/modules && for feed in $$GLUON_SITE_FEEDS; do echo src-link $$feed ../../packages/$$feed; done; \
  115. . $(GLUONDIR)/modules && for feed in $$GLUON_FEEDS; do echo src-link $$feed ../../packages/$$feed; done; \
  116. ) > feeds.conf
  117. +$(GLUONMAKE) refresh_feeds V=s$(OPENWRT_VERBOSE)
  118. +$(NO_TRACE_MAKE) -C $(TOPDIR) prepare-tmpinfo OPENWRT_BUILD=0
  119. config: FORCE
  120. ( \
  121. cat $(GLUONDIR)/include/config $(GLUONDIR)/targets/$(GLUON_TARGET)/config; \
  122. echo '$(patsubst %,CONFIG_PACKAGE_%=m,$(sort $(filter-out -%,$(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES) $(PROFILE_PACKAGES))))' \
  123. | sed -e 's/ /\n/g'; \
  124. ) > $(BOARD_BUILDDIR)/config
  125. +$(NO_TRACE_MAKE) scripts/config/conf OPENWRT_BUILD=0
  126. scripts/config/conf -D $(BOARD_BUILDDIR)/config -w $(BOARD_BUILDDIR)/config Config.in
  127. ln -sf $(BOARD_BUILDDIR)/config .config
  128. .config:
  129. +$(GLUONMAKE) config
  130. download: .config FORCE
  131. +$(SUBMAKE) tools/download
  132. +$(SUBMAKE) toolchain/download
  133. +$(SUBMAKE) package/download
  134. +$(SUBMAKE) target/download
  135. toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
  136. include $(INCLUDE_DIR)/kernel.mk
  137. kernel: FORCE
  138. +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.image TARGET_BUILD=1
  139. +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules TARGET_BUILD=1
  140. packages: $(package/stamp-compile)
  141. $(_SINGLE)$(SUBMAKE) -r package/index
  142. prepare-image: FORCE
  143. rm -rf $(BOARD_KDIR)
  144. mkdir -p $(BOARD_KDIR)
  145. cp $(KERNEL_BUILD_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf $(BOARD_KDIR)/
  146. +$(SUBMAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image -f $(GLUONDIR)/include/Makefile.image prepare KDIR="$(BOARD_KDIR)"
  147. CheckSite := (perl $(GLUON_SITEDIR)/site.conf 2>&1) > /dev/null || (echo 'Your site configuration did not pass validation; please verify yourself with `perl site.conf` and fix the problems.';false)
  148. prepare: FORCE
  149. @$(CheckSite)
  150. mkdir -p $(GLUON_IMAGEDIR) $(BOARD_BUILDDIR)
  151. echo 'src packages file:../openwrt/bin/$(BOARD)/packages' > $(BOARD_BUILDDIR)/opkg.conf
  152. +$(GLUONMAKE) feeds
  153. +$(GLUONMAKE) config
  154. +$(GLUONMAKE) toolchain
  155. +$(GLUONMAKE) kernel
  156. +$(GLUONMAKE) packages
  157. +$(GLUONMAKE) prepare-image
  158. echo "$(GLUON_RELEASE)" > $(gluon_prepared_stamp)
  159. $(gluon_prepared_stamp):
  160. +$(GLUONMAKE) prepare
  161. include $(INCLUDE_DIR)/package-ipkg.mk
  162. # override variables from rules.mk
  163. PACKAGE_DIR = $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
  164. PROFILE_BUILDDIR = $(BOARD_BUILDDIR)/$(PROFILE)
  165. PROFILE_KDIR = $(PROFILE_BUILDDIR)/kernel
  166. BIN_DIR = $(PROFILE_BUILDDIR)/images
  167. TMP_DIR = $(PROFILE_BUILDDIR)/tmp
  168. TARGET_DIR = $(PROFILE_BUILDDIR)/root
  169. IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$$(cat $(gluon_prepared_stamp))
  170. OPKG:= \
  171. IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
  172. IPKG_INSTROOT="$(TARGET_DIR)" \
  173. IPKG_CONF_DIR="$(TMP_DIR)" \
  174. IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
  175. $(STAGING_DIR_HOST)/bin/opkg \
  176. -f $(BOARD_BUILDDIR)/opkg.conf \
  177. --force-depends \
  178. --force-overwrite \
  179. --force-postinstall \
  180. --cache $(TMP_DIR)/dl \
  181. --offline-root $(TARGET_DIR) \
  182. --add-dest root:/ \
  183. --add-arch all:100 \
  184. --add-arch $(ARCH_PACKAGES):200
  185. EnableInitscript = ! grep -q '\#!/bin/sh /etc/rc.common' $(1) || bash ./etc/rc.common $(1) enable
  186. enable_initscripts: FORCE
  187. cd $(TARGET_DIR) && ( export IPKG_INSTROOT=$(TARGET_DIR); \
  188. $(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
  189. $(call EnableInitscript,$(script)); \
  190. ) : \
  191. )
  192. # Generate package list
  193. $(eval $(call merge-lists,INSTALL_PACKAGES,DEFAULT_PACKAGES $(PROFILE)_PACKAGES GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
  194. package_install: FORCE
  195. $(OPKG) update
  196. $(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
  197. $(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
  198. $(OPKG) install $(INSTALL_PACKAGES)
  199. +$(GLUONMAKE) enable_initscripts
  200. rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
  201. image: FORCE
  202. rm -rf $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(PROFILE_KDIR)
  203. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(TARGET_DIR)/tmp $(GLUON_IMAGEDIR)/factory $(GLUON_IMAGEDIR)/sysupgrade
  204. cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
  205. +$(GLUONMAKE) package_install
  206. $(call Image/mkfs/prepare)
  207. $(_SINGLE)$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 IMG_PREFIX=gluon \
  208. PROFILE="$(PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"
  209. $(foreach model,$(GLUON_$(PROFILE)_MODELS), \
  210. rm -f $(GLUON_IMAGEDIR)/factory/gluon-*-$(GLUON_$(PROFILE)_MODEL_$(model)).bin && \
  211. rm -f $(GLUON_IMAGEDIR)/sysupgrade/gluon-*-$(GLUON_$(PROFILE)_MODEL_$(model))-sysupgrade.bin && \
  212. \
  213. cp $(BIN_DIR)/gluon-$(model)-factory.bin $(GLUON_IMAGEDIR)/factory/$(IMAGE_PREFIX)-$(GLUON_$(PROFILE)_MODEL_$(model)).bin && \
  214. cp $(BIN_DIR)/gluon-$(model)-sysupgrade.bin $(GLUON_IMAGEDIR)/sysupgrade/$(IMAGE_PREFIX)-$(GLUON_$(PROFILE)_MODEL_$(model))-sysupgrade.bin && \
  215. ) :
  216. image/%: $(gluon_prepared_stamp)
  217. +$(GLUONMAKE) image PROFILE="$(patsubst image/%,%,$@)" V=s$(OPENWRT_VERBOSE)
  218. call_image/%: FORCE
  219. +$(GLUONMAKE) $(patsubst call_image/%,image/%,$@)
  220. images: $(patsubst %,call_image/%,$(PROFILES)) ;
  221. manifest: FORCE
  222. mkdir -p $(GLUON_IMAGEDIR)/sysupgrade
  223. (cd $(GLUON_IMAGEDIR)/sysupgrade && echo 'BRANCH=$(GLUON_BRANCH)' && echo && ($(foreach profile,$(PROFILES), \
  224. $(foreach model,$(GLUON_$(profile)_MODELS), \
  225. for file in gluon-*-'$(GLUON_$(profile)_MODEL_$(model))-sysupgrade.bin'; do \
  226. [ -e "$$file" ] && echo \
  227. '$(GLUON_$(profile)_MODEL_$(model))' \
  228. "$$(echo "$$file" | sed -n -r -e 's/^gluon-$(call regex-escape,$(GLUON_SITE_CODE))-(.*)-$(call regex-escape,$(GLUON_$(profile)_MODEL_$(model)))-sysupgrade\.bin$$/\1/p')" \
  229. "$$(sha512sum "$$file" | awk '{print $$1}')" \
  230. "$$file" && break; \
  231. done; \
  232. ) \
  233. ) :)) > $(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest
  234. .PHONY: all images prepare clean cleanall gluon-tools
  235. endif