2013-02-17 15:30:59 +00:00
all :
LC_ALL := C
LANG := C
export LC_ALL LANG
2020-03-07 13:21:17 +00:00
.SHELLFLAGS = -ec
2017-11-28 20:29:56 +00:00
# check for spaces & resolve possibly relative paths
d e f i n e m k a b s p a t h
2020-03-07 13:05:58 +00:00
ifneq ( 1,$( words [ $( $( 1) ) ] ) )
$$ ( error $( 1) must not contain spaces)
endif
override $( 1) := $( abspath $( $( 1) ) )
2017-11-28 20:29:56 +00:00
e n d e f
2020-03-07 12:47:59 +00:00
escape = '$(subst ' ,'\' ',$(1))'
2018-10-23 15:48:22 +00:00
GLUON_SITEDIR ?= site
2017-11-28 20:29:56 +00:00
$( eval $ ( call mkabspath ,GLUON_SITEDIR ) )
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-02-22 21:40:36 +00:00
i n c l u d e $( GLUON_SITEDIR ) / s i t e . m k
2013-02-11 03:52:16 +00:00
2017-02-22 21:40:36 +00:00
GLUON_RELEASE ?= $( error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line)
2019-06-15 12:34:45 +00:00
GLUON_DEPRECATED ?= $( error GLUON_DEPRECATED not set. Please consult the documentation)
2018-10-23 15:48:22 +00:00
# initialize (possibly already user set) directory variables
GLUON_TMPDIR ?= tmp
GLUON_OUTPUTDIR ?= output
GLUON_IMAGEDIR ?= $( GLUON_OUTPUTDIR) /images
GLUON_PACKAGEDIR ?= $( GLUON_OUTPUTDIR) /packages
GLUON_TARGETSDIR ?= targets
GLUON_PATCHESDIR ?= patches
$( eval $ ( call mkabspath ,GLUON_TMPDIR ) )
$( eval $ ( call mkabspath ,GLUON_OUTPUTDIR ) )
$( eval $ ( call mkabspath ,GLUON_IMAGEDIR ) )
$( eval $ ( call mkabspath ,GLUON_PACKAGEDIR ) )
$( eval $ ( call mkabspath ,GLUON_TARGETSDIR ) )
$( eval $ ( call mkabspath ,GLUON_PATCHESDIR ) )
2018-01-25 23:13:37 +00:00
GLUON_MULTIDOMAIN ?= 0
2020-05-11 21:08:02 +00:00
GLUON_AUTOREMOVE ?= 0
2018-01-25 23:03:00 +00:00
GLUON_DEBUG ?= 0
2020-05-12 22:45:06 +00:00
GLUON_MINIFY ?= 1
2013-02-17 15:30:59 +00:00
2020-03-07 14:46:55 +00:00
# Can be overridden via environment/command line/... to use the Gluon
# build system for non-Gluon builds
d e f i n e GLUON_BASE_FEEDS ?=
s r c - l i n k g l u o n _ b a s e . . / . . / p a c k a g e
e n d e f
2020-03-07 12:47:59 +00:00
GLUON_VARS = \
2020-05-11 21:08:02 +00:00
GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_AUTOREMOVE GLUON_DEBUG GLUON_MINIFY GLUON_DEPRECATED \
GLUON_DEVICES GLUON_TARGETSDIR GLUON_PATCHESDIR GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR \
2020-05-03 19:35:01 +00:00
GLUON_SITEDIR GLUON_RELEASE GLUON_BRANCH GLUON_LANGS GLUON_BASE_FEEDS \
GLUON_TARGET BOARD SUBTARGET
2020-03-07 12:47:59 +00:00
u n export $( GLUON_VARS )
GLUON_ENV = $( foreach var,$( GLUON_VARS) ,$( var) = $( call escape,$( $( var) ) ) )
2013-02-17 23:39:44 +00:00
2017-06-26 18:52:22 +00:00
show-release :
2020-05-11 22:54:55 +00:00
@echo '$(GLUON_RELEASE)'
2017-06-26 18:52:22 +00:00
2013-02-11 22:06:19 +00:00
2017-01-18 16:21:43 +00:00
update : FORCE
2020-05-11 22:54:55 +00:00
@
2020-03-07 12:47:59 +00:00
export $( GLUON_ENV)
scripts/update.sh
scripts/patch.sh
scripts/feeds.sh
2013-10-08 01:57:08 +00:00
2017-01-18 16:21:43 +00:00
update-patches : FORCE
2020-05-11 22:54:55 +00:00
@
2020-03-07 12:47:59 +00:00
export $( GLUON_ENV)
scripts/update.sh
scripts/update-patches.sh
scripts/patch.sh
2013-02-17 15:30:59 +00:00
2017-01-18 16:21:43 +00:00
update-feeds : FORCE
2020-05-11 22:54:55 +00:00
@$( GLUON_ENV) scripts/feeds.sh
2013-10-08 01:57:08 +00:00
2014-02-05 21:12:50 +00:00
2017-01-18 16:21:43 +00:00
GLUON_TARGETS :=
2015-01-03 03:40:18 +00:00
2017-01-18 16:21:43 +00:00
d e f i n e G l u o n T a r g e t
gluon_target := $( 1) $$ ( if $( 2) ,-$( 2) )
GLUON_TARGETS += $$ ( gluon_target)
GLUON_TARGET_$$(gluon_target)_BOARD := $( 1)
2018-07-10 20:57:40 +00:00
GLUON_TARGET_$$(gluon_target)_SUBTARGET := $( 2)
2015-01-25 02:31:37 +00:00
e n d e f
2018-10-23 15:48:22 +00:00
i n c l u d e $( GLUON_TARGETSDIR ) / t a r g e t s . m k
2015-10-16 17:11:36 +00:00
2013-02-12 06:14:18 +00:00
2018-07-10 20:57:40 +00:00
OPENWRTMAKE = $( MAKE) -C openwrt
2015-10-14 18:12:52 +00:00
BOARD := $( GLUON_TARGET_$( GLUON_TARGET) _BOARD)
2017-01-18 16:21:43 +00:00
SUBTARGET := $( GLUON_TARGET_$( GLUON_TARGET) _SUBTARGET)
2017-09-07 01:21:42 +00:00
2015-10-14 18:12:52 +00:00
2020-03-07 13:21:17 +00:00
d e f i n e C h e c k T a r g e t
if [ -z '$(BOARD)' ] ; then
echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'
for target in $( GLUON_TARGETS) ; do
echo " * $$ target "
done
exit 1
fi
e n d e f
2015-03-07 17:12:52 +00:00
2020-03-07 13:21:17 +00:00
d e f i n e C h e c k E x t e r n a l
if [ ! -d openwrt ] ; then
echo "You don't seem to have obtained the external repositories needed by Gluon; please call \`make update\` first!"
exit 1
fi
e n d e f
2014-05-11 08:43:10 +00:00
2018-01-19 03:57:48 +00:00
d e f i n e C h e c k S i t e
2020-03-07 13:21:17 +00:00
if ! GLUON_SITEDIR = '$(GLUON_SITEDIR)' GLUON_SITE_CONFIG = '$(1).conf' $( LUA) -e 'assert(dofile("scripts/site_config.lua")(os.getenv("GLUON_SITE_CONFIG")))' ; then
2020-03-14 18:15:24 +00:00
echo 'Your site configuration ($(1).conf) did not pass validation'
2020-03-07 13:21:17 +00:00
exit 1
fi
2018-01-19 03:57:48 +00:00
e n d e f
2014-05-11 08:43:10 +00:00
2017-02-16 17:36:20 +00:00
list-targets : FORCE
2020-05-11 22:54:55 +00:00
@for target in $( GLUON_TARGETS) ; do
2020-03-07 13:21:17 +00:00
echo " $$ target "
done
2017-02-16 17:36:20 +00:00
2019-12-14 21:18:58 +00:00
lint : lint -lua lint -sh
lint-lua : FORCE
2020-05-11 22:54:55 +00:00
@scripts/lint-lua.sh
2019-12-14 21:18:58 +00:00
lint-sh : FORCE
2020-05-11 22:54:55 +00:00
@scripts/lint-sh.sh
2017-02-16 17:36:20 +00:00
2015-10-13 19:36:19 +00:00
2018-07-10 20:57:40 +00:00
LUA := openwrt/staging_dir/hostpkg/bin/lua
2015-10-13 19:36:19 +00:00
2017-01-18 16:21:43 +00:00
$(LUA) :
2020-05-11 22:54:55 +00:00
+@
2020-03-07 13:21:17 +00:00
$( CheckExternal)
2013-04-05 20:53:09 +00:00
2020-03-07 13:21:17 +00:00
[ -e openwrt/.config ] || $( OPENWRTMAKE) defconfig
$( OPENWRTMAKE) tools/install
$( OPENWRTMAKE) package/lua/host/compile
2013-04-05 20:53:09 +00:00
2019-06-14 17:20:15 +00:00
config : $( LUA ) FORCE
2020-05-11 22:54:55 +00:00
+@
2020-03-07 13:21:17 +00:00
$( CheckExternal)
$( CheckTarget)
$( foreach conf,site $( patsubst $( GLUON_SITEDIR) /%.conf,%,$( wildcard $( GLUON_SITEDIR) /domains/*.conf) ) ,\
$( call CheckSite,$( conf) ) ; \
)
2013-04-05 20:53:09 +00:00
2020-05-03 19:35:01 +00:00
$( GLUON_ENV) $( LUA) scripts/target_config.lua > openwrt/.config
2020-03-07 13:21:17 +00:00
$( OPENWRTMAKE) defconfig
2020-05-03 19:35:01 +00:00
$( GLUON_ENV) $( LUA) scripts/target_config_check.lua
2019-06-14 17:20:15 +00:00
all : config
2020-05-11 22:54:55 +00:00
+@
2020-05-03 19:35:01 +00:00
$( GLUON_ENV) $( LUA) scripts/clean_output.lua
2020-03-07 13:21:17 +00:00
$( OPENWRTMAKE)
2020-05-03 19:35:01 +00:00
$( GLUON_ENV) $( LUA) scripts/copy_output.lua
2013-04-05 20:53:09 +00:00
2017-01-18 16:21:43 +00:00
clean download : config
2020-05-11 22:54:55 +00:00
+@$( OPENWRTMAKE) $@
2013-04-05 20:53:09 +00:00
2017-01-18 16:21:43 +00:00
dirclean : FORCE
2020-05-11 22:54:55 +00:00
+@
2020-03-07 13:21:17 +00:00
[ -e openwrt/.config ] || $( OPENWRTMAKE) defconfig
$( OPENWRTMAKE) dirclean
rm -rf $( GLUON_TMPDIR) $( GLUON_OUTPUTDIR)
2013-04-05 20:53:09 +00:00
2017-01-18 16:21:43 +00:00
manifest : $( LUA ) FORCE
2020-05-11 22:54:55 +00:00
@
2020-03-07 13:21:17 +00:00
[ '$(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)
(
2020-03-07 12:47:59 +00:00
export $( GLUON_ENV)
2020-03-07 13:21:17 +00:00
echo 'BRANCH=$(GLUON_BRANCH)'
echo " DATE= $$ ( $( LUA) scripts/rfc3339date.lua) "
echo 'PRIORITY=$(GLUON_PRIORITY)'
echo
for target in $( GLUON_TARGETS) ; do
2020-03-07 12:47:59 +00:00
$( LUA) scripts/generate_manifest.lua " $$ target "
2020-03-07 13:21:17 +00:00
done
2017-01-18 16:21:43 +00:00
) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
2014-02-06 12:20:34 +00:00
2020-03-07 13:21:17 +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 :
2020-03-07 13:21:17 +00:00
.ONESHELL :