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
2012-04-06 21:13:32 +04:00
MKIMAGE_PROFILES := $( dir $( lastword $( MAKEFILE_LIST) ) )
2011-12-30 14:46:58 +04:00
# 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
# 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
i n c l u d e l i b / * . m k
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
DISTRO_TARGETS := $( shell sed -n 's,^\(distro/[^:.]\+\):.*$$,\1,p' \
lib/distro.mk $( wildcard conf.d/*.mk) | sort -u)
VE_TARGETS := $( shell sed -n 's,^\(ve/[^:.]\+\):.*$$,\1,p' \
lib/ve.mk $( wildcard conf.d/*.mk) | sort -u)
DISTROS := $( call addsuffices,$( DISTRO_EXTS) ,$( DISTRO_TARGETS) )
VES := $( call addsuffices,$( VE_EXTS) ,$( VE_TARGETS) )
IMAGES := $( DISTROS) $( VES)
.PHONY : $( IMAGES ) $( DISTRO_TARGETS ) $( VE_TARGETS )
.PHONY : debug everything help space
### 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