2013-02-17 15:30:59 +00:00
all :
LC_ALL := C
LANG := C
export LC_ALL LANG
2013-02-17 20:29:20 +00:00
empty :=
space := $( empty) $( empty)
2014-05-11 08:43:10 +00:00
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
i f n e q ( $( OPENWRT_BUILD ) , 1 )
2013-02-11 22:06:19 +00:00
GLUONDIR := ${ CURDIR }
2013-02-11 03:52:16 +00:00
2013-04-04 19:00:15 +00:00
i n c l u d e $( GLUONDIR ) / i n c l u d e / g l u o n . m k
2013-02-11 03:52:16 +00:00
2014-05-11 08:43:10 +00:00
TOPDIR := $( GLUON_ORIGOPENWRTDIR)
2013-02-17 15:30:59 +00:00
export TOPDIR
2013-12-28 13:54:49 +00:00
2014-05-10 09:52:06 +00:00
GLUON_TARGET ?= ar71xx-generic
export GLUON_TARGET
2013-12-28 13:54:49 +00:00
update : FORCE
$( GLUONDIR) /scripts/update.sh $( GLUONDIR)
2013-12-28 20:35:16 +00:00
$( GLUONDIR) /scripts/patch.sh $( GLUONDIR)
2013-12-28 13:54:49 +00:00
2013-12-28 14:11:59 +00:00
patch : FORCE
$( GLUONDIR) /scripts/patch.sh $( GLUONDIR)
unpatch : FORCE
$( GLUONDIR) /scripts/unpatch.sh $( GLUONDIR)
2013-12-28 14:31:11 +00:00
update-patches : FORCE
2013-12-28 21:13:18 +00:00
$( GLUONDIR) /scripts/update.sh $( GLUONDIR)
2013-12-28 14:31:11 +00:00
$( GLUONDIR) /scripts/update-patches.sh $( GLUONDIR)
$( GLUONDIR) /scripts/patch.sh $( GLUONDIR)
2013-12-28 13:54:49 +00:00
- i n c l u d e $( TOPDIR ) / i n c l u d e / h o s t . m k
2013-02-17 15:30:59 +00:00
_SINGLE = export MAKEFLAGS = $( space) ;
o v e r r i d e OPENWRT_BUILD = 1
2014-05-07 22:49:46 +00:00
o v e r r i d e GLUON_TOOLS = 1
2013-02-17 15:30:59 +00:00
GREP_OPTIONS =
2014-05-07 22:49:46 +00:00
export OPENWRT_BUILD GLUON_TOOLS GREP_OPTIONS
2013-02-17 23:39:44 +00:00
2013-12-28 13:54:49 +00:00
- i n c l u d e $( TOPDIR ) / i n c l u d e / d e b u g . m k
- i n c l u d e $( TOPDIR ) / i n c l u d e / d e p e n d s . m k
2013-04-04 19:00:15 +00:00
i n c l u d e $( GLUONDIR ) / i n c l u d e / t o p l e v e l . m k
2013-02-17 15:30:59 +00:00
2013-03-07 20:50:15 +00:00
d e f i n e G l u o n P r o f i l e
image/$(1) : FORCE
+@$$ ( GLUONMAKE) $$ @
e n d e f
2014-02-05 21:12:50 +00:00
d e f i n e G l u o n M o d e l
e n d e f
2014-05-10 09:52:06 +00:00
i n c l u d e $( GLUONDIR ) / t a r g e t s / t a r g e t s . m k
2013-03-07 20:50:15 +00:00
2013-12-28 21:13:18 +00:00
2014-05-11 08:43:10 +00:00
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
2014-05-11 08:43:10 +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
2014-05-11 08:43:10 +00:00
prepare : prepare -target
2013-04-04 23:21:27 +00:00
+@$( GLUONMAKE) $@
2013-02-17 15:30:59 +00:00
2014-05-11 08:43:10 +00:00
clean dirclean download images : FORCE
@$( CheckExternal)
+@$( GLUONMAKE_EARLY) maybe-prepare-target
2014-05-09 07:06:41 +00:00
+@$( GLUONMAKE) $@
2014-05-11 08:43:10 +00:00
toolchain/% package/% target/% : FORCE
@$( CheckExternal)
+@$( GLUONMAKE_EARLY) maybe-prepare-target
2014-02-06 12:20:34 +00:00
+@$( GLUONMAKE) $@
2014-05-11 08:43:10 +00:00
manifest : FORCE
[ -n " $( GLUON_BRANCH) " ] || ( echo 'Please set GLUON_BRANCH to create a manifest.' ; false )
2014-01-11 11:01:19 +00:00
@$( CheckExternal)
2014-05-11 08:43:10 +00:00
+@$( GLUONMAKE_EARLY) maybe-prepare-target
+@$( GLUONMAKE) $@
2013-02-17 15:30:59 +00:00
2014-05-11 20:27:36 +00:00
cleanall : clean ;
2013-02-17 15:30:59 +00:00
e l s e
2013-02-11 22:06:19 +00:00
2014-05-11 08:43:10 +00:00
TOPDIR = ${ CURDIR }
export TOPDIR
2014-05-10 14:54:52 +00:00
i n c l u d e r u l e s . m k
2013-02-11 03:52:16 +00:00
2014-05-10 14:54:52 +00:00
i n c l u d e $( GLUONDIR ) / i n c l u d e / g l u o n . m k
2013-02-17 15:30:59 +00:00
2014-05-10 14:54:52 +00:00
i n c l u d e $( INCLUDE_DIR ) / h o s t . m k
2013-02-17 15:30:59 +00:00
i n c l u d e $( INCLUDE_DIR ) / d e p e n d s . m k
i n c l u d e $( INCLUDE_DIR ) / s u b d i r . m k
2013-02-17 23:39:44 +00:00
2013-02-17 15:30:59 +00:00
i n c l u d e p a c k a g e / M a k e f i l e
i n c l u d e t o o l s / M a k e f i l e
i n c l u d e t o o l c h a i n / M a k e f i l e
2013-02-11 22:06:19 +00:00
2013-10-08 01:57:08 +00:00
2013-02-17 15:30:59 +00:00
PROFILES :=
PROFILE_PACKAGES :=
2013-10-08 01:57:08 +00:00
d e f i n e P r o f i l e
$( eval $( call Profile/Default) )
$( eval $( call Profile/$( 1) ) )
$( 1) _PACKAGES := $( PACKAGES)
e n d e f
2013-02-12 06:14:18 +00:00
d e f i n e G l u o n P r o f i l e
PROFILES += $( 1)
2013-10-08 01:57:08 +00:00
PROFILE_PACKAGES += $( filter-out -%,$( $( 1) _PACKAGES) $( 2) $( GLUON_$( 1) _SITE_PACKAGES) )
2013-04-05 20:53:09 +00:00
GLUON_$(1)_DEFAULT_PACKAGES := $( 2)
2014-02-05 21:12:50 +00:00
GLUON_$(1)_MODELS :=
e n d e f
d e f i n e G l u o n M o d e l
GLUON_$(1)_MODELS += $( 2)
GLUON_$(1)_MODEL_$(2) := $( 3)
2013-02-12 06:14:18 +00:00
e n d e f
2014-05-10 09:52:06 +00:00
i n c l u d e $( GLUONDIR ) / t a r g e t s / t a r g e t s . m k
BOARD := $( GLUON_TARGET_$( GLUON_TARGET) _BOARD)
override SUBTARGET : = $( GLUON_TARGET_ $ ( GLUON_TARGET ) _SUBTARGET )
2014-05-11 08:43:10 +00:00
target_prepared_stamp := $( BOARD_BUILDDIR) /target-prepared
2014-05-10 09:52:06 +00:00
gluon_prepared_stamp := $( BOARD_BUILDDIR) /prepared
2013-10-08 01:57:08 +00:00
i n c l u d e $( INCLUDE_DIR ) / t a r g e t . m k
2013-02-17 15:30:59 +00:00
2013-04-05 20:53:09 +00:00
2014-05-07 22:49:46 +00:00
gluon-tools : $( STAGING_DIR_HOST ) /bin /stat
2014-05-11 08:43:10 +00:00
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
+$( NO_TRACE_MAKE) -C $( TOPDIR) prepare-tmpinfo OPENWRT_BUILD = 0
config : FORCE
( \
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
mkdir -p $( GLUON_OPENWRTDIR)
for dir in build_dir dl staging_dir tmp; do \
mkdir -p $( GLUON_ORIGOPENWRTDIR) /$$ dir; \
done
for link in build_dir Config.in dl include Makefile package rules.mk scripts staging_dir target tmp 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 )
2014-05-07 22:49:46 +00:00
2013-02-17 15:30:59 +00:00
$(BUILD_DIR)/.prepared : Makefile
@mkdir -p $$ ( dirname $@ )
@touch $@
$(toolchain/stamp-install) : $( tools /stamp -install )
2013-02-17 23:39:44 +00:00
$(package/stamp-compile) : $( package /stamp -cleanup )
2013-02-17 15:30:59 +00:00
2013-04-04 23:21:27 +00:00
2014-05-11 08:43:10 +00:00
clean : FORCE
+$( SUBMAKE) clean
2014-05-12 05:21:35 +00:00
rm -f $( gluon_prepared_stamp)
2013-04-05 20:53:09 +00:00
2014-05-11 08:43:10 +00:00
dirclean : FORCE
+$( SUBMAKE) dirclean
rm -rf $( GLUON_BUILDDIR)
2013-09-28 16:39:32 +00:00
export GLUON_GENERATE := $( GLUONDIR) /scripts/generate.sh
2013-09-30 17:04:35 +00:00
export GLUON_CONFIGURE := $( GLUONDIR) /scripts/configure.pl
2013-09-28 16:39:32 +00:00
2014-05-11 08:43:10 +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-04-04 23:21:27 +00:00
2013-02-17 15:30:59 +00:00
toolchain : $( toolchain /stamp -install ) $( tools /stamp -install )
2013-02-17 23:39:44 +00:00
2013-04-06 20:23:33 +00:00
i n c l u d e $( INCLUDE_DIR ) / k e r n e l . m k
2013-02-17 23:39:44 +00:00
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 23:39:44 +00:00
2013-02-17 15:30:59 +00:00
packages : $( package /stamp -compile )
2013-02-17 23:39:44 +00:00
$( _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
2014-05-10 09:52:06 +00:00
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 )
2013-02-17 15:30:59 +00:00
prepare : FORCE
2014-01-11 11:01:19 +00:00
@$( CheckSite)
2014-05-09 08:41:55 +00:00
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) config
+$( GLUONMAKE) toolchain
+$( GLUONMAKE) kernel
+$( GLUONMAKE) packages
+$( GLUONMAKE) prepare-image
2013-02-12 01:03:37 +00:00
2014-01-20 01:19:59 +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
2013-04-05 20:53:09 +00:00
i n c l u d e $( INCLUDE_DIR ) / p a c k a g e - i p k g . m k
# 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
2013-04-05 20:53:09 +00:00
TMP_DIR = $( PROFILE_BUILDDIR) /tmp
TARGET_DIR = $( PROFILE_BUILDDIR) /root
2014-02-11 00:25:10 +00:00
IMAGE_PREFIX = gluon-$( GLUON_SITE_CODE) -$$ ( cat $( gluon_prepared_stamp) )
2014-02-05 21:12:50 +00:00
2013-04-05 20:53:09 +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 \
--force-depends \
--force-overwrite \
--force-postinstall \
--cache $( TMP_DIR) /dl \
--offline-root $( TARGET_DIR) \
--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
2013-09-11 20:41:49 +00:00
2013-04-05 20:53:09 +00:00
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) ) ; \
2013-04-05 20:53:09 +00:00
) : \
)
2013-09-11 20:41:49 +00:00
2014-01-13 17:23:25 +00:00
# Generate package list
$( eval $ ( call merge -lists ,INSTALL_PACKAGES ,DEFAULT_PACKAGES $ ( PROFILE ) _PACKAGES GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_ $ ( PROFILE ) _DEFAULT_PACKAGES GLUON_ $ ( PROFILE ) _SITE_PACKAGES ) )
2013-09-11 20:41:49 +00:00
2013-04-05 20:53:09 +00:00
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
2013-04-05 20:53:09 +00:00
rm -f $( TARGET_DIR) /usr/lib/opkg/lists/* $( TARGET_DIR) /tmp/opkg.lock
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
2013-04-05 20:53:09 +00:00
cp -r $( BOARD_KDIR) $( PROFILE_KDIR)
2013-09-24 17:23:09 +00:00
+$( GLUONMAKE) package_install
2013-04-05 20:53:09 +00:00
$( call Image/mkfs/prepare)
2014-05-09 08:41:55 +00:00
$( _SINGLE) $( NO_TRACE_MAKE) -C $( TOPDIR) /target/linux/$( BOARD) /image install TARGET_BUILD = 1 IB = 1 IMG_PREFIX = gluon \
2013-04-05 20:53:09 +00:00
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) , \
2014-02-13 14:50:59 +00:00
rm -f $( GLUON_IMAGEDIR) /factory/gluon-*-$( GLUON_$( PROFILE) _MODEL_$( model) ) .bin && \
rm -f $( GLUON_IMAGEDIR) /sysupgrade/gluon-*-$( GLUON_$( PROFILE) _MODEL_$( model) ) -sysupgrade.bin && \
2014-02-05 21:12:50 +00:00
\
2014-05-09 08:41:55 +00:00
cp $( BIN_DIR) /gluon-$( model) -factory.bin $( GLUON_IMAGEDIR) /factory/$( IMAGE_PREFIX) -$( GLUON_$( PROFILE) _MODEL_$( model) ) .bin && \
cp $( BIN_DIR) /gluon-$( model) -sysupgrade.bin $( GLUON_IMAGEDIR) /sysupgrade/$( IMAGE_PREFIX) -$( GLUON_$( PROFILE) _MODEL_$( model) ) -sysupgrade.bin && \
2014-02-05 21:12:50 +00:00
) :
2013-04-05 20:53:09 +00:00
2014-05-10 09:52:06 +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
2014-02-11 16:11:11 +00:00
( cd $( GLUON_IMAGEDIR) /sysupgrade && echo 'BRANCH=$(GLUON_BRANCH)' && echo && ( $( foreach profile,$( PROFILES) , \
2014-02-06 12:20:34 +00:00
$( foreach model,$( GLUON_$( profile) _MODELS) , \
2014-02-11 00:25:10 +00:00
for file in gluon-*-'$(GLUON_$(profile)_MODEL_$(model))-sysupgrade.bin' ; do \
2014-02-06 12:20:34 +00:00
[ -e " $$ file " ] && echo \
2014-02-11 00:25:10 +00:00
'$(GLUON_$(profile)_MODEL_$(model))' \
" $$ (echo " $$ file" | sed -n -r -e 's/^gluon- $( call regex-escape,$( GLUON_SITE_CODE) ) -(.*)- $( call regex-escape,$( GLUON_$( profile) _MODEL_$( model) ) ) -sysupgrade\.bin $$ /\1/p') " \
" $$ (sha512sum " $$ file" | awk '{print $$ 1}') " \
2014-02-06 12:20:34 +00:00
" $$ file " && break; \
done ; \
) \
2014-02-12 09:03:26 +00:00
) :) ) > $( GLUON_IMAGEDIR) /sysupgrade/$( GLUON_BRANCH) .manifest
2014-02-06 12:20:34 +00:00
2014-05-07 22:49:46 +00:00
.PHONY : all images prepare clean cleanall gluon -tools
2013-02-17 15:30:59 +00:00
e n d i f