generate.mk 3.27 KB
Newer Older
1
ifdef BUILDDIR
Michael Shigorin's avatar
Michael Shigorin committed
2

3 4 5
# in deciseconds
DEFAULT_TIMEOUT = 90

6 7
# prepare data for syslinux installation;
# see also stage1/scripts.d/01-syslinux
Michael Shigorin's avatar
Michael Shigorin committed
8

9 10 11 12
include $(BUILDDIR)/distcfg.mk

ifndef BOOTLOADER
$(error syslinux feature enabled but BOOTLOADER undefined)
Michael Shigorin's avatar
Michael Shigorin committed
13 14
endif

15 16
# UI is backed by modules in modern syslinux
# (except for built-in text prompt)
17
ifdef SYSLINUX_UI
18
SYSLINUX_MODULES := $(SYSLINUX_MODULES) $(SYSLINUX_UI)
19
else
20 21
$(warning no syslinux ui configured, default is now none)
SYSLINUX_UI := none
22
endif
23

24
ifndef SYSLINUX_DIRECT
25
# SUBPROFILES are considered SYSLINUX_CFG too
26
# (note these can appear like stage2@live);
27
# 01defaults.cfg is included indefinitely
28
SYSLINUX_CFG := $(SYSLINUX_CFG) $(SUBPROFILE_DIRS) defaults
29
endif
30

31 32
DSTDIR  := $(BUILDDIR)/stage1/files/syslinux/.in
DSTCFGS := $(DSTDIR)/*.cfg
Michael Shigorin's avatar
Michael Shigorin committed
33

34 35 36 37 38 39
# we can do SYSLINUX_{CFG,MODULES,FILES}
# CFG have only cfg snippet
# FILES have only filenames (absolute or relative to /usr/lib/syslinux/)
# MODULES must have both cfg snippet and syslinux module filename
#         (and get included iff cfg snippet AND module exist)
cfg = $(wildcard cfg.in/??$(1).cfg)
Michael Shigorin's avatar
Michael Shigorin committed
40

41
# NB: list position determined by file numbering (*.cfg sorting)
42 43 44 45 46 47 48 49 50 51
#
# config snippets are copied into generated profile where they can
# be also tested against syslinux modules (some can be unavailable);
# we can't do tests right now since that implies host syslinux being
# identical to build system one which might be not the case...
#
# have to piggyback parameters as we're running in host system yet,
# and files involved will appear inside instrumental chroot
#
# arguments get evaluated before recipe body execution thus prep
52

53
all: debug timeout
54
	@### proper text branding should be implemented
55
	@echo $(SYSLINUX_MODULES) > $(DSTDIR)/modules.list
56
	@echo $(SYSLINUX_FILES) > $(DSTDIR)/syslinux.list
57 58
	@sed -i \
		-e 's,@mkimage-profiles@,$(IMAGE_NAME),' \
59
		-e 's,@relname@,$(RELNAME),' \
60
		$(DSTCFGS)
61

62
# integerity check
63
timeout: distro
64 65 66 67 68
	@if [ "$(SYSLINUX_TIMEOUT)" -ge 0 ] 2>/dev/null; then \
		TIMEOUT="$(SYSLINUX_TIMEOUT)"; \
	else \
		TIMEOUT="$(DEFAULT_TIMEOUT)"; \
	fi; \
69
	sed -i "s,@timeout@,$$TIMEOUT," $(DSTCFGS)
70

71 72 73 74
distro: bootargs
	@if [ -n "$(META_VOL_SET)" ]; then \
		DISTRO="$(META_VOL_SET)"; \
	else \
75
		DISTRO="ALT"; \
76
	fi; \
77
	sed -i "s,@distro@,$$DISTRO," $(DSTCFGS)
78

79
# pass over additional parameters, if any
80
bootargs: clean
81
	@if [ -n "$(STAGE2_BOOTARGS)" ]; then \
82
		sed -i "s,@bootargs@,$(STAGE2_BOOTARGS)," $(DSTCFGS); \
83
	fi; \
84
	sed -i "s,@bootargs@,," $(DSTCFGS)
85
	@if [ -n "$(RESCUE_BOOTARGS)" ]; then \
86
		sed -i "s,@rescue_bootargs@,$(RESCUE_BOOTARGS)," $(DSTCFGS); \
87
	fi; \
88
	sed -i "s,@rescue_bootargs@,," $(DSTCFGS)
89
	@if [ -n "$(BOOTVGA)" ]; then \
90
		sed -i "s,@bootvga@,$(BOOTVGA)," $(DSTCFGS); \
91
	fi; \
92
	sed -i "s,@bootvga@,,;s,vga= ,," $(DSTCFGS)
93

94 95
clean: copy
	@if [ "$(SYSLINUX_UI)" = gfxboot ]; then \
96
		sed -i "s/\^//;/menu label /d" $(DSTCFGS); \
97 98
	fi

99 100 101 102 103
copy: prep
	@cp -pLt $(DSTDIR) -- $(sort \
		$(foreach C,$(SYSLINUX_CFG),$(call cfg,$(C))) \
		$(foreach M,$(SYSLINUX_MODULES),$(call cfg,$(M))))

104
prep:
Michael Shigorin's avatar
Michael Shigorin committed
105
	@mkdir -p $(DSTDIR)
Michael Shigorin's avatar
Michael Shigorin committed
106 107

debug:
108
	@if [ -n "$(DEBUG)" ]; then \
109 110 111 112 113 114 115 116
		echo "** BOOTLOADER: $(BOOTLOADER)"; \
		echo "** SYSLINUX_UI: $(SYSLINUX_UI)"; \
		echo "** SYSLINUX_CFG: $(SYSLINUX_CFG)"; \
		echo "** SYSLINUX_FILES: $(SYSLINUX_FILES)"; \
		echo "** SYSLINUX_MODULES: $(SYSLINUX_MODULES)"; \
	fi

endif