* builds/toplevel.mk: Simplify version extraction.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/builds/toplevel.mk b/builds/toplevel.mk
index 7530be7..8d5063e 100644
--- a/builds/toplevel.mk
+++ b/builds/toplevel.mk
@@ -198,29 +198,22 @@ modules:
include $(TOP_DIR)/builds/modules.mk
-# get FreeType version string, using a
-# poor man's `sed' emulation with make's built-in string functions
+# get FreeType version string using built-in string functions
#
hash := \#
work := $(strip $(shell $(CAT) \
$(subst /,$(SEP),$(TOP_DIR)/include/freetype/freetype.h)))
-work := $(subst |,x,$(work))
-work := $(subst $(space),|,$(work))
-work := $(subst $(hash)define|FREETYPE_MAJOR|,$(space),$(work))
-work := $(word 2,$(work))
-major := $(subst |,$(space),$(work))
-major := $(firstword $(major))
-
-work := $(subst $(hash)define|FREETYPE_MINOR|,$(space),$(work))
-work := $(word 2,$(work))
-minor := $(subst |,$(space),$(work))
-minor := $(firstword $(minor))
-
-work := $(subst $(hash)define|FREETYPE_PATCH|,$(space),$(work))
-work := $(word 2,$(work))
-patch := $(subst |,$(space),$(work))
-patch := $(firstword $(patch))
+
+work := $(subst $(hash)define$(space)FREETYPE_MAJOR$(space),MAjOR=,$(work))
+work := $(subst $(hash)define$(space)FREETYPE_MINOR$(space),MInOR=,$(work))
+work := $(subst $(hash)define$(space)FREETYPE_PATCH$(space),PAtCH=,$(work))
+
+major := $(subst MAjOR=,,$(filter MAjOR=%,$(work)))
+minor := $(subst MInOR=,,$(filter MInOR=%,$(work)))
+patch := $(subst PAtCH=,,$(filter PAtCH=%,$(work)))
+
+work :=
# ifneq ($(findstring x0x,x$(patch)x),)
# version := $(major).$(minor)