Makefile 8.8 KB

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