check conditions of make for equality of variables with an empty value

check conditions of  make  for equality of variables with an empty value
instead of check definition.
A defined but empty variable under all these conditions results errors.
This commit is contained in:
Anton Midyukov 2022-11-23 12:39:50 +07:00
parent 38666a5b29
commit 41b065336f
32 changed files with 54 additions and 56 deletions

View File

@ -6,12 +6,12 @@
-include $(HOME)/.mkimage/profiles.mk -include $(HOME)/.mkimage/profiles.mk
# for immediate assignment # for immediate assignment
ifndef ARCH ifeq (,$(ARCH))
ARCH := $(shell arch \ ARCH := $(shell arch \
| sed 's/i686/i586/; s/armv7.*/armh/; s/armv.*/arm/') | sed 's/i686/i586/; s/armv7.*/armh/; s/armv.*/arm/')
endif endif
ifndef ARCHES ifeq (,$(ARCHES))
ARCHES := $(ARCH) ARCHES := $(ARCH)
endif endif

View File

@ -1,10 +1,10 @@
# build asciidoc books # build asciidoc books
ifdef BUILDDIR ifneq (,$(BUILDDIR))
DEST = -D "$(BUILDDIR)" DEST = -D "$(BUILDDIR)"
endif endif
ifdef DEBUG ifneq (,$(DEBUG))
VERBOSE = --verbose VERBOSE = --verbose
endif endif

View File

@ -10,7 +10,7 @@
include $(BUILDDIR)/distcfg.mk include $(BUILDDIR)/distcfg.mk
ifndef 00EXAMPLE ifeq (,$(00EXAMPLE))
$(warning this is an example, who might want to include it? :]) $(warning this is an example, who might want to include it? :])
endif endif

View File

@ -1,7 +1,6 @@
# step 3: copy the needed features to $(BUILDDIR) # step 3: copy the needed features to $(BUILDDIR)
# (only regarding the needed subprofiles) # (only regarding the needed subprofiles)
ifeq (,$(BUILDDIR))
ifndef BUILDDIR
help/plus all: banner help/plus all: banner
@$(call grepper,'^+') @$(call grepper,'^+')

View File

@ -10,7 +10,7 @@ IMAGE_PACKAGES = $(DOT_BASE) \
IMAGE_PACKAGES_REGEXP = $(THE_PACKAGES_REGEXP) \ IMAGE_PACKAGES_REGEXP = $(THE_PACKAGES_REGEXP) \
$(BASE_PACKAGES_REGEXP) $(BASE_PACKAGES_REGEXP)
ifdef EFI_BOOTLOADER ifneq (,$(EFI_BOOTLOADER))
VM_BOOTLOADER=$(EFI_BOOTLOADER) VM_BOOTLOADER=$(EFI_BOOTLOADER)
else else
VM_BOOTLOADER=$(BASE_BOOTLOADER) VM_BOOTLOADER=$(BASE_BOOTLOADER)
@ -30,7 +30,7 @@ VM_XZ_COMMAND ?= xz -T0 -f
RECOVERY_LINE ?= Press ENTER to start RECOVERY_LINE ?= Press ENTER to start
# tarball save # tarball save
ifdef VM_SAVE_TARBALL ifneq (,$(VM_SAVE_TARBALL))
ifeq (,$(filter-out img img.xz qcow2 qcow2c vdi vmdk vhd,$(IMAGE_TYPE))) ifeq (,$(filter-out img img.xz qcow2 qcow2c vdi vmdk vhd,$(IMAGE_TYPE)))
ifeq (,$(filter-out tar tar.gz tar.xz,$(VM_SAVE_TARBALL))) ifeq (,$(filter-out tar tar.gz tar.xz,$(VM_SAVE_TARBALL)))
SAVE_TARBALL := convert-image/$(VM_SAVE_TARBALL) SAVE_TARBALL := convert-image/$(VM_SAVE_TARBALL)
@ -69,7 +69,7 @@ prepare-tarball-qemu:
tar -rf "$(VM_TARBALL)" ./.host/qemu*) ||: tar -rf "$(VM_TARBALL)" ./.host/qemu*) ||:
convert-image/tar: convert-image/tar:
ifdef SAVE_TARBALL ifneq (,$(SAVE_TARBALL))
cp "$(VM_TARBALL)" "$(VM_OUT_TARBALL)" cp "$(VM_TARBALL)" "$(VM_OUT_TARBALL)"
else else
mv "$(VM_TARBALL)" "$(VM_OUT_TARBALL)" mv "$(VM_TARBALL)" "$(VM_OUT_TARBALL)"

