Add script to add config.h (AC_CONFIG_HEADERS)
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 25 May 2011 13:11:08 +0000 (15:11 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 25 May 2011 13:11:08 +0000 (15:11 +0200)
fixup-headers/add-config-h.sh [new file with mode: 0755]
fixup-headers/add-file-config.tcl [new file with mode: 0755]

diff --git a/fixup-headers/add-config-h.sh b/fixup-headers/add-config-h.sh
new file mode 100755 (executable)
index 0000000..b672b59
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+H=`dirname $0`/add-file-config.tcl
+for f in `find . \( -name '*.c' -or -name '*.cpp' \) -print`; do
+       echo $f
+       $H < $f >${f}_new
+       mv -f ${f}_new $f
+done
+       
diff --git a/fixup-headers/add-file-config.tcl b/fixup-headers/add-file-config.tcl
new file mode 100755 (executable)
index 0000000..2ad96c6
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/tclsh
+set have_config 0
+while {[gets stdin line] >= 0} {
+       set must_make_config 0
+       if {[string match "\#if HAVE_CONFIG_H*" $line]} {
+               set have_config 1
+       } elseif {[string match "\#*" $line]} {
+               if {!$have_config} {
+                       puts "\#if HAVE_CONFIG_H"
+                       puts "\#include <config.h>"
+                       puts "\#endif"
+               }
+               set have_config 1
+       }
+       puts $line
+}