log.mk 1.35 KB
Newer Older
1 2 3 4
# simple logging switch inspired by netch@'s advice:
# you can add plain $(LOG) to a rule recipe line to moderate it
# (logfile is automatically truncated during profile/init)

5
ifeq (,$(MKIMAGE_PROFILES))
6 7 8
$(error this makefile is designed to be included in toplevel one)
endif

9 10 11 12
# 1.3.22 fixes http://bugzilla.altlinux.org/26217
HSH_VER_OPTIMAL = 1.3.22
HSH_VERSION := $(shell hsh -V | sed -n 's/^.* version \([0-9.]\+\).*$$/\1/p')

13
ifeq (-,$(shell rpmvercmp $(HSH_VERSION) $(HSH_VER_OPTIMAL) | tr -d '[0-9]'))
14 15 16
$(info warning: hasher-$(HSH_VERSION) is suboptimal, consider upgrading)
endif

17
BUILDLOG ?= $(BUILDDIR)/$(BUILD_LOG)
18

19
# LOG holds a redirecting postprocessor
20
ifneq (,$(DEBUG))
21 22
# 1) makefile target; 2) also passed to script hooks
GLOBAL_DEBUG := debug
23 24 25 26
GLOBAL_VERBOSE ?= $(DEBUG)
ifeq (2,$(DEBUG))
SHELL += -x
endif
27 28 29 30
ifeq (1,$(STDOUT))
LOG = 2>&1 | tee -a $(BUILDLOG)
LOG_STDERR = $(LOG)
else
31
LOG = >>$(BUILDLOG) 2>&1
32
LOG_STDERR = 2> >(tee -a $(BUILDLOG) >&2) 1>>$(BUILDLOG)
33
endif
34 35 36
else
MAKE += -s
LOG = 2>>$(BUILDLOG) >/dev/null
37
LOG_STDERR = 2> >(tee -a $(BUILDLOG) >&2) 1>/dev/null
38 39
endif

40 41 42 43
ifeq (,$(filter-out $(DIRECT_TARGETS),$(MAKECMDGOALS)))
LOG = >/dev/null 2>&1
endif

44
# in build.mk, naive TIME gets expanded a bit too early (no need to export btw)
45
DATE = $(shell date +%Y%m%d)
46
TIME = `date +%H:%M:%S`
47

48
export BUILDLOG DATE GLOBAL_DEBUG GLOBAL_VERBOSE LOG MAKE SHELL