From: Alon Bar-Lev Date: Wed, 29 Feb 2012 20:12:14 +0000 (+0200) Subject: build: split out compat X-Git-Tag: v2.3_alpha2~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc81e743989640cc681a40e69455cc9fc736ab9c;p=thirdparty%2Fopenvpn.git build: split out compat compat should not use any of the main project headers or conventions, it should be a standalone library that provides missing library functions. Signed-off-by: Alon Bar-Lev Acked-by: David Sommerseth Signed-off-by: David Sommerseth --- diff --git a/configure.ac b/configure.ac index f5663ebcf..ff3df28aa 100644 --- a/configure.ac +++ b/configure.ac @@ -365,7 +365,7 @@ AC_CHECK_HEADERS([ \ AC_CHECK_HEADERS([ \ sys/time.h sys/un.h sys/ioctl.h sys/stat.h \ sys/mman.h sys/file.h \ - unistd.h signal.h \ + unistd.h signal.h libgen.h \ syslog.h pwd.h grp.h \ net/if_tun.h net/tun/if_tun.h stropts.h \ sys/sockio.h \ @@ -914,6 +914,7 @@ AC_CONFIG_FILES([ distro/rpm/openvpn.spec include/Makefile src/Makefile + src/compat/Makefile src/openvpn/Makefile src/openvpnserv/Makefile tests/Makefile diff --git a/openvpn.sln b/openvpn.sln index cbd209368..be35d166e 100644 --- a/openvpn.sln +++ b/openvpn.sln @@ -8,6 +8,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvpnserv", "src\openvpns EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvpn", "src\openvpn\openvpn.vcproj", "{29DF226E-4D4E-440F-ADAF-5829CFD4CA94}" ProjectSection(ProjectDependencies) = postProject + {4B2E2719-E661-45D7-9203-F6F456B22F19} = {4B2E2719-E661-45D7-9203-F6F456B22F19} {8598C2C8-34C4-47A1-99B0-7C295A890615} = {8598C2C8-34C4-47A1-99B0-7C295A890615} EndProjectSection EndProject @@ -20,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{1AA03DE8-3 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msvc-generate", "build\msvc\msvc-generate\msvc-generate.vcproj", "{8598C2C8-34C4-47A1-99B0-7C295A890615}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compat", "src\compat\compat.vcproj", "{4B2E2719-E661-45D7-9203-F6F456B22F19}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -38,6 +41,10 @@ Global {8598C2C8-34C4-47A1-99B0-7C295A890615}.Debug|Win32.Build.0 = Debug|Win32 {8598C2C8-34C4-47A1-99B0-7C295A890615}.Release|Win32.ActiveCfg = Release|Win32 {8598C2C8-34C4-47A1-99B0-7C295A890615}.Release|Win32.Build.0 = Release|Win32 + {4B2E2719-E661-45D7-9203-F6F456B22F19}.Debug|Win32.ActiveCfg = Debug|Win32 + {4B2E2719-E661-45D7-9203-F6F456B22F19}.Debug|Win32.Build.0 = Debug|Win32 + {4B2E2719-E661-45D7-9203-F6F456B22F19}.Release|Win32.ActiveCfg = Release|Win32 + {4B2E2719-E661-45D7-9203-F6F456B22F19}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Makefile.am b/src/Makefile.am index f2481c2ff..b89497703 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,4 +15,4 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ plugins -SUBDIRS = openvpn openvpnserv +SUBDIRS = compat openvpn openvpnserv diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am new file mode 100644 index 000000000..e33e5e7a1 --- /dev/null +++ b/src/compat/Makefile.am @@ -0,0 +1,23 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2002-2010 OpenVPN Technologies, Inc. +# Copyright (C) 2006-2012 Alon Bar-Lev +# + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +EXTRA_DIST = \ + compat.vcproj + +noinst_LTLIBRARIES = libcompat.la + +libcompat_la_SOURCES = \ + compat.h \ + compat-dirname.c \ + compat-basename.c diff --git a/src/compat/compat-basename.c b/src/compat/compat-basename.c new file mode 100644 index 000000000..a0576919f --- /dev/null +++ b/src/compat/compat-basename.c @@ -0,0 +1,50 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2011 - David Sommerseth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING included with this + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif + +#ifndef HAVE_BASENAME + +#include "compat.h" +#include + +/* Modified version based on glibc-2.14.1 by Roland McGrath + * This version is extended to handle both / and \ in path names + */ +char * +basename (char *filename) +{ + char *p = strrchr (filename, '/'); + if (!p) { + /* If NULL, check for \ instead ... might be Windows a path */ + p = strrchr (filename, '\\'); + } + return p ? p + 1 : (char *) filename; +} + +#endif /* HAVE_BASENAME */ diff --git a/src/openvpn/compat.c b/src/compat/compat-dirname.c similarity index 88% rename from src/openvpn/compat.c rename to src/compat/compat-dirname.c index f2fa265cb..887859508 100644 --- a/src/openvpn/compat.c +++ b/src/compat/compat-dirname.c @@ -28,12 +28,12 @@ #include "config-msvc.h" #endif -#include "syshead.h" + +#ifndef HAVE_DIRNAME + #include "compat.h" #include - -#ifndef HAVE_DIRNAME /* Unoptimised version of glibc memrchr(). * This is considered fast enough, as only this compat * version of dirname() depends on it. @@ -115,21 +115,5 @@ dirname (char *path) return path; } -#endif /* HAVE_DIRNAME */ - -#ifndef HAVE_BASENAME -/* Modified version based on glibc-2.14.1 by Roland McGrath - * This version is extended to handle both / and \ in path names - */ -char * -basename (char *filename) -{ - char *p = strrchr (filename, '/'); - if (!p) { - /* If NULL, check for \ instead ... might be Windows a path */ - p = strrchr (filename, '\\'); - } - return p ? p + 1 : (char *) filename; -} -#endif /* HAVE_BASENAME */ +#endif /* HAVE_DIRNAME */ diff --git a/src/openvpn/compat.h b/src/compat/compat.h similarity index 94% rename from src/openvpn/compat.h rename to src/compat/compat.h index 7af9fe274..57754da57 100644 --- a/src/openvpn/compat.h +++ b/src/compat/compat.h @@ -25,10 +25,6 @@ #ifndef COMPAT_H #define COMPAT_H -#if defined(HAVE_BASENAME) || defined(HAVE_DIRNAME) -#include -#endif - #ifndef HAVE_DIRNAME char * dirname(char *str); #endif /* HAVE_DIRNAME */ diff --git a/src/compat/compat.vcproj b/src/compat/compat.vcproj new file mode 100644 index 000000000..1ece7492f --- /dev/null +++ b/src/compat/compat.vcproj @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am index 3d8c0a9c5..e1703808c 100644 --- a/src/openvpn/Makefile.am +++ b/src/openvpn/Makefile.am @@ -17,7 +17,9 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ openvpn.vcproj -INCLUDES = -I$(top_srcdir)/include +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/compat AM_CFLAGS = \ $(OPTIONAL_CRYPTO_CFLAGS) \ @@ -33,7 +35,6 @@ openvpn_SOURCES = \ circ_list.h \ clinat.c clinat.h \ common.h \ - compat.h compat.c \ crypto.c crypto.h crypto_backend.h \ crypto_openssl.c crypto_openssl.h \ crypto_polarssl.c crypto_polarssl.h \ @@ -104,6 +105,7 @@ openvpn_SOURCES = \ win32.h win32.c \ cryptoapi.h cryptoapi.c openvpn_LDADD = \ + $(top_builddir)/src/compat/libcompat.la \ $(SOCKETS_LIBS) \ $(OPTIONAL_LZO_LIBS) \ $(OPTIONAL_PKCS11_HELPER_LIBS) \ diff --git a/src/openvpn/openvpn.vcproj b/src/openvpn/openvpn.vcproj index 8a3f4b0d7..45c0a7768 100644 --- a/src/openvpn/openvpn.vcproj +++ b/src/openvpn/openvpn.vcproj @@ -41,7 +41,7 @@ - - @@ -460,10 +456,6 @@ RelativePath=".\common.h" > - - diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index f9636f7d3..e8da88ccf 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -181,6 +181,10 @@ #include #endif +#if defined(HAVE_LIBGEN_H) +#include +#endif + #ifdef TARGET_SOLARIS #ifdef HAVE_STRINGS_H #include