View File

@ -30,7 +30,7 @@ ifeq (,$(filter-out x86_64 ,$(ARCH)))
endif endif
use/dev/builder/full: use/dev use/dev/builder/live use/dev/repo use/dev/builder/full: use/dev use/dev/builder/live use/dev/repo
ifdef BIGRAM ifneq (,$(BIGRAM))
@$(call set,KFLAVOURS,$(BIGRAM)) @$(call set,KFLAVOURS,$(BIGRAM))
endif endif
@$(call add,THE_LISTS,$(call tags,server extra)) @$(call add,THE_LISTS,$(call tags,server extra))

View File

@ -1,4 +1,4 @@
ifdef BUILDDIR ifneq (,$(BUILDDIR))
# in seconds # in seconds
DEFAULT_TIMEOUT = 60 DEFAULT_TIMEOUT = 60
@ -8,28 +8,28 @@ DEFAULT_TIMEOUT = 60
include $(BUILDDIR)/distcfg.mk include $(BUILDDIR)/distcfg.mk
ifndef BOOTLOADER ifeq (,$(BOOTLOADER))
$(error grub feature enabled but BOOTLOADER undefined) $(error grub feature enabled but BOOTLOADER undefined)
endif endif
STAGE1_INITRD_BOOTARGS := $(STAGE1_INITRD_TYPEARGS)=$(STAGE1_INITRD_BOOTMETHOD) STAGE1_INITRD_BOOTARGS := $(STAGE1_INITRD_TYPEARGS)=$(STAGE1_INITRD_BOOTMETHOD)
ifndef GRUB_DIRECT ifeq (,$(GRUB_DIRECT))
# SUBPROFILES are considered GRUB_CFG too # SUBPROFILES are considered GRUB_CFG too
# (note these can appear like stage2@live); # (note these can appear like stage2@live);
# 01defaults.cfg is included indefinitely # 01defaults.cfg is included indefinitely
GRUB_CFG := $(GRUB_CFG) $(SUBPROFILE_DIRS) defaults fwsetup_efi GRUB_CFG := $(GRUB_CFG) $(SUBPROFILE_DIRS) defaults fwsetup_efi
endif endif
ifdef GRUB_UI ifneq (,$(GRUB_UI))
GRUB_CFG := $(GRUB_CFG) gfxterm GRUB_CFG := $(GRUB_CFG) gfxterm
endif endif
ifdef LOCALE ifneq (,$(LOCALE))
GRUB_CFG := $(GRUB_CFG) lang GRUB_CFG := $(GRUB_CFG) lang
endif endif
ifdef KFLAVOURS ifneq (,$(KFLAVOURS))
ifneq ($(words $(KFLAVOURS)),1) ifneq ($(words $(KFLAVOURS)),1)
GRUB_CFG := $(GRUB_CFG) kernel GRUB_CFG := $(GRUB_CFG) kernel
endif endif

View File

@ -1,6 +1,6 @@
# set up initrd-bootchain config # set up initrd-bootchain config
ifdef BUILDDIR ifneq (,$(BUILDDIR))
include $(BUILDDIR)/distcfg.mk include $(BUILDDIR)/distcfg.mk

View File

@ -1,6 +1,6 @@
# stage2 mod: build install2 subprofile (installer "live" part) # stage2 mod: build install2 subprofile (installer "live" part)
ifndef INSTALLER ifeq (,$(INSTALLER))
$(error install2 feature enabled but INSTALLER undefined) $(error install2 feature enabled but INSTALLER undefined)
endif endif

View File

@ -1,18 +1,18 @@
# set up livecd browser redirection page # set up livecd browser redirection page
ifdef BUILDDIR ifneq (,$(BUILDDIR))
include $(BUILDDIR)/distcfg.mk include $(BUILDDIR)/distcfg.mk
ifndef HOMEPAGE ifeq (,$(HOMEPAGE))
HOMEPAGE = http://altlinux.org/ HOMEPAGE = http://altlinux.org/
endif endif
ifndef HOMENAME ifeq (,$(HOMENAME))
HOMENAME = ALT HOMENAME = ALT
endif endif
ifndef HOMEWAIT ifeq (,$(HOMEWAIT))
HOMEWAIT = 3 HOMEWAIT = 3
endif endif

