gluon/Makefile

161 lines
4.7 KiB
Makefile
Raw Normal View History

2013-02-17 15:30:59 +00:00
all:
LC_ALL:=C
LANG:=C
export LC_ALL LANG
2017-01-18 16:21:43 +00:00
GLUON_SITEDIR ?= $(CURDIR)/site
GLUON_TMPDIR ?= $(CURDIR)/tmp
2017-01-18 16:21:43 +00:00
GLUON_OUTPUTDIR ?= $(CURDIR)/output
GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
GLUON_PACKAGEDIR ?= $(GLUON_OUTPUTDIR)/packages
2017-01-18 16:21:43 +00:00
export GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR DEVICES
2013-02-17 15:30:59 +00:00
2017-01-18 16:21:43 +00:00
$(GLUON_SITEDIR)/site.mk:
$(error No site configuration was found. Please check out a site configuration to $(GLUON_SITEDIR))
2013-02-11 03:52:16 +00:00
2017-01-18 16:21:43 +00:00
-include $(GLUON_SITEDIR)/site.mk
2013-02-11 03:52:16 +00:00
2017-01-18 16:21:43 +00:00
ifeq ($(GLUON_RELEASE),)
$(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line.)
endif
2013-02-11 03:52:16 +00:00
2017-01-18 16:21:43 +00:00
GLUON_LANGS ?= en
2013-02-17 15:30:59 +00:00
export GLUON_RELEASE GLUON_ATH10K_MESH GLUON_REGION GLUON_DEBUG
2013-02-11 22:06:19 +00:00
2017-01-18 16:21:43 +00:00
update: FORCE
2017-01-19 16:27:14 +00:00
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
2017-01-18 16:21:43 +00:00
update-patches: FORCE
2017-01-19 16:27:14 +00:00
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update-patches.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
2013-02-17 15:30:59 +00:00
2017-01-18 16:21:43 +00:00
update-feeds: FORCE
2017-01-19 16:27:14 +00:00
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
2014-02-05 21:12:50 +00:00
2017-01-18 16:21:43 +00:00
GLUON_TARGETS :=
2017-01-18 16:21:43 +00:00
define GluonTarget
gluon_target := $(1)$$(if $(2),-$(2))
GLUON_TARGETS += $$(gluon_target)
GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(if $(3),$(3),$(2))
endef
2017-01-18 16:21:43 +00:00
include targets/targets.mk
2017-01-18 16:21:43 +00:00
LEDEMAKE = $(MAKE) -C lede
BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
2017-01-18 16:21:43 +00:00
SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
LEDE_TARGET := $(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
2017-01-18 16:21:43 +00:00
export LEDE_TARGET
2017-01-18 16:21:43 +00:00
CheckTarget := [ '$(LEDE_TARGET)' ] \
|| (echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'; $(foreach target,$(GLUON_TARGETS),echo ' * $(target)';) false)
2017-01-18 16:21:43 +00:00
CheckExternal := test -d lede || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
list-targets: FORCE
@$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
2017-01-18 16:21:43 +00:00
GLUON_DEFAULT_PACKAGES := -odhcpd -ppp -ppp-mod-pppoe -wpad-mini gluon-core ip6tables hostapd-mini
2017-01-18 16:21:43 +00:00
GLUON_PACKAGES :=
define merge_packages
$(foreach pkg,$(1),
GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
)
endef
$(eval $(call merge_packages,$(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES)))
2013-02-17 15:30:59 +00:00
2017-01-18 16:21:43 +00:00
GLUON_PACKAGES_YES := $(filter-out -%,$(GLUON_PACKAGES))
GLUON_PACKAGES_NO := $(patsubst -%,%,$(filter -%,$(GLUON_PACKAGES)))
2013-02-11 22:06:19 +00:00
2017-01-18 16:21:43 +00:00
config: FORCE
@$(CheckExternal)
@$(CheckTarget)
2013-02-12 01:03:37 +00:00
2017-01-18 16:21:43 +00:00
@( \
echo 'CONFIG_TARGET_$(BOARD)=y' \
$(if $(SUBTARGET),&& echo 'CONFIG_TARGET_$(BOARD)_$(SUBTARGET)=y') \
$(foreach pkg,$(GLUON_PACKAGES_NO),&& echo '# CONFIG_PACKAGE_$(pkg) is not set') \
&& scripts/target_config.sh generic \
&& GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config.sh '$(GLUON_TARGET)' \
$(foreach pkg,$(GLUON_PACKAGES_YES),&& echo 'CONFIG_PACKAGE_$(pkg)=y') \
$(foreach lang,$(GLUON_LANGS),&& echo 'CONFIG_LUCI_LANG_$(lang)=y') \
&& echo 'CONFIG_GLUON_RELEASE="$(GLUON_RELEASE)"' \
&& echo 'CONFIG_GLUON_SITEDIR="$(GLUON_SITEDIR)"' \
&& echo 'CONFIG_GLUON_BRANCH="$(GLUON_BRANCH)"' \
) > lede/.config
+@$(LEDEMAKE) defconfig
2013-02-12 01:03:37 +00:00
2017-01-18 16:21:43 +00:00
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES_YES)'
2013-02-11 22:06:19 +00:00
2017-01-18 16:21:43 +00:00
LUA := lede/staging_dir/hostpkg/bin/lua
2017-01-18 16:21:43 +00:00
$(LUA):
@$(CheckExternal)
2017-01-18 16:21:43 +00:00
+@[ -e lede/.config ] || $(LEDEMAKE) defconfig
+@$(LEDEMAKE) tools/install
+@$(LEDEMAKE) package/lua/host/install
2017-01-18 16:21:43 +00:00
prepare-target: config $(LUA) ;
2017-01-18 16:21:43 +00:00
all: prepare-target
@GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/site_config.lua \
|| (echo 'Your site configuration did not pass validation.'; false)
2017-01-18 16:21:43 +00:00
@scripts/clean_output.sh
+@$(LEDEMAKE)
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
2017-01-18 16:21:43 +00:00
clean download: config
+@$(LEDEMAKE) $@
2017-01-18 16:21:43 +00:00
dirclean: FORCE
+@[ -e lede/.config ] || $(LEDEMAKE) defconfig
+@$(LEDEMAKE) dirclean
@rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
2017-01-18 16:21:43 +00:00
manifest: $(LUA) FORCE
@[ '$(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)
2017-01-18 16:21:43 +00:00
@( \
echo 'BRANCH=$(GLUON_BRANCH)' && \
echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
echo 'PRIORITY=$(GLUON_PRIORITY)' && \
echo && \
$(foreach GLUON_TARGET,$(GLUON_TARGETS), \
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
) : \
2017-01-18 16:21:43 +00:00
) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
2014-02-06 12:20:34 +00:00
2017-01-18 16:21:43 +00:00
@mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
@mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
2013-02-17 15:30:59 +00:00
2017-01-18 16:21:43 +00:00
FORCE: ;
.PHONY: FORCE
.NOTPARALLEL: