You need to sign in or sign up before continuing.
profile.mk 2.58 KB
Newer Older
1 2 3
ifndef MKIMAGE_PROFILES
$(error this makefile is designed to be included in toplevel one)
endif
4

5 6
SYMLINK = build

7 8
# this could have come from environment;
# if not, can be symlinked if r/w, or made anew
9
# NB: immediate assignment matters
10
# NB: PATH has no effect here
11
ifndef BUILDDIR
12 13
BUILDDIR := $(shell [ -s "$(SYMLINK)" ] \
        && realpath "$(SYMLINK)" \
14 15 16 17 18 19
        || bin/mktmpdir mkimage-profiles.build)
endif

# even smart caching only hurts when every build goes from scratch
NO_CACHE ?= 1

20 21 22
PATH := $(CURDIR)/bin:$(PATH)

export BUILDDIR NO_CACHE PATH
23

24 25 26
CONFIG := $(BUILDDIR)/distcfg.mk
RC := $(HOME)/.mkimage/profiles.mk

27 28
# holds a postprocessor; shell test executes in particular situation
# NB: not exported, for toplevel use only
29 30
SHORTEN = $(shell [ "$(DEBUG)" != 2 -a -s "$(SYMLINK)" ] \
	  && echo "| sed 's,$(BUILDDIR),$(SYMLINK),'")
31

32
# step 1: initialize the off-tree mkimage profile (BUILDDIR)
33 34
profile/init: distclean
	@echo -n "** initializing BUILDDIR: "
Michael Shigorin's avatar
Michael Shigorin committed
35
	@rsync -qaH --delete image.in/ "$(BUILDDIR)"/
36 37
	@$(call put,ifndef DISTCFG_MK)
	@$(call put,DISTCFG_MK = 1)
38 39 40 41
	@{ \
		git show-ref --head -d -s -- HEAD && \
		git status -s && \
		echo; \
42
	} $(LOG)
43
	@mkdir "$(BUILDDIR)"/.mki	# mkimage toplevel marker
44
	@if type -t git >&/dev/null && cd $(BUILDDIR); then \
45 46
		git init -q && \
		git add . && \
47 48
		git commit -qam 'derivative profile initialized'; \
	fi
49
	@rm -f "$(SYMLINK)" && \
50
		if [ -w . ]; then \
51 52
			ln -sf "$(BUILDDIR)" "$(SYMLINK)" && \
			echo "$(SYMLINK)/"; \
53 54 55
		else \
			echo "$(BUILDDIR)/"; \
		fi
Michael Shigorin's avatar
Michael Shigorin committed
56

57 58 59 60 61 62 63
profile/bare: profile/init
	@echo "** preparing distro configuration$${DEBUG:+: see $(CONFIG)}" $(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)
64 65 66 67 68
	@if type -t git >&/dev/null && cd $(BUILDDIR); then \
		git init -q && \
		git add . && \
		git commit -qam 'image configuration defaults set'; \
	fi
69 70 71 72

profile/finalize:
	@if [ -s $(RC) ]; then $(call put,-include $(RC)); fi
	@$(call put,endif)
73 74 75 76 77
	@if type -t git >&/dev/null && cd $(BUILDDIR); then \
		git init -q && \
		git add . && \
		git commit -qam 'image configuration finalized'; \
	fi
78

79 80 81 82 83 84 85
# 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)

86
# step 3 entry point: copy the needed parts into BUILDDIR
87
profile/populate: profile/init profile/finalize profile/dump-vars
Michael Shigorin's avatar
Michael Shigorin committed
88
	@for dir in sub.in features.in pkg.in; do \
89
		$(MAKE) -C $$dir $(LOG); \
Michael Shigorin's avatar
Michael Shigorin committed
90
	done