defs.mk: Beautify gcc and ld version parsing

And be compatible with CentOS while at it

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2018-12-13 10:42:56 +00:00
commit 378e46f8b6

View file

@ -279,15 +279,18 @@ SUBDIRS_TO_ITERATE = $(filter-out $(IGNORE_SUBDIRS),$(SUBDIRS))
# compiler and linker # compiler and linker
# gcc # gcc
GCC_VERSION := $(shell gcc -v 2>&1 | grep "gcc version" | awk '{ print $$3;}') GCC_VERSION := $(shell $(GCC) -v 2>&1 | $(SED) '/gcc.version/I !d; s/.*version *//I; s/ \+.*//')
GCC_MAJOR := $(shell gcc -v 2>&1 | grep "gcc version" | awk '{ split($$3,a,"."); print a[1];}') GCC_VERSION_NUMBERS := $(subst ., ,$(GCC_VERSION))
GCC_MINOR := $(shell gcc -v 2>&1 | grep "gcc version" | awk '{ split($$3,a,"."); print a[2];}') GCC_MAJOR := $(word 1,$(GCC_VERSION_NUMBERS))
GCC_REV := $(shell gcc -v 2>&1 | grep "gcc version" | awk '{ split($$3,a,"."); print a[3];}') GCC_MINOR := $(word 2,$(GCC_VERSION_NUMBERS))
GCC_REV := $(word 3,$(GCC_VERSION_NUMBERS))
LD_VERSION := $(shell ld -V | $(SED) '/GNU ld/ !d; s/(.*)//; s/[^0-9.-]*//') LD_VERSION := $(shell ld -V | $(SED) '/GNU ld/ !d; s/(.*)//; s/[^0-9.-]*//')
LD_MAJOR := $(shell echo $(LD_VERSION) | cut -d. -f1) LD_VERSION_NUMBERS := $(subst ., ,$(LD_VERSION))
LD_MINOR := $(shell echo $(LD_VERSION) | cut -d. -f2) LD_MAJOR := $(word 1,$(LD_VERSION_NUMBERS))
LD_REV := $(shell echo $(LD_VERSION) | cut -d. -f3) LD_MINOR := $(word 2,$(LD_VERSION_NUMBERS))
LD_REV := $(word 3,$(LD_VERSION_NUMBERS))
UPDATE_REPO_SH := /opt/packager-server/bin/packager-server schedule-rebuild UPDATE_REPO_SH := /opt/packager-server/bin/packager-server schedule-rebuild
# clang # clang