mkimage-profiles/Makefile
Michael Shigorin 041d57542a Makefile: get help back up
Partially reverts "Makefile: presume a distro by default" commit:
plain `make' should better help the user to decide the target
rather than rush to build them all upon her.
2011-11-24 22:09:15 +02:00

78 lines
2.3 KiB
Makefile

# steps to build a distribution 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
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
MKIMAGE_PROFILES = $(dir $(lastword $(MAKEFILE_LIST)))
# only process the first target (inter-target cleanup is tricky)
IMAGE_TARGET := $(firstword $(MAKECMDGOALS))# distro/server-base.iso
ifeq (./,$(dir $(IMAGE_TARGET)))# convenience fallback
IMAGE_TARGET := distro/$(IMAGE_TARGET)# for omitted "distro/"
endif
IMAGE_CONF := $(basename $(IMAGE_TARGET))# 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
# preferences
-include $(HOME)/.mkimage/profiles.mk
# most of the actual work done elsewhere
include lib/*.mk
include conf.d/*.mk
include features.in/*/config.mk
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)
DISTROS := $(call addsuffices,$(DISTRO_EXTS),$(DISTRO_TARGETS))
VES := $(call addsuffices,$(VE_EXTS),$(VE_TARGETS))
IMAGES := $(DISTROS) $(VES)
.PHONY: $(IMAGES) $(DISTRO_TARGETS) $(VE_TARGETS)
### suboptimal but at least clear, reliable and convenient
all:
@n=1; sum=$(words $(DISTROS)); \
for distro in $(DISTROS); do \
echo "** building $$distro:"; \
$(MAKE) --no-print-directory \
ALL=$$n/$$sum \
BUILDDIR=$(BUILDDIR) \
$$distro; \
echo; \
n=$$(($$n+1)); \
done
$(IMAGES): debug \
config/with/$(IMAGE_CONF) \
config/like/$(IMAGE_CLASS) \
config/name/$(IMAGE_NAME) \
config/pack/$(IMAGE_TYPE) \
build; @:
# convenience shortcut
$(DISTROS:distro/%=%): %: distro/%
debug:
ifeq (2,$(DEBUG))
@$(foreach v,\
$(filter IMAGE_%,$(sort $(.VARIABLES))),\
$(warning $v = $($v)))
endif