Browse code

Fix autotools cross-compiling support

This is a modified version of a patch sent to the sf.net
patch tracker:

<http://sourceforge.net/tracker/?func=detail&aid=2491190&group_id=48978&atid=454721>

After having disucssed this patch on IRC (#openvpn-discussions)
March 4, 2010, it was decided to accept this patch when not modifying
TARGET_* defines through out the code. Further, in a mail comment
Alon Bar-Lev had some other comments of what would be needed to be done.

Mail reference:
<http://thread.gmane.org/gmane.network.openvpn.devel/3176>

This patch has been tested by bootstrapping the code on a RHEL4.6 box.
with the following autotools packages installed:
autoconf-2.59-5
automake-1.9.2-3
libtool-1.5.6-4.EL4.2

It builds cleanly and 'make check' passes.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: James Yonan <james@openvpn.net>
Acked-by: Alon Bar-Lev <alon.barlev@gmail.com>

David Sommerseth authored on 2010/03/12 01:28:41
Showing 2 changed files
... ...
@@ -224,8 +224,8 @@ acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -m
224 224
 # pthread: Linux, etcetera
225 225
 # --thread-safe: KAI C++
226 226
 
227
-case "$target" in
228
-        *solaris*)
227
+case "$host" in
228
+        *-*-solaris*)
229 229
 
230 230
         # On Solaris (at least, for some versions), libc contains stubbed
231 231
         # (non-functional) versions of the pthreads routines, so link-based
... ...
@@ -321,9 +321,9 @@ if test "x$acx_pthread_ok" = xyes; then
321 321
 
322 322
         AC_MSG_CHECKING([if more special flags are required for pthreads])
323 323
         flag=no
324
-        case "$target" in
325
-                *-aix* | *-freebsd*)               flag="-D_THREAD_SAFE";;
326
-                *solaris* | alpha*-osf* | *linux*) flag="-D_REENTRANT";;
324
+        case "$host" in
325
+                *-*-aix* | *-freebsd*)               flag="-D_THREAD_SAFE";;
326
+                *-*-solaris* | alpha*-osf* | *linux*) flag="-D_REENTRANT";;
327 327
         esac
328 328
         AC_MSG_RESULT(${flag})
329 329
         if test "x$flag" != xno; then
... ...
@@ -32,7 +32,6 @@ AC_CONFIG_SRCDIR(syshead.h)
32 32
 
33 33
 dnl Guess host type.
34 34
 AC_CANONICAL_HOST
35
-AC_CANONICAL_SYSTEM
36 35
 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
37 36
 
38 37
 AC_ARG_WITH(cygwin-native,
... ...
@@ -48,7 +47,7 @@ case "${host}" in
48 48
 		WIN32="yes"
49 49
 		cross_compiling="yes"
50 50
 	;;
51
-	*-cygwin*)
51
+	*-*-cygwin*)
52 52
 		AC_MSG_CHECKING([cygwin mode to use])
53 53
 		if test "${CYGWIN_NATIVE}" = "yes"; then
54 54
 			AC_MSG_RESULT([Using native win32])
... ...
@@ -275,38 +274,38 @@ AC_ARG_WITH(mem-check,
275 275
 dnl fix search path, to allow compilers to find syshead.h
276 276
 CPPFLAGS="$CPPFLAGS -I${srcdir}"
277 277
 
278
-dnl check target OS
279
-openvpn_target=$target
280
-if test $target_alias; then
281
-  openvpn_target=$target_alias
278
+dnl check host OS
279
+openvpn_host=$host
280
+if test $host_alias; then
281
+  openvpn_host=$host_alias
282 282
 fi
283
-AC_DEFINE_UNQUOTED(TARGET_ALIAS, "$openvpn_target", [A string representing our target])
284
-case "$target" in
285
-*linux*)
283
+AC_DEFINE_UNQUOTED(TARGET_ALIAS, "$openvpn_host", [A string representing our host])
284
+case "$host" in
285
+*-*-linux*)
286 286
 	AC_DEFINE(TARGET_LINUX, 1, [Are we running on Linux?])
287 287
 	dnl RH9 SSL headers workaround
288 288
         if test -z $CS_HDR_DIR && test "$CRYPTO" = "yes"; then
289 289
            CPPFLAGS="$CPPFLAGS $(pkg-config --cflags openssl 2>/dev/null)"
290 290
         fi
291 291
 	;;
292
-*solaris*)
292
+*-*-solaris*)
293 293
 	AC_DEFINE(TARGET_SOLARIS, 1, [Are we running on Solaris?])
294 294
 	;;
295
-*openbsd*)
295
+*-*-openbsd*)
296 296
 	AC_DEFINE(TARGET_OPENBSD, 1, [Are we running on OpenBSD?])
297 297
 	;;
298
-*freebsd*)
298
+*-*-freebsd*)
299 299
 	AC_DEFINE(TARGET_FREEBSD, 1, [Are we running on FreeBSD?])
300 300
 	;;
301
-*netbsd*)
301
+*-*-netbsd*)
302 302
 	AC_DEFINE(TARGET_NETBSD, 1, [Are we running NetBSD?])
303 303
 	;;
304
-*darwin*)
304
+*-*-darwin*)
305 305
 	dnl some Mac OS X tendering (we use vararg macros...)
306 306
 	AC_DEFINE(TARGET_DARWIN, 1, [Are we running on Mac OS X?])
307 307
 	CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
308 308
 	;;
309
-*mingw*)
309
+*-mingw*)
310 310
 	AC_DEFINE(TARGET_WIN32, 1, [Are we running WIN32?])
311 311
 	OPENVPN_ADD_LIBS(-lgdi32)
312 312
 	OPENVPN_ADD_LIBS(-lws2_32)
... ...
@@ -315,7 +314,7 @@ case "$target" in
315 315
 	OPENVPN_ADD_LIBS(-liphlpapi)
316 316
 	OPENVPN_ADD_LIBS(-lwinmm)
317 317
 	;;
318
-*dragonfly*)
318
+*-*-dragonfly*)
319 319
 	AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFlyBSD?])
320 320
 	;;
321 321
 	
... ...
@@ -574,7 +573,7 @@ if test "$PTHREAD" = "yes"; then
574 574
   AC_MSG_RESULT([********* WARNING: pthread support is experimental for OpenVPN 2.0])
575 575
   ACX_PTHREAD(
576 576
         [
577
-	    case "$target" in
577
+	    case "$host" in
578 578
 	    *openbsd*)
579 579
 		AC_MSG_RESULT([WARNING: pthread support on OpenBSD is unstable!])
580 580
 		CFLAGS="$CFLAGS -pthread"