Makefile 7.8 KB

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