diff --git a/Makefile b/Makefile index 4f39b92b..72c62a0b 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,74 @@ -GLUONDIR:=${CURDIR} - -LN_S:=ln -sf - all: - $(MAKE) prepare - $(MAKE) images + +LC_ALL:=C +LANG:=C +export LC_ALL LANG + +GLUONMAKE = $(SUBMAKE) -C $(GLUON_OPENWRTDIR) -f $(GLUONDIR)/Makefile + +ifneq ($(OPENWRT_BUILD),1) + +GLUONDIR:=${CURDIR} include $(GLUONDIR)/builder/gluon.mk -BOARD := ar71xx -PROFILES := -PROFILE_PACKAGES := +TOPDIR:=$(GLUON_OPENWRTDIR) +export TOPDIR + +include $(TOPDIR)/include/host.mk + +empty:= +space:= $(empty) $(empty) +_SINGLE=export MAKEFLAGS=$(space); + +override OPENWRT_BUILD=1 +GREP_OPTIONS= +export OPENWRT_BUILD GREP_OPTIONS +include $(TOPDIR)/include/debug.mk +include $(TOPDIR)/include/depends.mk +include $(TOPDIR)/include/toplevel.mk + +all: FORCE + +@$(GLUONMAKE) prepare + +@$(GLUONMAKE) images + +prepare: FORCE + +@$(GLUONMAKE) prepare + +images: FORCE + +@$(GLUONMAKE) images + +clean: clean-gluon + +clean-gluon: + rm -rf $(GLUON_BUILDDIR) + +else + +include $(GLUONDIR)/builder/gluon.mk + +include $(TOPDIR)/include/host.mk + +include rules.mk +include $(INCLUDE_DIR)/depends.mk +include $(INCLUDE_DIR)/subdir.mk +include target/Makefile +include package/Makefile +include tools/Makefile +include toolchain/Makefile null := space := ${null} ${null} ${space} := ${space} -prepared_stamp := $(GLUON_BUILDDIR)/$(BOARD)/prepared +BOARD := ar71xx +PROFILES := +PROFILE_PACKAGES := + +gluon_prepared_stamp := $(GLUON_BUILDDIR)/$(BOARD)/prepared define GluonProfile -image/$(1): $(prepared_stamp) +image/$(1): $(gluon_prepared_stamp) $(MAKE) -C $(GLUON_BUILDERDIR) image \ PROFILE="$(1)" \ $(if $(2),PACKAGES="$(2)") @@ -28,32 +77,56 @@ PROFILES += $(1) PROFILE_PACKAGES += $(filter-out -%,$(2)) endef -include profiles.mk +include $(GLUONDIR)/profiles.mk -prepare: +$(BUILD_DIR)/.prepared: Makefile + @mkdir -p $$(dirname $@) + @touch $@ + +$(toolchain/stamp-install): $(tools/stamp-install) +$(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared +$(package/stamp-cleanup): $(target/stamp-compile) +$(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup) +$(package/stamp-install): $(package/stamp-compile) +$(package/stamp-rootfs-prepare): $(package/stamp-install) +$(target/stamp-install): $(package/stamp-compile) $(package/stamp-install) $(package/stamp-rootfs-prepare) + +feeds: FORCE + ln -sf $(GLUON_BUILDERDIR)/feeds.conf feeds.conf + + scripts/feeds uninstall -a + scripts/feeds update -a + scripts/feeds install -a + + rm -f $(TMP_DIR)/info/.files-packageinfo-$(SCAN_COOKIE) + $(SUBMAKE) prepare-tmpinfo OPENWRT_BUILD=0 + +config: FORCE + echo -e 'CONFIG_TARGET_$(BOARD)=y\nCONFIG_TARGET_ROOTFS_JFFS2=n\n$(subst ${ },\n,$(patsubst %,CONFIG_PACKAGE_%=m,$(GLUON_PACKAGES) $(PROFILE_PACKAGES)))' > .config + $(SUBMAKE) defconfig OPENWRT_BUILD=0 + +toolchain: $(toolchain/stamp-install) $(tools/stamp-install) +target: $(target/stamp-compile) +packages: $(package/stamp-compile) + +prepare: FORCE mkdir -p $(GLUON_IMAGEDIR) $(GLUON_BUILDDIR)/$(BOARD) echo 'src packages file:../openwrt/bin/$(BOARD)/packages' > $(GLUON_BUILDDIR)/$(BOARD)/opkg.conf - $(LN_S) $(GLUON_BUILDERDIR)/feeds.conf $(GLUON_OPENWRTDIR)/feeds.conf - $(GLUON_OPENWRTDIR)/scripts/feeds uninstall -a - $(GLUON_OPENWRTDIR)/scripts/feeds update -a - $(GLUON_OPENWRTDIR)/scripts/feeds install -a + $(GLUONMAKE) feeds + $(GLUONMAKE) config + $(GLUONMAKE) toolchain + $(GLUONMAKE) target + $(GLUONMAKE) packages + $(SUBMAKE) -C $(GLUON_BUILDERDIR) prepare - echo -e "CONFIG_TARGET_$(BOARD)=y\nCONFIG_TARGET_ROOTFS_JFFS2=n\n$(subst ${ },\n,$(patsubst %,CONFIG_PACKAGE_%=m,$(GLUON_PACKAGES) $(PROFILE_PACKAGES)))" > $(GLUON_OPENWRTDIR)/.config - $(MAKE) -C $(GLUON_OPENWRTDIR) defconfig prepare package/compile - $(MAKE) -C $(GLUON_BUILDERDIR) prepare - - touch $(prepared_stamp) + touch $(gluon_prepared_stamp) $(prepared_stamp): $(MAKE) prepare images: $(patsubst %,image/%,$(PROFILES)) -clean: - rm -rf $(GLUON_BUILDDIR) - -cleanall: clean - $(MAKE) -C $(GLUON_OPENWRTDIR) clean - .PHONY: all images prepare clean cleanall + +endif diff --git a/builder/Makefile b/builder/Makefile index 2412c55e..9487116e 100644 --- a/builder/Makefile +++ b/builder/Makefile @@ -7,24 +7,11 @@ # See /LICENSE for more information. # -GLUONDIR:=${CURDIR}/.. +all: image include ${CURDIR}/gluon.mk -TOPDIR:=$(GLUON_OPENWRTDIR) -LC_ALL:=C -LANG:=C -export TOPDIR LC_ALL LANG -export OPENWRT_VERBOSE=s -all: image - include $(TOPDIR)/include/host.mk - -ifneq ($(OPENWRT_BUILD),1) - override OPENWRT_BUILD=1 - export OPENWRT_BUILD -endif - include $(TOPDIR)/rules.mk PACKAGE_DIR := $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages @@ -93,7 +80,10 @@ prepare: FORCE $(MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image -f $(GLUON_BUILDERDIR)/Makefile.image prepare KDIR="$(BOARD_KDIR)" $(MAKE) package_index -_call_image: +image/%:: FORCE + $(MAKE) assemble_image PROFILE="$(patsubst image/%,%,$@)" + +assemble_image: echo 'Building images for $(BOARD)$(if $($(PROFILE)_NAME), - $($(PROFILE)_NAME))' echo 'Packages: $(BUILD_PACKAGES)' echo @@ -165,10 +155,9 @@ build_image: FORCE image: (unset PROFILE FILES PACKAGES MAKEFLAGS; \ - $(MAKE) _call_image \ - $(if $(PROFILE),PROFILE="$(PROFILE)") \ - $(if $(FILES),USER_FILES="$(FILES)") \ - $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \ + $(MAKE) image/$(PROFILE) OPENWRT_VERBOSE="$(OPENWRT_VERBOSE)" \ + $(if $(FILES),USER_FILES="$(FILES)") \ + $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \ ) .SILENT: prepare image diff --git a/builder/gluon.mk b/builder/gluon.mk index b21a19ba..a14887f2 100644 --- a/builder/gluon.mk +++ b/builder/gluon.mk @@ -7,6 +7,8 @@ GLUON_OPENWRTDIR := $(GLUONDIR)/openwrt GLUON_BUILDERDIR := $(GLUONDIR)/builder GLUON_BUILDDIR := $(GLUONDIR)/build +export GLUONDIR GLUON_SITEDIR GLUON_IMAGEDIR GLUON_OPENWRTDIR GLUON_BUILDERDIR GLUON_BUILDDIR + $(GLUON_SITEDIR)/site.mk: $(error There was no site configuration found. Please check out a site configuration to $(GLUON_SITEDIR))