summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-04-13 09:04:40 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2021-04-13 09:04:40 +0200
commitb1355998c859cf4a1531b1035ca0ccb4a9e97409 (patch)
tree066c2860c5df095645beb9af057ddeb617277e80 /script
parent168ea4b5641eb08ef24c70e94e332aaabf7e2e81 (diff)
prepare for switch to config.h instead of CFLAGS defines
Diffstat (limited to 'script')
-rw-r--r--script/conf2h.awk35
1 files changed, 35 insertions, 0 deletions
diff --git a/script/conf2h.awk b/script/conf2h.awk
new file mode 100644
index 0000000..818beea
--- /dev/null
+++ b/script/conf2h.awk
@@ -0,0 +1,35 @@
+#! /usr/bin/gawk -f
+#
+# Copyright 2021 AG Eingebettete Softwaresysteme, Universität Osnabrück
+#
+# SPDX-License-Identicier: CC0-1.0
+
+BEGIN {
+ print "// config.h generated from " ARGV[1] "\n" \
+ "#ifndef CONFIG_H\n" \
+ "#define CONFIG_H"
+}
+
+/^CONFIG_.*?_INSTANCES=/ { next }
+
+/^#/ { sub(/^#/,"//") }
+
+/^CONFIG_.*?=/ {
+ if (/=n$/) {
+ sub(/^/,"// ");
+ } else {
+ sub(/^/,"#define ")
+ if (/=y$/) {
+ sub(/=.*$/,"")
+ } else if (/=".*"$/) {
+ sub(/="/, " ")
+ sub(/"$/, "")
+ } else {
+ sub(/=/," ")
+ }
+ }
+}
+
+{ print }
+
+END { print "#endif" }