From 38489e6179a357626d9233f9b1204bf6bc93341a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Samuli=20Sepp=C3=A4nen?= <sam...@openvpn.net>
Date: Fri, 26 Nov 2010 16:32:47 +0200
Subject: [PATCH] Added fake configure.h generation to Python-based build system
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Building OpenVPN using the Python-based build system fails because of missing
configure.h file. This patch adds code to win/wb.py and win/config.py to
automatically generate a fake configure.h file which contains build parameters
parsed from win/settings.in in CONFIGURE_DEFINES, as well as a more proper value
for the CONFIGURE_CALL variable.

Signed-off-by: Samuli Seppänen <sam...@openvpn.net>
---
 win/config.py |    3 ++-
 win/wb.py     |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/win/config.py b/win/config.py
index cf38cac..c9956cc 100644
--- a/win/config.py
+++ b/win/config.py
@@ -1,6 +1,7 @@
-from wb import preprocess, autogen, mod_fn, home_fn, build_autodefs, make_headers_objs, dict_def
+from wb import preprocess, autogen, mod_fn, home_fn, build_configure_h, build_autodefs, make_headers_objs, dict_def
 
 def main(config):
+    build_configure_h(config, mod_fn(home_fn('configure.h')), head_comment='/* %s */\n\n' % autogen)
     build_autodefs(config, mod_fn('autodefs.h.in'), home_fn('autodefs.h'))
     ho = make_headers_objs(home_fn('Makefile.am'))
 
diff --git a/win/wb.py b/win/wb.py
index f7f4f4a..a368712 100644
--- a/win/wb.py
+++ b/win/wb.py
@@ -70,6 +70,26 @@ def build_autodefs(kv, autodefs_in, autodefs_out):
                quote_end='@',
                head_comment='/* %s */\n\n' % autogen)
 
+'''Generate a fake configure.h dynamically'''
+def build_configure_h(kv, configure_h_out, head_comment):
+    fout = open(configure_h_out, 'w')
+    configure_defines='#define CONFIGURE_DEFINES \"'
+    configure_call='#define CONFIGURE_CALL \" config_all.py \"'
+
+    fout.write(head_comment)
+
+    dict = get_config()
+
+    for key, value in dict.iteritems():
+        configure_defines = configure_defines + " " + key + "=" + value + ","
+
+    configure_defines = configure_defines + "\"" + "\n"
+
+    fout.write(configure_defines)
+    fout.write(configure_call)
+    fout.close()
+
+
 def preprocess(kv, in_fn, out_fn, quote_begin=None, quote_end=None, if_prefix=None, head_comment=None):
     def repfn(m):
         var, = m.groups()
-- 
1.6.3.3

Reply via email to