]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts: embed/minify scripts in C code
authorMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 18 May 2015 19:02:58 +0000 (21:02 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 18 May 2015 19:02:58 +0000 (21:02 +0200)
config.mk
scripts/embed.sh [new file with mode: 0755]

index e8c4f46f4c51a47909fe6b3fcb9d26a6b951f962..17ec10a4f7ee68184c0900effad0ca2a6f4d9b06 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -16,6 +16,6 @@ CFLAGS        += -std=c99 -D_GNU_SOURCE -Wall -fPIC -I$(abspath .) -I$(abspath lib/gene
 CFLAGS  += -DPACKAGE_VERSION="\"$(MAJOR).$(MINOR)\"" -DPREFIX="\"$(PREFIX)\"" -DMODULEDIR="\"$(MODULEDIR)\""
 RM     := rm -f
 LN      := ln -s
-XXD     ?= hexdump -v -e '/1 "0x%02X, " " "'
+XXD     := ./scripts/embed.sh
 INSTALL := install
 PYTHON  := python
diff --git a/scripts/embed.sh b/scripts/embed.sh
new file mode 100755 (executable)
index 0000000..1f57b87
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+alias strip="sed -e 's/^[    ]*//g; s/[ ][ ]*/ /g; /^--/d; /^$/d'"
+if hash xxd 2>/dev/null; then
+       xxd -i - < $1 | strip
+else
+       hexdump -v -e '/1 "0x%02X, " " "' < $1 | strip
+fi