summaryrefslogtreecommitdiff
path: root/script/conf2h.awk
blob: 818beeabb46307318f3816bd6533dfe285f35f66 (plain)
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
#! /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" }