2010-12-03 17:53:02 +03:00
# steps to build a distribution image:
2010-09-27 23:02:57 +04:00
# --- here
2010-12-03 17:53:02 +03:00
# 1. initialize new profile (BUILDDIR) as a copy of image.in/
# 2. configure distro
2011-10-06 12:46:31 +04:00
# 3. copy the needed bits from metaprofile to a new profile
2010-09-27 23:02:57 +04:00
# --- in BUILDDIR
2011-10-06 12:46:31 +04:00
# 4. build subprofiles and subsequently an image
2010-09-27 23:02:57 +04:00
2011-10-06 12:46:31 +04:00
MKIMAGE_PROFILES = $( dir $( lastword $( MAKEFILE_LIST) ) )
# only process the first target (inter-target cleanup is tricky)
IMAGE_TARGET := $( firstword $( MAKECMDGOALS) ) # distro/server-base.iso
IMAGE_CONF := $( basename $( MAKECMDGOALS) ) # distro/server-base
IMAGE_CLASS := $( dir $( IMAGE_TARGET) ) # distro/ (let's fix it)
IMAGE_CLASS := $( IMAGE_CLASS:%/= %) # distro
IMAGE_FILE := $( notdir $( IMAGE_TARGET) ) # server-base.iso
IMAGE_NAME := $( basename $( IMAGE_FILE) ) # server-base
IMAGE_TYPE := $( suffix $( IMAGE_FILE) ) # .iso (fix this too)
IMAGE_TYPE := $( IMAGE_TYPE:.%= %) # iso
2010-08-28 20:28:42 +04:00
2011-11-04 18:51:11 +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
2011-05-11 23:40:47 +04:00
# most of the actual work done elsewhere
2011-10-06 12:46:31 +04:00
i n c l u d e l i b / * . m k
2011-10-31 14:40:02 +04:00
i n c l u d e c o n f . d / * . m k
2011-10-06 12:46:31 +04:00
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
2011-10-31 14:40:02 +04:00
DISTRO_TARGETS := $( shell sed -n 's,^\(distro/[^:.]\+\):.*$$,\1,p' \
lib/distro.mk $( wildcard conf.d/*.mk) | sort)
VE_TARGETS := $( shell sed -n 's,^\(ve/[^:.]\+\):.*$$,\1,p' \
lib/ve.mk $( wildcard conf.d/*.mk) | sort)
2011-10-06 12:46:31 +04:00
DISTROS := $( call addsuffices,$( DISTRO_EXTS) ,$( DISTRO_TARGETS) )
VES := $( call addsuffices,$( VE_EXTS) ,$( VE_TARGETS) )
IMAGES := $( DISTROS) $( VES)
2010-09-13 18:22:05 +04:00
2011-10-31 14:40:02 +04:00
.PHONY : $( IMAGES ) $( DISTRO_TARGETS ) $( VE_TARGETS )
2011-09-12 13:26:20 +04:00
2011-10-06 12:46:31 +04:00
help :
@echo '** available distribution targets:'
@echo $( DISTROS) | fmt -sw" $$ ((COLUMNS>>1)) " | column -t
@echo
@echo '** available virtual environment targets:'
@echo $( VES) | fmt -sw" $$ ((COLUMNS>>1)) " | column -t
### suboptimal but at least clear, reliable and convenient
all :
2011-11-04 15:26:31 +04:00
@n= 1; sum = $( words $( DISTROS) ) ; \
for distro in $( DISTROS) ; do \
echo " ** building $$ distro: " ; \
$( MAKE) --no-print-directory \
ALL = $$ n/$$ sum \
BUILDDIR = $( BUILDDIR) \
$$ distro; \
2011-10-06 12:46:31 +04:00
echo; \
2011-11-04 15:26:31 +04:00
n = $$ ( ( $$ n+1) ) ; \
2011-10-06 12:46:31 +04:00
done
$(IMAGES) : debug \
config/with/$( IMAGE_CONF) \
config/like/$( IMAGE_CLASS) \
config/name/$( IMAGE_NAME) \
config/pack/$( IMAGE_TYPE) \
build; @:
debug :
i f e q ( 2 , $( DEBUG ) )
@$( foreach v,\
$( filter IMAGE_%,$( sort $( .VARIABLES) ) ) ,\
$( warning $v = $( $v ) ) )
e n d i f