2011-12-30 14:46:58 +04:00
# steps to build an image:
# --- here
# 1. initialize new profile (BUILDDIR) as a copy of image.in/
# 2. configure distro
# 3. copy the needed bits from metaprofile to a new profile
# --- in BUILDDIR
# 4. build subprofiles and subsequently an image
# deal with one target at a time
IMAGE_TARGET := $( firstword $( MAKECMDGOALS) ) # ve/generic.tar.gz
i f e q ( . / , $( dir $ ( IMAGE_TARGET ) ) ) # convenience fallback
IMAGE_TARGET := distro/$( IMAGE_TARGET) # for omitted "distro/"
2015-04-02 21:02:51 +03:00
IMAGE_GUESS := 1
e l s e
IMAGE_GUESS :=
2011-12-30 14:46:58 +04:00
e n d i f
IMAGE_CONF := $( firstword $( subst ., ,$( IMAGE_TARGET) ) ) # ve/generic
IMAGE_CLASS := $( firstword $( subst /, ,$( IMAGE_TARGET) ) ) # ve
IMAGE_FILE := $( lastword $( subst /, ,$( IMAGE_TARGET) ) ) # generic.tar.gz
2022-11-25 14:59:47 +03:00
i f n e q ( s i s y p h u s , $( BRANCH ) )
2021-05-30 18:49:00 +03:00
IMAGE_FILE := $( subst regular,alt-$( BRANCH) ,$( IMAGE_FILE) )
e n d i f
2011-12-30 14:46:58 +04:00
IMAGE_NAME := $( firstword $( subst ., ,$( IMAGE_FILE) ) ) # generic
IMAGE_TYPE := $( subst $( IMAGE_NAME) .,,$( IMAGE_FILE) ) # tar.gz
2015-04-02 21:02:51 +03:00
i f e q ( $( IMAGE_NAME ) , $( IMAGE_TYPE ) $( IMAGE_GUESS ) )
2015-06-03 13:25:45 +03:00
i f n e q ( h e l p , $( IMAGE_CLASS ) )
2015-04-02 21:02:51 +03:00
$( warning no image type /extension specified , run make help ?)
e n d i f
2015-06-03 13:25:45 +03:00
e n d i f
2011-12-30 14:46:58 +04:00
# readjustable
i f e q ( 1 , $( NUM_TARGETS ) )
BUILDDIR_PREFIX ?= mkimage-profiles.build
e l s e
BUILDDIR_PREFIX ?= mkimage-profiles.build/$( IMAGE_CONF) .$( ARCH)
e n d i f
2012-07-18 17:06:15 +04:00
export MKIMAGE_PROFILES := $( realpath $( dir $( lastword $( MAKEFILE_LIST) ) ) )
2011-12-30 14:46:58 +04:00
# preferences
- i n c l u d e $( HOME ) / . m k i m a g e / p r o f i l e s . m k
# most of the actual work done elsewhere
2012-10-10 17:18:32 +04:00
i n c l u d e $( sort $ ( wildcard lib /*.mk ) )
2011-12-30 14:46:58 +04:00
i n c l u d e c o n f . d / * . m k
i n c l u d e f e a t u r e s . i n / * / c o n f i g . m k
2013-02-04 19:18:06 +04:00
# ensure the outdir is created and globbable
2022-11-23 08:39:50 +03:00
i f n e q ( , $( IMAGEDIR ) )
2013-02-04 19:18:06 +04:00
$( shell mkdir -p $ ( IMAGEDIR ) )
IMAGEDIR := $( wildcard $( IMAGEDIR) )
e n d i f
2013-06-19 19:57:30 +04:00
# conf.d/*.mk can expose parts conditionally (e.g. DEBUG-only bits)
targets = $( shell \
for i in conf.d/*.mk; do \
make IMAGE_CLASS = $( 1) -s -r -p -f $$ i 2>/dev/null; \
done \
| sed -rn 's,^($(1)/[^.:]+):.*,\1,p' \
| sort -u)
DISTRO_TARGETS := $( call targets,distro)
VE_TARGETS := $( call targets,ve)
VM_TARGETS := $( call targets,vm)
2011-12-30 14:46:58 +04:00
DISTROS := $( call addsuffices,$( DISTRO_EXTS) ,$( DISTRO_TARGETS) )
VES := $( call addsuffices,$( VE_EXTS) ,$( VE_TARGETS) )
2020-08-27 19:39:54 +03:00
VES_TAR := $( call addsuffices,.tar,$( VE_TARGETS) )
2019-05-19 12:39:04 +03:00
VMS := $( call addsuffices,$( VM_EXTS) ,$( VM_TARGETS) ) \
2020-09-07 13:50:56 +03:00
$( call addsuffices,$( VM_TAVOLGA_EXTS) , $( filter vm/%-tavolga, $( VM_TARGETS) ) )
2020-08-27 19:39:54 +03:00
VMS_IMG := $( call addsuffices,.img,$( VM_TARGETS) )
2012-06-18 22:00:32 +04:00
IMAGES := $( DISTROS) $( VES) $( VMS)
2011-12-30 14:46:58 +04:00
2012-06-18 22:00:32 +04:00
.PHONY : $( IMAGES ) $( DISTRO_TARGETS ) $( VE_TARGETS ) $( VM_TARGETS )
2011-12-30 14:46:58 +04:00
.PHONY : debug everything help space
2013-06-15 15:40:15 +04:00
# grepping for localized error messages is not trivial
export LC_MESSAGES = C
2011-12-30 14:46:58 +04:00
### duplicate but still needed
everything :
2020-08-27 19:39:54 +03:00
@n= 1; sum = $( words $( DISTROS) $( VES_TAR) $( VMS_IMG) ) ; \
for distro in $( DISTROS) $( VES_TAR) $( VMS_IMG) ; do \
2011-12-30 14:46:58 +04:00
echo " ** building $$ distro [ $$ n/ $$ sum]: " ; \
2012-01-17 00:32:54 +04:00
$( MAKE) -f main.mk --no-print-directory $$ distro; \
[ " $$ n " -lt " $$ sum " ] && echo; \
2011-12-30 14:46:58 +04:00
n = $$ ( ( $$ n+1) ) ; \
done
# config/with/ve/generic config/like/ve config/name/generic config/pack/tar.gz
$(IMAGES) : debug \
config/with/$( IMAGE_CONF) \
config/like/$( IMAGE_CLASS) \
config/name/$( IMAGE_NAME) \
config/pack/$( IMAGE_TYPE) \
build; @:
# convenience shortcut
2012-03-19 15:23:58 +04:00
$(DISTROS : distro /%=%): %: distro /%; @:
2011-12-30 14:46:58 +04:00
2017-08-07 21:49:47 +03:00
debug ::
2011-12-30 14:46:58 +04:00
i f e q ( 2 , $( DEBUG ) )
@$( foreach v,\
$( filter IMAGE_%,$( sort $( .VARIABLES) ) ) ,\
$( warning $v = $( $v ) ) )
e n d i f