View File

@ -1,4 +1,4 @@
ifdef BUILDDIR ifneq (,$(BUILDDIR))
include $(BUILDDIR)/distcfg.mk include $(BUILDDIR)/distcfg.mk

View File

@ -1,4 +1,4 @@
ifdef BUILDDIR ifneq (,$(BUILDDIR))
# in deciseconds # in deciseconds
DEFAULT_TIMEOUT = 600 DEFAULT_TIMEOUT = 600
@ -8,7 +8,7 @@ DEFAULT_TIMEOUT = 600
include $(BUILDDIR)/distcfg.mk include $(BUILDDIR)/distcfg.mk
ifndef BOOTLOADER ifeq (,$(BOOTLOADER))
$(error syslinux feature enabled but BOOTLOADER undefined) $(error syslinux feature enabled but BOOTLOADER undefined)
endif endif
@ -16,14 +16,14 @@ STAGE1_INITRD_BOOTARGS := $(STAGE1_INITRD_TYPEARGS)=$(STAGE1_INITRD_BOOTMETHOD)
# UI is backed by modules in modern syslinux # UI is backed by modules in modern syslinux
# (except for built-in text prompt) # (except for built-in text prompt)
ifdef SYSLINUX_UI ifneq (,$(SYSLINUX_UI))
SYSLINUX_MODULES := $(SYSLINUX_MODULES) $(SYSLINUX_UI) SYSLINUX_MODULES := $(SYSLINUX_MODULES) $(SYSLINUX_UI)
else else
$(warning no syslinux ui configured, default is now none) $(warning no syslinux ui configured, default is now none)
SYSLINUX_UI := none SYSLINUX_UI := none
endif endif
ifndef SYSLINUX_DIRECT ifeq (,$(SYSLINUX_DIRECT))
# SUBPROFILES are considered SYSLINUX_CFG too # SUBPROFILES are considered SYSLINUX_CFG too
# (note these can appear like stage2@live); # (note these can appear like stage2@live);
# 01defaults.cfg is included indefinitely # 01defaults.cfg is included indefinitely

View File

@ -36,7 +36,7 @@ IMAGEDIR := $(wildcard $(IMAGEDIR))
IMAGE_SORTDIR := $(wildcard $(SORTDIR)) IMAGE_SORTDIR := $(wildcard $(SORTDIR))
# use distro version in image name if defined # use distro version in image name if defined
ifdef DISTRO_VERSION ifneq (,$(DISTRO_VERSION))
IMAGE_VERSION := -$(DISTRO_VERSION) IMAGE_VERSION := -$(DISTRO_VERSION)
IMAGE_VER_LINK := $(IMAGE_NAME)$(IMAGE_VERSION)-latest-$(ARCH).$(IMAGE_TYPE) IMAGE_VER_LINK := $(IMAGE_NAME)$(IMAGE_VERSION)-latest-$(ARCH).$(IMAGE_TYPE)
endif endif

View File

@ -1,7 +1,7 @@
ifneq (clean,$(MAKECMDGOALS)) ifneq (clean,$(MAKECMDGOALS))
ifneq (distclean,$(MAKECMDGOALS)) ifneq (distclean,$(MAKECMDGOALS))
ifndef INCLUDED_FUNCTIONS_MK ifeq (,$(INCLUDED_FUNCTIONS_MK))
INCLUDED_FUNCTIONS_MK = 1 INCLUDED_FUNCTIONS_MK = 1
# globals # globals

View File

@ -1,4 +1,4 @@
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif

View File

@ -6,12 +6,12 @@ MAX_LINES = 200
MAX_ERRORS = 5 MAX_ERRORS = 5
GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (FAILURE|FATAL|ERROR|conflicts|Conflicts:|Depends:) .*)|(.* (Stop|failed|not found)\.)|(not allowed))$$ GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (FAILURE|FATAL|ERROR|conflicts|Conflicts:|Depends:) .*)|(.* (Stop|failed|not found)\.)|(not allowed))$$
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif
# try not to bog down the system, both CPU and I/O wise # try not to bog down the system, both CPU and I/O wise
ifdef NICE ifneq (,$(NICE))
START := nice $(shell ionice -c3 echo "ionice -c3" 2>/dev/null) START := nice $(shell ionice -c3 echo "ionice -c3" 2>/dev/null)
endif endif

