Makefile 2.16 KB
Newer Older
Michael Shigorin's avatar
Michael Shigorin committed
1
# steps to build a distribution image:
2
# --- here
Michael Shigorin's avatar
Michael Shigorin committed
3 4
# 1. initialize new profile (BUILDDIR) as a copy of image.in/
# 2. configure distro
5
# 3. copy the needed bits from metaprofile to a new profile
6
# --- in BUILDDIR
7
# 4. build subprofiles and subsequently an image
8

9 10 11 12 13 14 15 16 17 18 19
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
20

21 22 23
# preferences
-include $(HOME)/.mkimage/profiles.mk

24
# most of the actual work done elsewhere
25
include lib/*.mk
26
include conf.d/*.mk
27 28
include features.in/*/config.mk

29 30 31 32
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)
33 34 35
DISTROS := $(call addsuffices,$(DISTRO_EXTS),$(DISTRO_TARGETS)) 
VES     := $(call addsuffices,$(VE_EXTS),$(VE_TARGETS))
IMAGES  := $(DISTROS) $(VES)
36

37
.PHONY: $(IMAGES) $(DISTRO_TARGETS) $(VE_TARGETS)
38

39 40 41 42 43 44 45 46 47
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:
48 49 50 51 52 53 54
	@n=1; sum=$(words $(DISTROS)); \
	for distro in $(DISTROS); do \
		echo "** building $$distro:"; \
		$(MAKE) --no-print-directory \
			ALL=$$n/$$sum \
			BUILDDIR=$(BUILDDIR) \
			$$distro; \
55
		echo; \
56
		n=$$(($$n+1)); \
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
	done

$(IMAGES): debug \
	config/with/$(IMAGE_CONF) \
	config/like/$(IMAGE_CLASS) \
	config/name/$(IMAGE_NAME) \
	config/pack/$(IMAGE_TYPE) \
	build; @:

debug:
ifeq (2,$(DEBUG))
	@$(foreach v,\
		$(filter IMAGE_%,$(sort $(.VARIABLES))),\
		$(warning $v = $($v)))
endif