This looks like a hack (and it is), so here's the underlying logic:

- service-win32/service.h (or .c?) refers to non-existing header files
when using the Python-based build system, but changing the header file
name would  break(?) the older automake-based Windows buildsystem. By
making a copy of the file it can be safely modified on the fly.

- nmake seems to get confused with working directories when some source
files are located in subdirectories  (here ./service-win32)

If somebody knows a cleaner solution to this issue, I'm all ears :).

-- 
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

From edb8445bdd472d4aad359b78c30f35154bf4b554 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Samuli=20Sepp=C3=A4nen?= <sam...@openvpn.net>
Date: Mon, 3 Jan 2011 16:55:04 +0200
Subject: [PATCH 6/6] Added copying of files from service-win32 directory to build root directory.

Building of openvpnserv.exe using nmake is least painful if files in
service-win32 (service.h, service.c and openvpnserv.c) are available in build
root directory; added code to win/build.py and win/wb.py to take care of this
before build is started. Also modified the clean target in win/msvc.mak.in to
remove those files.
---
 win/config.py   |    4 +++-
 win/msvc.mak.in |    7 ++++++-
 win/wb.py       |    7 ++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/win/config.py b/win/config.py
index c9956cc..95472e3 100644
--- a/win/config.py
+++ b/win/config.py
@@ -1,4 +1,4 @@
-from wb import preprocess, autogen, mod_fn, home_fn, build_configure_h, 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, copy_service_win32_files
 
 def main(config):
     build_configure_h(config, mod_fn(home_fn('configure.h')), head_comment='/* %s */\n\n' % autogen)
@@ -13,6 +13,8 @@ def main(config):
                if_prefix='!',
                head_comment='# %s\n\n' % autogen)
 
+    copy_service_win32_files()
+
 # if we are run directly, and not loaded as a module
 if __name__ == "__main__":
     from wb import config
diff --git a/win/msvc.mak.in b/win/msvc.mak.in
index ae51538..3fc0b94 100644
--- a/win/msvc.mak.in
+++ b/win/msvc.mak.in
@@ -47,6 +47,11 @@ LINK32_FLAGS=/nologo /subsystem:console /incremental:no
 # HEADERS and OBJS definitions, automatically generated from ../Makefile.am
 @HEADERS_OBJS@
 
+SERVICE32FILES = \
+	service.c \
+	service.h \
+	openvpnserv.c
+
 SERVOBJS = \
 	openvpnserv.obj \
 	service.obj
@@ -63,7 +68,7 @@ openvpnserv : openvpn $(SERVOBJS)
 
 
 clean :
-	del /Q $(OBJS) $(SERVOBJS) $(SERVEXE) $(EXE) *.idb *.pdb
+	del /Q $(OBJS) $(SERVICE32FILES) $(SERVOBJS) $(SERVEXE) $(EXE) *.idb *.pdb
 
 .c.obj::
    $(CPP) @<<
diff --git a/win/wb.py b/win/wb.py
index f673bba..3bd2544 100644
--- a/win/wb.py
+++ b/win/wb.py
@@ -96,7 +96,6 @@ def parse_config_win32_h(kv, config_win32_h):
     f.close()
 
 
-
 def dict_def(dict, newdefs):
     ret = dict.copy()
     ret.update(newdefs)
@@ -214,6 +213,12 @@ def make_headers_objs(makefile_am):
     ret += output_mak_list('OBJS', c, 'obj')
     return ret
 
+'''Copy files from ../service-win32 to .. to avoid nmake issues'''
+def copy_service_win32_files():
+    cp (home_fn("service-win32/service.h"), home_fn("."))
+    cp (home_fn("service-win32/service.c"), home_fn("."))
+    cp (home_fn("service-win32/openvpnserv.c"), home_fn("."))
+
 def choose_arch(arch_name):
     if arch_name == 'x64':
         return (True,)
-- 
1.6.3.3

Reply via email to