Makefile 7.2 KB

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