common/Makefile.inc: Factor out generation TLAs
The Three Letter Acronyms that correspond to generation names appear
four times inside complex sed-fu. As they are the same, factor them out.
Sanity-checked by building gfxtest for Haswell, whose executable remains
identical regardless of whether this commit is applied or not.
Change-Id: I63cb24d7334359d39aca4682632c3b9b6b698d43
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/42365
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: Nico Huber <nico.h@gmx.de>
diff --git a/common/Makefile.inc b/common/Makefile.inc
index e01bdc2..f2a2fbb 100644
--- a/common/Makefile.inc
+++ b/common/Makefile.inc
@@ -57,6 +57,8 @@
CONFIG_GFX_GMA_ANALOG_I2C_PORT := $(call strip_quotes,$(CONFIG_GFX_GMA_ANALOG_I2C_PORT))
CONFIG_GFX_GMA_IGNORE_PRESENCE_STRAPS := $(if $(filter y,$(CONFIG_GFX_GMA_IGNORE_PRESENCE_STRAPS)),True,False)
+_GEN_TLA_SUBSTITUTIONS := \(g45\|ilk\|hsw\|skl\)
+
_GEN_NONCONST := $(strip \
$(if $(filter G45,$(CONFIG_GFX_GMA_GENERATION)),g45, \
$(if $(filter Ironlake,$(CONFIG_GFX_GMA_GENERATION)),ilk, \
@@ -86,9 +88,9 @@
sed $(GFX_GMA_COMMON_SUBSTITUTIONS) \
-e'/constant Gen_CPU\(_Var\)\?/d' \
-e's/<genbool>/constant Boolean/' \
- -e's/<\(\(g45\|ilk\|hsw\|skl\)\(...\)\?\)bool>/<\1var> Boolean/' \
+ -e's/<\($(_GEN_TLA_SUBSTITUTIONS)\(...\)\?\)bool>/<\1var> Boolean/' \
$(if $(_GEN_NONCONST),-e's/<\(...\)\?$(_GEN_NONCONST)\(...\)\?var>/<cpufunc>/') \
- -e's/<\(g45\|ilk\|hsw\|skl\)\(...\)\?var>/$(_GEN_CONST_TARGET)/' \
+ -e's/<$(_GEN_TLA_SUBSTITUTIONS)\(...\)\?var>/$(_GEN_CONST_TARGET)/' \
-e's/\(.*: *<cpufunc>.*:=\) *\(.*\);/\1\n (\2);/' \
-e's/\([^ ]\+\) *: *<cpufunc> \+\([^ ]*\) *:=/function \1 return \2 is/' \
-e's/<cpunull>//' \
@@ -101,8 +103,8 @@
-e's/<<CPU_VARIANT>>/$(CONFIG_GFX_GMA_CPU_VARIANT)/' \
-e":s$$(printf '\n ')/,$$/{N;s/,\n.*Dyn_CPU\(_Var\)\?[^,)]*//;ts$$(printf '\n ')P;D;}" \
-e'/Dyn_CPU\(_Var\)\?/d' \
- -e's/<\(gen\|\(g45\|ilk\|hsw\|skl\)\(...\)\?\)bool>/constant Boolean/' \
- -e's/<\(\(g45\|ilk\|hsw\|skl\)\(...\)\?\)var>/constant/' \
+ -e's/<\(gen\|$(_GEN_TLA_SUBSTITUTIONS)\(...\)\?\)bool>/constant Boolean/' \
+ -e's/<\($(_GEN_TLA_SUBSTITUTIONS)\(...\)\?\)var>/constant/' \
-e's/<cpunull>/ is null/' \
$< >$@
endif