Makefile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. . $(GLUONDIR)/modules && for feed in $$GLUON_FEEDS; do echo src-link $$feed ../../packages/$$feed; done > feeds.conf
  100. +$(GLUONMAKE) refresh_feeds V=s$(OPENWRT_VERBOSE)
  101. config: FORCE
  102. echo \
  103. 'CONFIG_TARGET_$(BOARD)=y' \
  104. 'CONFIG_TARGET_ROOTFS_JFFS2=n' \
  105. '$(patsubst %,CONFIG_PACKAGE_%=m,$(sort $(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES) $(PROFILE_PACKAGES)))' \
  106. | sed -e 's/ /\n/g' > .config
  107. $(_SINGLE)$(SUBMAKE) defconfig OPENWRT_BUILD=
  108. .config:
  109. +$(GLUONMAKE) config
  110. download: .config FORCE
  111. +$(SUBMAKE) tools/download
  112. +$(SUBMAKE) toolchain/download
  113. +$(SUBMAKE) package/download
  114. +$(SUBMAKE) target/download
  115. toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
  116. include $(INCLUDE_DIR)/kernel.mk
  117. kernel: FORCE
  118. +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.image TARGET_BUILD=1
  119. +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules TARGET_BUILD=1
  120. packages: $(package/stamp-compile)
  121. $(_SINGLE)$(SUBMAKE) -r package/index
  122. prepare-image: FORCE
  123. rm -rf $(BOARD_KDIR)
  124. mkdir -p $(BOARD_KDIR)
  125. cp $(KERNEL_BUILD_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf $(BOARD_KDIR)/
  126. +$(SUBMAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image -f $(GLUONDIR)/include/Makefile.image prepare KDIR="$(BOARD_KDIR)"
  127. prepare: FORCE
  128. @$(CheckSite)
  129. mkdir -p $(GLUON_IMAGEDIR) $(GLUON_BUILDDIR)/$(BOARD)
  130. echo 'src packages file:../openwrt/bin/$(BOARD)/packages' > $(GLUON_BUILDDIR)/$(BOARD)/opkg.conf
  131. +$(GLUONMAKE) feeds
  132. +$(GLUONMAKE) config
  133. +$(GLUONMAKE) toolchain
  134. +$(GLUONMAKE) kernel
  135. +$(GLUONMAKE) packages
  136. +$(GLUONMAKE) prepare-image
  137. touch $(gluon_prepared_stamp)
  138. $(gluon_prepared_stamp):
  139. +$(GLUONMAKE) prepare
  140. include $(INCLUDE_DIR)/package-ipkg.mk
  141. # override variables from rules.mk
  142. PACKAGE_DIR = $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
  143. BIN_DIR = $(GLUON_IMAGEDIR)/$(BOARD)/$(PROFILE)
  144. PROFILE_BUILDDIR = $(BOARD_BUILDDIR)/$(PROFILE)
  145. PROFILE_KDIR = $(PROFILE_BUILDDIR)/kernel
  146. TMP_DIR = $(PROFILE_BUILDDIR)/tmp
  147. TARGET_DIR = $(PROFILE_BUILDDIR)/root
  148. OPKG:= \
  149. IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
  150. IPKG_INSTROOT="$(TARGET_DIR)" \
  151. IPKG_CONF_DIR="$(TMP_DIR)" \
  152. IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
  153. $(STAGING_DIR_HOST)/bin/opkg \
  154. -f $(BOARD_BUILDDIR)/opkg.conf \
  155. --force-depends \
  156. --force-overwrite \
  157. --force-postinstall \
  158. --cache $(TMP_DIR)/dl \
  159. --offline-root $(TARGET_DIR) \
  160. --add-dest root:/ \
  161. --add-arch all:100 \
  162. --add-arch $(ARCH_PACKAGES):200
  163. EnableInitscript = ! grep -q '\#!/bin/sh /etc/rc.common' $(1) || bash ./etc/rc.common $(1) enable
  164. FileOrigin = $(firstword $(shell $(OPKG) search $(1)))
  165. enable_initscripts: FORCE
  166. cd $(TARGET_DIR) && ( export IPKG_INSTROOT=$(TARGET_DIR); \
  167. $(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
  168. $(if $(filter $(ENABLE_INITSCRIPTS_FROM),$(call FileOrigin,$(script))),$(call EnableInitscript,$(script));) \
  169. ) : \
  170. )
  171. # Generate package lists
  172. $(eval $(call merge-lists,BASE_PACKAGES,DEFAULT_PACKAGES $(PROFILE)_PACKAGES))
  173. $(eval $(call merge-lists,GLUON_PACKAGES,GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
  174. package_install: FORCE
  175. $(OPKG) update
  176. $(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
  177. $(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
  178. $(OPKG) install $(BASE_PACKAGES)
  179. +$(GLUONMAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM=%
  180. $(OPKG) install $(GLUON_PACKAGES)
  181. +$(GLUONMAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM="$(GLUON_PACKAGES)"
  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-$(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