gluon/Makefile

410 lines
12 KiB
Makefile
Raw Normal View History

2013-02-17 15:30:59 +00:00
all:
LC_ALL:=C
LANG:=C
export LC_ALL LANG
empty:=
space:= $(empty) $(empty)
GLUONMAKE_EARLY = $(SUBMAKE) -C $(GLUON_ORIGOPENWRTDIR) -f $(GLUONDIR)/Makefile GLUON_TOOLS=0
2013-02-17 15:30:59 +00:00
GLUONMAKE = $(SUBMAKE) -C $(GLUON_OPENWRTDIR) -f $(GLUONDIR)/Makefile
ifneq ($(OPENWRT_BUILD),1)
2013-02-11 22:06:19 +00:00
GLUONDIR:=${CURDIR}
2013-02-11 03:52:16 +00:00
include $(GLUONDIR)/include/gluon.mk
2013-02-11 03:52:16 +00:00
TOPDIR:=$(GLUON_ORIGOPENWRTDIR)
2013-02-17 15:30:59 +00:00
export TOPDIR
2013-12-28 13:54:49 +00:00
GLUON_TARGET ?= ar71xx-generic
export GLUON_TARGET
2013-12-28 13:54:49 +00:00
update: FORCE
$(GLUONDIR)/scripts/update.sh
$(GLUONDIR)/scripts/patch.sh
2013-12-28 13:54:49 +00:00
2013-12-28 14:11:59 +00:00
patch: FORCE
$(GLUONDIR)/scripts/patch.sh
2013-12-28 14:11:59 +00:00
unpatch: FORCE
$(GLUONDIR)/scripts/unpatch.sh
2013-12-28 14:11:59 +00:00
2013-12-28 14:31:11 +00:00
update-patches: FORCE
$(GLUONDIR)/scripts/update.sh
$(GLUONDIR)/scripts/update-patches.sh
$(GLUONDIR)/scripts/patch.sh
2013-12-28 14:31:11 +00:00
2013-12-28 13:54:49 +00:00
-include $(TOPDIR)/include/host.mk
2013-02-17 15:30:59 +00:00
_SINGLE=export MAKEFLAGS=$(space);
override OPENWRT_BUILD=1
override GLUON_TOOLS=1
2013-02-17 15:30:59 +00:00
GREP_OPTIONS=
export OPENWRT_BUILD GLUON_TOOLS GREP_OPTIONS
2013-12-28 13:54:49 +00:00
-include $(TOPDIR)/include/debug.mk
-include $(TOPDIR)/include/depends.mk
include $(GLUONDIR)/include/toplevel.mk
2013-02-17 15:30:59 +00:00
define GluonProfile
image/$(1): FORCE
+@$$(GLUONMAKE) $$@
endef
define GluonProfileFactorySuffix
endef
define GluonProfileSysupgradeSuffix
endef
2014-02-05 21:12:50 +00:00
define GluonModel
endef
include $(GLUONDIR)/targets/targets.mk
2014-05-21 17:43:54 +00:00
include $(GLUONDIR)/targets/$(GLUON_TARGET)/profiles.mk
CheckExternal := test -d $(GLUON_ORIGOPENWRTDIR) || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
2014-05-09 06:52:25 +00:00
prepare-target: FORCE
@$(CheckExternal)
+@$(GLUONMAKE_EARLY) prepare-target
all: prepare-target
2013-02-17 15:30:59 +00:00
+@$(GLUONMAKE) prepare
+@$(GLUONMAKE) images
prepare: prepare-target
+@$(GLUONMAKE) $@
2013-02-17 15:30:59 +00:00
clean dirclean download images: FORCE
@$(CheckExternal)
+@$(GLUONMAKE_EARLY) maybe-prepare-target
+@$(GLUONMAKE) $@
toolchain/% package/% target/%: FORCE
@$(CheckExternal)
+@$(GLUONMAKE_EARLY) maybe-prepare-target
2014-02-06 12:20:34 +00:00
+@$(GLUONMAKE) $@
manifest: FORCE
[ -n '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
@$(CheckExternal)
+@$(GLUONMAKE_EARLY) maybe-prepare-target
+@$(GLUONMAKE) $@
2013-02-17 15:30:59 +00:00
else
2013-02-11 22:06:19 +00:00
TOPDIR=${CURDIR}
export TOPDIR
include rules.mk
2013-02-11 03:52:16 +00:00
include $(GLUONDIR)/include/gluon.mk
2013-02-17 15:30:59 +00:00
include $(INCLUDE_DIR)/host.mk
2013-02-17 15:30:59 +00:00
include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/subdir.mk
2013-02-17 15:30:59 +00:00
include package/Makefile
include tools/Makefile
include toolchain/Makefile
include target/Makefile
2013-02-11 22:06:19 +00:00
2013-02-17 15:30:59 +00:00
PROFILES :=
PROFILE_PACKAGES :=
define Profile
$(eval $(call Profile/Default))
$(eval $(call Profile/$(1)))
endef
define GluonProfile
PROFILES += $(1)
PROFILE_PACKAGES += $(filter-out -%,$(2) $(GLUON_$(1)_SITE_PACKAGES))
GLUON_$(1)_DEFAULT_PACKAGES := $(2)
GLUON_$(1)_FACTORY_SUFFIX := -squashfs-factory
GLUON_$(1)_SYSUPGRADE_SUFFIX := -squashfs-sysupgrade
GLUON_$(1)_FACTORY_EXT := .bin
GLUON_$(1)_SYSUPGRADE_EXT := .bin
2014-02-05 21:12:50 +00:00
GLUON_$(1)_MODELS :=
endef
define GluonProfileFactorySuffix
GLUON_$(1)_FACTORY_SUFFIX := $(2)
GLUON_$(1)_FACTORY_EXT := $(3)
endef
define GluonProfileSysupgradeSuffix
GLUON_$(1)_SYSUPGRADE_SUFFIX := $(2)
GLUON_$(1)_SYSUPGRADE_EXT := $(3)
endef
2014-02-05 21:12:50 +00:00
define GluonModel
GLUON_$(1)_MODELS += $(3)
GLUON_$(1)_MODEL_$(3) := $(2)
endef
include $(GLUONDIR)/targets/targets.mk
2014-05-21 17:43:54 +00:00
include $(GLUONDIR)/targets/$(GLUON_TARGET)/profiles.mk
BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared
gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared
include $(INCLUDE_DIR)/target.mk
2013-02-17 15:30:59 +00:00
prereq: FORCE
+$(NO_TRACE_MAKE) prereq
2014-07-26 14:11:27 +00:00
gluon-tools: FORCE
+$(GLUONMAKE_EARLY) tools/sed/install
+$(GLUONMAKE_EARLY) package/lua/host/install
prepare-tmpinfo: FORCE
mkdir -p tmp/info
$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk $(TOPDIR)/overlay/*/*.mk" SCAN_EXTRA=""
$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
for type in package target; do \
f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
[ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
done
./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
touch $(TOPDIR)/tmp/.build
feeds: FORCE
rm -rf $(TOPDIR)/package/feeds
mkdir $(TOPDIR)/package/feeds
[ ! -f $(GLUON_SITEDIR)/modules ] || . $(GLUON_SITEDIR)/modules && for feed in $$GLUON_SITE_FEEDS; do ln -s ../../../packages/$$feed $(TOPDIR)/package/feeds/$$feed; done
. $(GLUONDIR)/modules && for feed in $$GLUON_FEEDS; do ln -s ../../../packages/$$feed $(TOPDIR)/package/feeds/$$feed; done
+$(GLUONMAKE_EARLY) prepare-tmpinfo
config: FORCE
+$(GLUONMAKE) prepare-tmpinfo
( \
cat $(GLUONDIR)/include/config $(GLUONDIR)/targets/$(GLUON_TARGET)/config; \
echo '$(patsubst %,CONFIG_PACKAGE_%=m,$(sort $(filter-out -%,$(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES) $(PROFILE_PACKAGES))))' \
| sed -e 's/ /\n/g'; \
) > .config
+$(NO_TRACE_MAKE) defconfig OPENWRT_BUILD=0
prepare-target: FORCE
rm $(GLUON_OPENWRTDIR)/tmp || true
mkdir -p $(GLUON_OPENWRTDIR)/tmp
for dir in build_dir dl staging_dir; do \
mkdir -p $(GLUON_ORIGOPENWRTDIR)/$$dir; \
done
for link in build_dir config Config.in dl include Makefile package rules.mk scripts staging_dir target toolchain tools; do \
ln -sf $(GLUON_ORIGOPENWRTDIR)/$$link $(GLUON_OPENWRTDIR); \
done
+$(GLUONMAKE_EARLY) feeds
+$(GLUONMAKE_EARLY) gluon-tools
+$(GLUONMAKE) config
touch $(target_prepared_stamp)
$(target_prepared_stamp):
+$(GLUONMAKE_EARLY) prepare-target
maybe-prepare-target: $(target_prepared_stamp)
2013-02-17 15:30:59 +00:00
$(BUILD_DIR)/.prepared: Makefile
@mkdir -p $$(dirname $@)
@touch $@
$(toolchain/stamp-install): $(tools/stamp-install)
$(package/stamp-compile): $(package/stamp-cleanup)
2013-02-17 15:30:59 +00:00
clean: FORCE
+$(SUBMAKE) clean
2014-05-12 05:21:35 +00:00
rm -f $(gluon_prepared_stamp)
dirclean: FORCE
for dir in build_dir dl staging_dir tmp; do \
rm -rf $(GLUON_ORIGOPENWRTDIR)/$$dir; \
done
rm -rf $(GLUON_BUILDDIR)
2013-09-28 16:39:32 +00:00
export MD5SUM := $(GLUONDIR)/scripts/md5sum.sh
export SHA512SUM := $(GLUONDIR)/scripts/sha512sum.sh
2013-09-28 16:39:32 +00:00
download: FORCE
2013-09-24 17:23:09 +00:00
+$(SUBMAKE) tools/download
+$(SUBMAKE) toolchain/download
+$(SUBMAKE) package/download
+$(SUBMAKE) target/download
2013-02-17 15:30:59 +00:00
toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
2013-04-06 20:23:33 +00:00
include $(INCLUDE_DIR)/kernel.mk
kernel: FORCE
2013-09-24 17:23:09 +00:00
+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.image TARGET_BUILD=1
+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules TARGET_BUILD=1
2013-02-17 15:30:59 +00:00
packages: $(package/stamp-compile)
$(_SINGLE)$(SUBMAKE) -r package/index
prepare-image: FORCE
rm -rf $(BOARD_KDIR)
mkdir -p $(BOARD_KDIR)
cp $(KERNEL_BUILD_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf $(BOARD_KDIR)/
2013-09-24 17:23:09 +00:00
+$(SUBMAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image -f $(GLUONDIR)/include/Makefile.image prepare KDIR="$(BOARD_KDIR)"
2013-02-17 15:30:59 +00:00
prepare: FORCE
@$(STAGING_DIR_HOST)/bin/lua $(GLUONDIR)/packages/gluon/gluon/gluon-core/files/usr/lib/lua/gluon/site_config.lua \
|| (echo 'Your site configuration did not pass validation.'; false)
mkdir -p $(GLUON_IMAGEDIR) $(BOARD_BUILDDIR)
echo 'src packages file:../openwrt/bin/$(BOARD)/packages' > $(BOARD_BUILDDIR)/opkg.conf
2013-02-11 22:06:19 +00:00
2013-09-24 17:23:09 +00:00
+$(GLUONMAKE) toolchain
+$(GLUONMAKE) kernel
+$(GLUONMAKE) packages
+$(GLUONMAKE) prepare-image
2013-02-12 01:03:37 +00:00
echo "$(GLUON_RELEASE)" > $(gluon_prepared_stamp)
2013-02-12 01:03:37 +00:00
2013-02-17 15:58:07 +00:00
$(gluon_prepared_stamp):
2013-09-24 17:23:09 +00:00
+$(GLUONMAKE) prepare
2013-02-11 22:06:19 +00:00
include $(INCLUDE_DIR)/package-ipkg.mk
# override variables from rules.mk
PACKAGE_DIR = $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
PROFILE_BUILDDIR = $(BOARD_BUILDDIR)/$(PROFILE)
PROFILE_KDIR = $(PROFILE_BUILDDIR)/kernel
2014-02-05 21:12:50 +00:00
BIN_DIR = $(PROFILE_BUILDDIR)/images
TMP_DIR = $(PROFILE_BUILDDIR)/tmp
TARGET_DIR = $(PROFILE_BUILDDIR)/root
IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$$(cat $(gluon_prepared_stamp))
2014-02-05 21:12:50 +00:00
OPKG:= \
IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
IPKG_INSTROOT="$(TARGET_DIR)" \
IPKG_CONF_DIR="$(TMP_DIR)" \
IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
$(STAGING_DIR_HOST)/bin/opkg \
-f $(BOARD_BUILDDIR)/opkg.conf \
--cache $(TMP_DIR)/dl \
--offline-root $(TARGET_DIR) \
--force-postinstall \
--add-dest root:/ \
--add-arch all:100 \
--add-arch $(ARCH_PACKAGES):200
EnableInitscript = ! grep -q '\#!/bin/sh /etc/rc.common' $(1) || bash ./etc/rc.common $(1) enable
enable_initscripts: FORCE
cd $(TARGET_DIR) && ( export IPKG_INSTROOT=$(TARGET_DIR); \
$(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
2014-01-13 17:23:25 +00:00
$(call EnableInitscript,$(script)); \
) : \
)
2014-01-13 17:23:25 +00:00
# Generate package list
$(eval $(call merge-lists,INSTALL_PACKAGES,DEFAULT_PACKAGES GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
package_install: FORCE
$(OPKG) update
$(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
$(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
2014-01-13 17:23:25 +00:00
$(OPKG) install $(INSTALL_PACKAGES)
+$(GLUONMAKE) enable_initscripts
rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
ifeq ($(GLUON_OPKG_CONFIG),1)
include $(INCLUDE_DIR)/version.mk
endif
opkg_config: FORCE
cp $(GLUON_OPENWRTDIR)/package/system/opkg/files/opkg.conf $(TARGET_DIR)/etc/opkg.conf
for d in base luci packages routing telephony management oldpackages; do \
echo "src/gz %n_$$d %U/$$d" >> $(TARGET_DIR)/etc/opkg.conf; \
done
$(VERSION_SED) $(TARGET_DIR)/etc/opkg.conf
image: FORCE
rm -rf $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(PROFILE_KDIR)
2014-02-05 21:12:50 +00:00
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(TARGET_DIR)/tmp $(GLUON_IMAGEDIR)/factory $(GLUON_IMAGEDIR)/sysupgrade
cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
2013-09-24 17:23:09 +00:00
+$(GLUONMAKE) package_install
+$(GLUONMAKE) opkg_config GLUON_OPKG_CONFIG=1
$(call Image/mkfs/prepare)
$(_SINGLE)$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 IMG_PREFIX=gluon \
PROFILE="$(PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"
2014-02-05 21:12:50 +00:00
$(foreach model,$(GLUON_$(PROFILE)_MODELS), \
$(if $(GLUON_$(PROFILE)_SYSUPGRADE_EXT), \
rm -f $(GLUON_IMAGEDIR)/sysupgrade/gluon-*-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) && \
cp $(BIN_DIR)/gluon-$(GLUON_$(PROFILE)_MODEL_$(model))$(GLUON_$(PROFILE)_SYSUPGRADE_SUFFIX)$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) $(GLUON_IMAGEDIR)/sysupgrade/$(IMAGE_PREFIX)-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) && \
) \
$(if $(GLUON_$(PROFILE)_FACTORY_EXT), \
rm -f $(GLUON_IMAGEDIR)/factory/gluon-*-$(model)$(GLUON_$(PROFILE)_FACTORY_EXT) && \
cp $(BIN_DIR)/gluon-$(GLUON_$(PROFILE)_MODEL_$(model))$(GLUON_$(PROFILE)_FACTORY_SUFFIX)$(GLUON_$(PROFILE)_FACTORY_EXT) $(GLUON_IMAGEDIR)/factory/$(IMAGE_PREFIX)-$(model)$(GLUON_$(PROFILE)_FACTORY_EXT) && \
) \
2014-02-05 21:12:50 +00:00
) :
image/%: $(gluon_prepared_stamp)
+$(GLUONMAKE) image PROFILE="$(patsubst image/%,%,$@)" V=s$(OPENWRT_VERBOSE)
2013-02-19 15:58:48 +00:00
call_image/%: FORCE
2013-09-24 17:23:09 +00:00
+$(GLUONMAKE) $(patsubst call_image/%,image/%,$@)
2013-02-19 15:58:48 +00:00
images: $(patsubst %,call_image/%,$(PROFILES)) ;
2013-02-11 03:52:16 +00:00
2014-02-06 12:20:34 +00:00
manifest: FORCE
mkdir -p $(GLUON_IMAGEDIR)/sysupgrade
(cd $(GLUON_IMAGEDIR)/sysupgrade && \
echo 'BRANCH=$(GLUON_BRANCH)' && \
echo 'DATE=$(shell $(STAGING_DIR_HOST)/bin/lua $(GLUONDIR)/scripts/rfc3339date.lua)' && \
echo 'PRIORITY=$(GLUON_PRIORITY)' && \
echo && \
($(foreach profile,$(PROFILES), \
$(foreach model,$(GLUON_$(profile)_MODELS), \
for file in gluon-*-'$(model)-sysupgrade$(GLUON_$(profile)_SYSUPGRADE_EXT)'; do \
[ -e "$$file" ] && echo \
'$(model)' \
"$$(echo "$$file" | sed -n -r -e 's/^gluon-$(call regex-escape,$(GLUON_SITE_CODE))-(.*)-$(call regex-escape,$(model)-sysupgrade$(GLUON_$(profile)_SYSUPGRADE_EXT))$$/\1/p')" \
"$$($(SHA512SUM) "$$file")" \
"$$file" && break; \
done; \
) \
) :) \
) > $(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest
2014-02-06 12:20:34 +00:00
.PHONY: all images prepare clean gluon-tools
2013-02-17 15:30:59 +00:00
endif