View File

@ -1,4 +1,4 @@
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif

View File

@ -8,12 +8,12 @@ SYMLINK = build
# tmpfs-sparing extra rule: cleanup workdir after completing each stage # tmpfs-sparing extra rule: cleanup workdir after completing each stage
# (as packed results are saved this only lowers RAM pressure) # (as packed results are saved this only lowers RAM pressure)
# NB: it's useful enough to be enabled by default in DEBUG abscence # NB: it's useful enough to be enabled by default in DEBUG abscence
ifndef DEBUG ifeq (,$(DEBUG))
CLEAN ?= 1 CLEAN ?= 1
endif endif
ifdef CLEAN ifneq (,$(CLEAN))
export GLOBAL_CLEAN_WORKDIR = clean-current export GLOBAL_CLEAN_WORKDIR = clean-current
ifdef DEBUG ifneq (,$(DEBUG))
WARNING = (NB: DEBUG scope is limited when CLEAN is enabled) WARNING = (NB: DEBUG scope is limited when CLEAN is enabled)
endif endif
endif endif

View File

@ -1,6 +1,6 @@
# step 2: build up distribution's configuration # step 2: build up distribution's configuration
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif

View File

@ -2,7 +2,7 @@
# you can add plain $(LOG) to a rule recipe line to moderate it # you can add plain $(LOG) to a rule recipe line to moderate it
# (logfile is automatically truncated during profile/init) # (logfile is automatically truncated during profile/init)
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif
@ -17,7 +17,7 @@ endif
BUILDLOG ?= $(BUILDDIR)/$(BUILD_LOG) BUILDLOG ?= $(BUILDDIR)/$(BUILD_LOG)
# LOG holds a redirecting postprocessor # LOG holds a redirecting postprocessor
ifdef DEBUG ifneq (,$(DEBUG))
# 1) makefile target; 2) also passed to script hooks # 1) makefile target; 2) also passed to script hooks
GLOBAL_DEBUG := debug GLOBAL_DEBUG := debug
GLOBAL_VERBOSE ?= $(DEBUG) GLOBAL_VERBOSE ?= $(DEBUG)

View File

