+# GIT-HEAD helper
+# The file ./src/shl_githead.c contains a constant "shl_git_head" which is
+# defined to the string returned by "git describe". We need to adjust this
+# string for every build and correctly rebuild any sources that depend on it.
+# Therefore, you should use this file rarely as it causes rebuilds on every
+# git-commit.
+#
+# We have a helper-script ./src/genversion.sh that takes as argument the source
+# file and creates it if necessary. It updates it only if the new git-describe
+# string is different to the old one. So the file is only modified on changes.
+# Hence, we can use it as normal dependency in this Makefile.
+# However, we need to run this script on _every_ "make" invocation before any
+# recipy is executed. To achieve this, we use $(shell ...) and assign it to a
+# "simply expanded" variable (:=) so the shell command is executed on
+# variable-declaration and not during expansion.
+#
+# Note that we must not clean ./src/shl_githead.c ever! If we would, a
+# distribution tarball might delete that file and have no way to recreate it.
+# We could delete it on something like "make maintainerclean", but then again,
+# it seems unnecessary so lets simply not clean it at all.
+#
+# If the helper-script is executed in a directory that is not a git-repository
+# (like a distribution tarball) and shl_githead.c exists, then it does nothing
+# as it expects shl_githead.c to be correctly written by "make dist".
+# However, if shl_githead.c does not exist, it will print a warning and write
+# an unknown random git-revision.
+# This guarantees, that shl_githead.c is always present and has the most correct
+# value that we can get under any conditions.
+#
+# The $(emptyvariable) expansion below is used for broken $(shell ...)
+# syntax-highlighting algorithms in many existing editors.
+#
+
+EXTRA_DIST += src/genversion.sh
+GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
+
+#
+# Binary File Compiler
+# This target gets as input a binary file *.bin and produces an ELF/etc. output
+# object file *.bin.o and the corresponding libtool file *.bin.lo.
+# Note that we fake the libtool object files as there is no way to make libtool
+# create it. The comments in the .lo file are mandatory so don't remove them!
+#
+
+CLEANFILES += src/*.bin.lo src/*.bin.o
+
+src/%.bin.lo: src/%.bin
+ $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
+ $(AM_V_at)$(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents "src/$*.bin.o"
+ $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
+ $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
+ $(AM_V_at)echo "#" >>"$@"
+ $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
+ $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
+ $(AM_V_at)echo >>"$@"
+ $(AM_V_at)echo "# Name of the PIC object." >>"$@"
+ $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
+ $(AM_V_at)echo >>"$@"
+ $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
+ $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
+ $(AM_V_at)echo >>"$@"
+
+#
+# Shader Converter
+# We use a few built-in shader files. To reduce memory-consumption, this helper
+# removes useless lines from the shaders before they are compiled into an object
+# file.
+#
+# Following regexp are used to remove characters/lines:
+# ^/*.*$ Start of multi-line comment
+# ^ *.*$ Multi-line comment body
+# ^[ \t]* Indentation whitespace
+# [\r\n] Newlines
+#
+
+CLEANFILES += src/*.vert.bin src/*.frag.bin
+SHADER_SED = -e 's/^\/\*.*$$//' -e 's/^ \*.*$$//' -e 's/^[ \t]*//'
+SHADER_TR = -d "\r\n"
+
+src/%.vert.bin: $(top_srcdir)/src/%.vert
+ $(AM_V_at)$(SED) $(SHADER_SED) "$<" | tr $(SHADER_TR) >"$@"
+
+src/%.frag.bin: $(top_srcdir)/src/%.frag
+ $(AM_V_at)$(SED) $(SHADER_SED) "$<" | tr $(SHADER_TR) >"$@"
+
+#
+# XKB Fallback Converter
+# We use a static built-in XKB fallback keymap. To avoid huge memory consumption
+# we remove useless lines/characters first.
+# We also append an ASCII 0 character so it can be used as regular C-string.
+#
+# Following regexp are used to remove characters/lines:
+# *= * Whitespace around assignments
+# *, * Whitespace around commatas
+# *[][{}()] * Whitespace around braces
+# ^[ \t]* Indentation whitespace
+# [\r\n] Newlines
+#
+
+CLEANFILES += src/*.xkb.bin
+XKB_SED = -e 's/^[ \t]*//' -e 's/ *\([,=]\) */\1/g' -e 's/ *\([][{}()]\) */\1/g'
+XKB_TR = -d "\r\n"
+
+src/%.xkb.bin: $(top_srcdir)/src/%.xkb
+ $(AM_V_at)$(SED) $(XKB_SED) "$<" | tr $(XKB_TR) >"$@"
+ $(AM_V_at)echo -ne "\x00" >>"$@"
+
+#