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/"
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
IMAGE_NAME := $( firstword $( subst ., ,$( IMAGE_FILE) ) ) # generic
IMAGE_TYPE := $( subst $( IMAGE_NAME) .,,$( IMAGE_FILE) ) # tar.gz
# 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
i f d e f I M A G E D I R
$( 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) )
2012-06-18 22:00:32 +04:00
VMS := $( call addsuffices,$( VM_EXTS) ,$( VM_TARGETS) )
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 :
@n= 1; sum = $( words $( DISTROS) ) ; \
for distro in $( DISTROS) ; do \
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
debug :
i f e q ( 2 , $( DEBUG ) )
@$( foreach v,\
$( filter IMAGE_%,$( sort $( .VARIABLES) ) ) ,\
$( warning $v = $( $v ) ) )
e n d i f