2f307ffffb
The former toplevel Makefile is now toplevel main.mk; this change allows for multi-target, multi-arch processing in the current toplevel Makefile. As the "build" symlink semantics change quite considerably when one is doing bulk builds (several pruned builddirs might be useful for comparison), BUILDDIR is now much more likely to be recreated: the cases when it will persist are when it's either a single-image build or when the prefix hasn't changed. There are some more or less subtle bugfixes and enhancements all over the map as well. Done within 20111230..20120102 timeframe, actually...
109 lines
3.0 KiB
Makefile
109 lines
3.0 KiB
Makefile
ifndef MKIMAGE_PROFILES
|
|
$(error this makefile is designed to be included in toplevel one)
|
|
endif
|
|
|
|
SYMLINK = build
|
|
|
|
# this could have come from env; or could be symlinked; or is made anew
|
|
# (the reuse rationale is avoiding extra tmpdir lookups)
|
|
# NB: immediate assignment matters
|
|
ifndef BUILDDIR
|
|
BUILDLINK := $(realpath $(SYMLINK))
|
|
BUILDDIR := $(shell \
|
|
if [ -s "$(SYMLINK)" -a "$(NUM_TARGETS)" = 1 ] && \
|
|
[ -n "$(findstring $(BUILDDIR_PREFIX).,$(BUILDLINK))" ]; \
|
|
then \
|
|
echo "$(BUILDLINK)"; \
|
|
else \
|
|
bin/mktmpdir $(BUILDDIR_PREFIX) || exit 127; \
|
|
fi; )
|
|
endif
|
|
|
|
# even smart caching only hurts when every build goes from scratch
|
|
NO_CACHE ?= 1
|
|
|
|
PATH := $(CURDIR)/bin:$(PATH)
|
|
|
|
export BUILDDIR NO_CACHE PATH
|
|
|
|
CONFIG := $(BUILDDIR)/distcfg.mk
|
|
RC := $(HOME)/.mkimage/profiles.mk
|
|
|
|
# step 1: initialize the off-tree mkimage profile (BUILDDIR)
|
|
profile/init: distclean
|
|
@if [ "`realpath "$(BUILDDIR)/"`" = / ]; then \
|
|
echo "$(TIME) ERROR: invalid BUILDDIR: \`$(BUILDDIR)'"; \
|
|
exit 128; \
|
|
fi;
|
|
@echo -n "$(TIME) initializing BUILDDIR: "
|
|
@rsync -qaxH --delete-after image.in/ "$(BUILDDIR)"/
|
|
@mkdir "$(BUILDDIR)"/.mki # mkimage toplevel marker
|
|
@$(call put,ifndef DISTCFG_MK)
|
|
@$(call put,DISTCFG_MK = 1)
|
|
@if type -t git >&/dev/null; then \
|
|
if [ -d .git ]; then \
|
|
git show-ref --head -d -s -- HEAD && \
|
|
git status -s && \
|
|
echo; \
|
|
fi $(LOG); \
|
|
fi
|
|
@{ \
|
|
eval `apt-config shell $${APTCONF:+-c=$(wildcard $(APTCONF))} \
|
|
SOURCELIST Dir::Etc::sourcelist/f \
|
|
SOURCEPARTS Dir::Etc::sourceparts/d`; \
|
|
find "$$SOURCEPARTS" -name '*.list' \
|
|
| xargs egrep -Rhv '^#|^[[:blank:]]*$$' "$$SOURCELIST" && \
|
|
echo; \
|
|
} $(LOG)
|
|
@if type -t git >&/dev/null; then \
|
|
if cd $(BUILDDIR); then \
|
|
git init -q && \
|
|
git add . && \
|
|
git commit -qam 'derivative profile initialized'; \
|
|
fi; \
|
|
fi
|
|
@if [ -w . ]; then \
|
|
rm -f "$(SYMLINK)" && \
|
|
ln -s "$(BUILDDIR)" "$(SYMLINK)" && \
|
|
echo "$(SYMLINK)/"; \
|
|
else \
|
|
echo "$(BUILDDIR)/" $(SHORTEN); \
|
|
fi $(SHORTEN)
|
|
|
|
profile/bare: profile/init
|
|
@NOTE="$${GLOBAL_VERBOSE:+: $(CONFIG)}"; \
|
|
echo "$(TIME) preparing distro config$$NOTE" \
|
|
$(SHORTEN)
|
|
@$(call try,MKIMAGE_PREFIX,/usr/share/mkimage)
|
|
@$(call try,GLOBAL_VERBOSE,)
|
|
@$(call try,IMAGEDIR,$(IMAGEDIR))
|
|
@$(call try,BRANDING,altlinux-sisyphus)
|
|
@$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release)
|
|
@if type -t git >&/dev/null && cd $(BUILDDIR); then \
|
|
git init -q && \
|
|
git add . && \
|
|
git commit -qam 'image configuration defaults set'; \
|
|
fi
|
|
|
|
profile/finalize:
|
|
@if [ -s $(RC) ]; then $(call put,-include $(RC)); fi
|
|
@$(call put,endif)
|
|
@if type -t git >&/dev/null && cd $(BUILDDIR); then \
|
|
git init -q && \
|
|
git add . && \
|
|
git commit -qam 'image configuration finalized'; \
|
|
fi
|
|
|
|
# requires already formed distcfg.mk for useful output
|
|
profile/dump-vars:
|
|
@if [ -s "$(SYMLINK)" ]; then \
|
|
$(MAKE) --no-print-directory -C "$(SYMLINK)/" -f vars.mk; \
|
|
echo; \
|
|
fi $(LOG)
|
|
|
|
# step 3 entry point: copy the needed parts into BUILDDIR
|
|
profile/populate: profile/init profile/finalize profile/dump-vars
|
|
@for dir in sub.in features.in pkg.in; do \
|
|
$(MAKE) -C $$dir $(LOG); \
|
|
done
|