@ -1,4 +1,4 @@
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif
@ -6,7 +6,7 @@ ifneq (,$(filter-out $(DIRECT_TARGETS),$(MAKECMDGOALS)))
# this could have come from env; or could be symlinked; or is made anew # this could have come from env; or could be symlinked; or is made anew
# (the reuse rationale is avoiding extra tmpdir lookups) # (the reuse rationale is avoiding extra tmpdir lookups)
# NB: immediate assignment matters # NB: immediate assignment matters
ifndef BUILDDIR ifeq (,$(BUILDDIR))
BUILDLINK := $(realpath $(SYMLINK)) BUILDLINK := $(realpath $(SYMLINK))
BUILDDIR := $(shell \ BUILDDIR := $(shell \
if [ -s "$(SYMLINK)" -a "$(NUM_TARGETS)" = 1 ] && \ if [ -s "$(SYMLINK)" -a "$(NUM_TARGETS)" = 1 ] && \

View File

@ -1,6 +1,6 @@
# step 2: build up virtual environment's configuration # step 2: build up virtual environment's configuration
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif

View File

@ -1,6 +1,6 @@
# step 2: build up virtual machine's configuration # step 2: build up virtual machine's configuration
ifndef MKIMAGE_PROFILES ifeq (,$(MKIMAGE_PROFILES))
$(error this makefile is designed to be included in toplevel one) $(error this makefile is designed to be included in toplevel one)
endif endif

View File

@ -46,7 +46,7 @@ include conf.d/*.mk
include features.in/*/config.mk include features.in/*/config.mk
# ensure the outdir is created and globbable # ensure the outdir is created and globbable
ifdef IMAGEDIR ifneq (,$(IMAGEDIR))
$(shell mkdir -p $(IMAGEDIR)) $(shell mkdir -p $(IMAGEDIR))
IMAGEDIR := $(wildcard $(IMAGEDIR)) IMAGEDIR := $(wildcard $(IMAGEDIR))
endif endif

View File

@ -2,7 +2,7 @@
# referenced in distro configuration (and only those!) # referenced in distro configuration (and only those!)
# over to $(BUILDDIR) # over to $(BUILDDIR)
ifndef BUILDDIR ifeq (,$(BUILDDIR))
$(error BUILDDIR not defined) $(error BUILDDIR not defined)
endif endif

View File

@ -1,7 +1,7 @@
# step 3: copy package groups referenced in distro configuration # step 3: copy package groups referenced in distro configuration
# (and only those!) over to $(BUILDDIR) # (and only those!) over to $(BUILDDIR)
ifndef BUILDDIR ifeq (,$(BUILDDIR))
check all: check-parents check-echo check-pkglists; @: check all: check-parents check-echo check-pkglists; @:

View File

@ -1,7 +1,6 @@
# step 3: copy package lists referenced in distro configuration # step 3: copy package lists referenced in distro configuration
# (and only those!) over to $(BUILDDIR) # (and only those!) over to $(BUILDDIR)
ifeq (,$(BUILDDIR))
ifndef BUILDDIR
pkgdups: pkgdups:
@find -type f ! -name README ! -name Makefile \ @find -type f ! -name README ! -name Makefile \
| grep -v '~$$' \ | grep -v '~$$' \

View File

@ -1,7 +1,7 @@
# step 3: copy package profiles referenced in distro configuration # step 3: copy package profiles referenced in distro configuration
# (and only those!) over to $(BUILDDIR) # (and only those!) over to $(BUILDDIR)
ifndef BUILDDIR ifeq (,$(BUILDDIR))
$(error BUILDDIR not defined) $(error BUILDDIR not defined)
endif endif

View File

@ -1,6 +1,6 @@
# step 3: copy the needed subprofiles to $(BUILDDIR) # step 3: copy the needed subprofiles to $(BUILDDIR)
ifndef BUILDDIR ifeq (,$(BUILDDIR))
$(error BUILDDIR not defined) $(error BUILDDIR not defined)
endif endif

View File

@ -1,6 +1,6 @@
# step 4: build main subprofile (requisite + optional packages for media) # step 4: build main subprofile (requisite + optional packages for media)
ifndef GLOBAL_BUILDDIR ifeq (,$(GLOBAL_BUILDDIR))
$(error GLOBAL_BUILDDIR not defined) $(error GLOBAL_BUILDDIR not defined)
endif endif

View File

@ -1,6 +1,6 @@
# step 4: build stage1 subprofile (installer bootstrap) # step 4: build stage1 subprofile (installer bootstrap)
ifndef GLOBAL_BUILDDIR ifeq (,$(GLOBAL_BUILDDIR))
$(error GLOBAL_BUILDDIR not defined) $(error GLOBAL_BUILDDIR not defined)
endif endif
@ -8,7 +8,7 @@ include $(GLOBAL_BUILDDIR)/distcfg.mk
include $(GLOBAL_BUILDDIR)/functions.mk include $(GLOBAL_BUILDDIR)/functions.mk
include $(MKIMAGE_PREFIX)/config.mk include $(MKIMAGE_PREFIX)/config.mk
ifndef BOOTLOADER ifeq (,$(BOOTLOADER))
$(error BOOTLOADER not defined) $(error BOOTLOADER not defined)
endif endif
GLOBAL_BOOTLOADER := $(BOOTLOADER) GLOBAL_BOOTLOADER := $(BOOTLOADER)

View File

@ -3,7 +3,7 @@
# NB: stage2 is not standalone but rather a common base # NB: stage2 is not standalone but rather a common base
# for all livecd images (installer, live, rescue) # for all livecd images (installer, live, rescue)
ifndef GLOBAL_BUILDDIR ifeq (,$(GLOBAL_BUILDDIR))
$(error GLOBAL_BUILDDIR not defined) $(error GLOBAL_BUILDDIR not defined)
endif endif
@ -54,7 +54,7 @@ IMAGE_PACKAGES_REGEXP += $(call kpackages, \
-include $(sort $(wildcard lib/*.mk)) -include $(sort $(wildcard lib/*.mk))
# see also ./scripts.d/99-elf-stats # see also ./scripts.d/99-elf-stats
ifdef GLOBAL_SQUASHFS_SORT ifneq (,$(GLOBAL_SQUASHFS_SORT))
ifeq (tight,$(SQUASHFS)) ifeq (tight,$(SQUASHFS))
CHROOT_PACKAGES += file CHROOT_PACKAGES += file
pack-image: PACK_SQUASHFS_OPTS += -sort /.our/elf.lst pack-image: PACK_SQUASHFS_OPTS += -sort /.our/elf.lst