2010-12-03 17:53:02 +03:00
# step 3: copy the needed features to $(BUILDDIR)
# (only regarding the needed subprofiles)
2011-06-12 19:06:36 +04:00
i f n d e f B U I L D D I R
2012-03-16 22:26:58 +04:00
help/plus all : banner
@$( call grepper,'^+' )
help/features : banner
@$( call grepper,'^use/' )
banner :
2011-09-19 11:55:45 +04:00
@echo "** BUILDDIR not defined; available features:"
2012-03-16 22:26:58 +04:00
grepper = $( and $( 1) ,$( grepper_body) )
d e f i n e g r e p p e r _ b o d y
2011-09-19 11:55:45 +04:00
@for dir in */; do \
2012-03-16 22:26:58 +04:00
out = " `grep -h $( 1) $$ dir/config.mk \
2011-09-19 11:55:45 +04:00
| cut -f1 -d: \
2012-03-16 22:26:58 +04:00
| tr ' ' '\n\n' \
| grep $( 1) \
2011-09-19 11:55:45 +04:00
| tr '\n' ' ' \
2012-03-16 22:26:58 +04:00
| sort -u` " ; \
[ -z " $$ out " ] || echo " $$ dir: $$ out " ; \
2011-09-19 11:55:45 +04:00
done
2012-03-16 22:26:58 +04:00
e n d e f
2012-04-10 20:08:22 +04:00
% :
$( error BUILDDIR not defined)
2011-09-19 11:55:45 +04:00
e l s e
2011-06-12 19:06:36 +04:00
2012-06-21 22:39:37 +04:00
export BUILDDIR
2011-08-22 20:29:22 +04:00
i n c l u d e $( BUILDDIR ) / d i s t c f g . m k
2010-09-14 14:18:53 +04:00
2011-08-22 20:29:22 +04:00
# first rsync what's static, and make backups (*~) --
2010-09-14 14:18:53 +04:00
# these might signal of file clashes (or plain dirt);
2013-05-28 12:51:36 +04:00
# second, care for toplevel dirs;
# then handle feature generator scripts
2011-09-13 20:15:42 +04:00
#
2011-09-11 17:08:31 +04:00
# NB: some subprofiles will be specified as "src/dst"
2011-09-13 20:15:42 +04:00
# -- then both src/ and dst/ can hold the addons;
# still both pieces go into a single destination
2011-10-20 19:44:15 +04:00
### sorry for somewhat complicated and overly long lines
2011-12-06 16:12:25 +04:00
TARGETS := prep $( FEATURES) finalize
.PHONY : $( TARGETS )
all : | $( TARGETS )
prep :
2010-09-14 14:18:53 +04:00
@echo "** starting feature configuration"
2011-09-11 17:08:31 +04:00
@if [ -n " $( GLOBAL_DEBUG) " ] ; then \
echo " ** target subprofiles: $( SUBPROFILES) " ; \
2011-08-22 20:29:22 +04:00
echo " ** requested features: $( FEATURES) " ; \
fi
2011-12-06 16:12:25 +04:00
# feat
2013-05-28 12:51:36 +04:00
# NB: this is somewhat complicated since it has to handle "$sub" like:
# - "/": copy feature's toplevel parts to the BUILDDIR toplevel
# - "stage1": copy feature's stage1 parts into stage1 subprofile
# - "stage2@live": copy feature's stage2 parts into live subprofile
# - "rootfs@/": copy feature's rootfs parts into BUILDDIR toplevel
2011-12-06 16:12:25 +04:00
$(FEATURES) :
@feat= $@ ; \
if [ -n " $( GLOBAL_DEBUG) " ] ; then \
echo " ** adding $$ feat feature " ; \
fi ; \
pushd " $$ feat " >/dev/null && \
for sub in / $( SUBPROFILES) ; do \
if [ " $$ sub " = / ] ; then \
srcdirs = "." ; \
dst = "." ; \
else \
2012-07-10 13:20:15 +04:00
src = " $$ {sub%@*} " ; \
dst = " $$ {sub#*@} " ; \
2013-05-28 12:51:36 +04:00
if [ " $$ src " = / ] ; then \
echo "** src=/: you don't want this" >& 2; \
exit 1; \
fi ; \
if [ " $$ dst " = / -o " $$ dst " = "" ] ; then \
dst = "." ; \
fi ; \
2011-12-06 16:12:25 +04:00
srcdirs = ; \
if [ -d " $$ src " ] ; then \
srcdirs = " $$ src " ; \
2011-10-21 22:07:44 +04:00
fi ; \
2011-12-06 16:12:25 +04:00
if [ -d " $$ dst " -a " $$ dst " != " $$ src " ] ; then \
2012-07-10 13:20:15 +04:00
srcdirs = " $$ {srcdirs:+ $$ srcdirs } $$ dst " ; \
2011-11-14 22:48:56 +04:00
fi ; \
2013-05-28 12:51:36 +04:00
: "why this overduplication was done? (still needed)" ; \
2011-11-14 22:48:56 +04:00
for srcdir in $$ srcdirs; do \
2013-05-28 12:51:36 +04:00
rsync -qab " $$ srcdir/ " " $( BUILDDIR) / $$ dst/ " ; \
2011-09-13 20:15:42 +04:00
done ; \
2011-12-06 16:12:25 +04:00
fi ; \
if [ -n " $( GLOBAL_DEBUG) " ] ; then \
echo " ** src=[ $$ src] dst=[ $$ dst] srcdirs=[ $$ srcdirs] " ; \
fi ; \
for srcdir in $$ srcdirs; do \
[ -d " $$ srcdir " ] || continue ; \
pushd " $$ srcdir " >& /dev/null; \
2012-04-25 15:08:36 +04:00
for part in lib { image-,} scripts.d; do \
2011-12-06 16:12:25 +04:00
destdir = " $( BUILDDIR) / $$ dst/ $$ part " ; \
[ -d " $$ destdir " ] || continue ; \
if [ " $$ sub " = / -a -d " $$ part " ] ; then \
rsync -qab " $$ part/ " " $$ destdir/ " ; \
fi ; \
done ; \
popd >& /dev/null; \
2011-08-22 22:37:21 +04:00
done ; \
2013-05-28 12:51:36 +04:00
if [ -n " $$ dst " -a " $$ dst " != "." ] ; then \
2012-08-10 00:32:00 +04:00
the = " $$ sub subprofile " ; \
else \
the = "toplevel" ; \
2011-10-20 19:44:15 +04:00
fi ; \
2012-08-10 00:32:00 +04:00
mp-commit " $( BUILDDIR) / $$ dst/ " " $$ feat feature: $$ the part added " ; \
2011-12-06 16:12:25 +04:00
done ; \
if [ -x "generate.sh" ] ; then sh generate.sh; fi ; \
if [ -s "generate.mk" ] ; then $( MAKE) -f generate.mk; fi ; \
2012-08-10 00:32:00 +04:00
mp-commit " $( BUILDDIR) " " $$ feat feature generation complete " ; \
2011-12-06 16:12:25 +04:00
popd >/dev/null
finalize :
2011-08-22 20:29:22 +04:00
@find " $( BUILDDIR) / " -name '*~' \
| sed " s, $( BUILDDIR) /,** warning: file clash: , " >& 2
2011-12-06 16:12:25 +04:00
2011-09-19 11:55:45 +04:00
e n d i f