Browse code

build: split acinclude.m4 into m4/*

ax_emptyarray.m4 ax_openvpn_lib.m4 ax_socklen_t.m4 ax_varargs.m4

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Signed-off-by: David Sommerseth <davids@redhat.com>

Alon Bar-Lev authored on 2012/03/01 05:11:52
Showing 8 changed files
... ...
@@ -28,6 +28,7 @@ LDADD = @LIBOBJS@
28 28
 # This option prevents autoreconf from overriding our COPYING and
29 29
 # INSTALL targets:
30 30
 AUTOMAKE_OPTIONS = foreign
31
+ACLOCAL_AMFLAGS = -I m4
31 32
 
32 33
 MAINTAINERCLEANFILES = \
33 34
 	config.log config.status \
34 35
deleted file mode 100644
... ...
@@ -1,131 +0,0 @@
1
-dnl Special Autoconf Macros for OpenVPN
2
-
3
-dnl OPENVPN_ADD_LIBS(LIB)
4
-AC_DEFUN([OPENVPN_ADD_LIBS], [
5
-  LIBS="$1 $LIBS"
6
-])
7
-
8
-dnl @synopsis AX_EMPTY_ARRAY
9
-dnl
10
-dnl Define EMPTY_ARRAY_SIZE to be either "0"
11
-dnl or "" depending on which syntax the compiler
12
-dnl prefers for empty arrays in structs.
13
-dnl
14
-dnl @version
15
-dnl @author James Yonan <jim@yonan.net>
16
-
17
-
18
-AC_DEFUN([AX_EMPTY_ARRAY], [
19
-  AC_MSG_RESULT([checking for C compiler empty array support])
20
-  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
21
-    [
22
-        struct { int foo; int bar[[0]]; } mystruct;
23
-    ])], [
24
-        AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE, 0, [Dimension to use for empty array declaration])
25
-    ], [
26
-        AC_COMPILE_IFELSE([AC_LANG_SOURCE(
27
-	    [
28
-	        struct { int foo; int bar[[]]; } mystruct;
29
-	    ])], [
30
-                AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE,, [Dimension to use for empty array declaration])
31
-	    ], [
32
-	        AC_MSG_ERROR([C compiler is unable to creaty empty arrays])
33
-	    ])
34
-    ])
35
-  ]
36
-)
37
-
38
-dnl @synopsis AX_CPP_VARARG_MACRO_GCC
39
-dnl
40
-dnl Test if the preprocessor understands GNU GCC-style vararg macros.
41
-dnl If it does, defines HAVE_CPP_VARARG_MACRO_GCC to 1.
42
-dnl
43
-dnl @version
44
-dnl @author James Yonan <jim@yonan.net>, Matthias Andree <matthias.andree@web.de>
45
-AC_DEFUN([AX_CPP_VARARG_MACRO_GCC], [dnl
46
-    AS_VAR_PUSHDEF([VAR],[ax_cv_cpp_vararg_macro_gcc])dnl
47
-    AC_CACHE_CHECK([for GNU GCC vararg macro support], VAR, [dnl
48
-      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
49
-	#define macro(a, b...) func(a, b)
50
-	int func(int a, int b, int c);
51
-	int test() { return macro(1, 2, 3); }
52
-	])], [ VAR=yes ], [VAR=no])])
53
-    if test $VAR = yes ; then
54
-    AC_DEFINE([HAVE_CPP_VARARG_MACRO_GCC], 1,
55
-      [Define to 1 if your compiler supports GNU GCC-style variadic macros])
56
-    fi
57
-    AS_VAR_POPDEF([VAR])dnl
58
-])
59
-
60
-dnl @synopsis AX_CPP_VARARG_MACRO_ISO
61
-dnl
62
-dnl Test if the preprocessor understands ISO C 1999 vararg macros.
63
-dnl If it does, defines HAVE_CPP_VARARG_MACRO_ISO to 1.
64
-dnl
65
-dnl @version
66
-dnl @author James Yonan <jim@yonan.net>, Matthias Andree <matthias.andree@web.de>
67
-AC_DEFUN([AX_CPP_VARARG_MACRO_ISO], [dnl
68
-    AS_VAR_PUSHDEF([VAR],[ax_cv_cpp_vararg_macro_iso])dnl
69
-    AC_CACHE_CHECK([for ISO C 1999 vararg macro support], VAR, [dnl
70
-      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
71
-#define macro(a, ...) func(a, __VA_ARGS__)
72
-	int func(int a, int b, int c);
73
-	int test() { return macro(1, 2, 3); }
74
-	])], [ VAR=yes ], [VAR=no])])
75
-    if test $VAR = yes ; then
76
-    AC_DEFINE([HAVE_CPP_VARARG_MACRO_ISO], 1,
77
-      [Define to 1 if your compiler supports ISO C99 variadic macros])
78
-    fi
79
-    AS_VAR_POPDEF([VAR])dnl
80
-])
81
-
82
-dnl -- The following is taken from curl's acinclude.m4 --
83
-dnl Check for socklen_t: historically on BSD it is an int, and in
84
-dnl POSIX 1g it is a type of its own, but some platforms use different
85
-dnl types for the argument to getsockopt, getpeername, etc.  So we
86
-dnl have to test to find something that will work.
87
-AC_DEFUN([TYPE_SOCKLEN_T],
88
-[
89
-   AC_CHECK_TYPE([socklen_t], ,[
90
-      AC_MSG_CHECKING([for socklen_t equivalent])
91
-      AC_CACHE_VAL([curl_cv_socklen_t_equiv],
92
-      [
93
-         case "$host" in
94
-	 *-mingw*) curl_cv_socklen_t_equiv=int ;;
95
-	 *)
96
-            # Systems have either "struct sockaddr *" or
97
-            # "void *" as the second argument to getpeername
98
-            curl_cv_socklen_t_equiv=
99
-            for arg2 in "struct sockaddr" void; do
100
-               for t in int size_t unsigned long "unsigned long"; do
101
-                  AC_TRY_COMPILE([
102
-                     #include <sys/types.h>
103
-                     #include <sys/socket.h>
104
-
105
-                     int getpeername (int, $arg2 *, $t *);
106
-                  ],[
107
-                     $t len;
108
-                     getpeername(0,0,&len);
109
-                  ],[
110
-                     curl_cv_socklen_t_equiv="$t"
111
-                     break
112
-                  ])
113
-               done
114
-            done
115
-	 ;;
116
-	 esac
117
-
118
-         if test "x$curl_cv_socklen_t_equiv" = x; then
119
-            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
120
-         fi
121
-      ])
122
-      AC_MSG_RESULT($curl_cv_socklen_t_equiv)
123
-      AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
124
-			[type to use in place of socklen_t if not defined])],
125
-      [#include <sys/types.h>
126
-#ifdef WIN32
127
-#include <ws2tcpip.h>
128
-#else
129
-#include <sys/socket.h>
130
-#endif])
131
-])
... ...
@@ -32,6 +32,7 @@ AC_CONFIG_SRCDIR(syshead.h)
32 32
 
33 33
 dnl Guess host type.
34 34
 AC_CANONICAL_HOST
35
+AC_CONFIG_MACRO_DIR([m4])
35 36
 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
36 37
 
37 38
 AC_ARG_WITH(cygwin-native,
38 39
new file mode 100644
39 40
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+dnl @synopsis AX_EMPTY_ARRAY
1
+dnl
2
+dnl Define EMPTY_ARRAY_SIZE to be either "0"
3
+dnl or "" depending on which syntax the compiler
4
+dnl prefers for empty arrays in structs.
5
+dnl
6
+dnl @version
7
+dnl @author James Yonan <jim@yonan.net>
8
+AC_DEFUN([AX_EMPTY_ARRAY], [
9
+  AC_MSG_RESULT([checking for C compiler empty array support])
10
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
11
+    [
12
+        struct { int foo; int bar[[0]]; } mystruct;
13
+    ])], [
14
+        AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE, 0, [Dimension to use for empty array declaration])
15
+    ], [
16
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE(
17
+	    [
18
+	        struct { int foo; int bar[[]]; } mystruct;
19
+	    ])], [
20
+                AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE,, [Dimension to use for empty array declaration])
21
+	    ], [
22
+	        AC_MSG_ERROR([C compiler is unable to creaty empty arrays])
23
+	    ])
24
+    ])
25
+  ]
26
+)
0 27
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+dnl OPENVPN_ADD_LIBS(LIB)
1
+AC_DEFUN([OPENVPN_ADD_LIBS], [
2
+  LIBS="$1 $LIBS"
3
+])
0 4
new file mode 100644
... ...
@@ -0,0 +1,50 @@
0
+dnl -- The following is taken from curl's acinclude.m4 --
1
+dnl Check for socklen_t: historically on BSD it is an int, and in
2
+dnl POSIX 1g it is a type of its own, but some platforms use different
3
+dnl types for the argument to getsockopt, getpeername, etc.  So we
4
+dnl have to test to find something that will work.
5
+AC_DEFUN([TYPE_SOCKLEN_T],
6
+[
7
+   AC_CHECK_TYPE([socklen_t], ,[
8
+      AC_MSG_CHECKING([for socklen_t equivalent])
9
+      AC_CACHE_VAL([curl_cv_socklen_t_equiv],
10
+      [
11
+         case "$host" in
12
+	 *-mingw*) curl_cv_socklen_t_equiv=int ;;
13
+	 *)
14
+            # Systems have either "struct sockaddr *" or
15
+            # "void *" as the second argument to getpeername
16
+            curl_cv_socklen_t_equiv=
17
+            for arg2 in "struct sockaddr" void; do
18
+               for t in int size_t unsigned long "unsigned long"; do
19
+                  AC_TRY_COMPILE([
20
+                     #include <sys/types.h>
21
+                     #include <sys/socket.h>
22
+
23
+                     int getpeername (int, $arg2 *, $t *);
24
+                  ],[
25
+                     $t len;
26
+                     getpeername(0,0,&len);
27
+                  ],[
28
+                     curl_cv_socklen_t_equiv="$t"
29
+                     break
30
+                  ])
31
+               done
32
+            done
33
+	 ;;
34
+	 esac
35
+
36
+         if test "x$curl_cv_socklen_t_equiv" = x; then
37
+            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
38
+         fi
39
+      ])
40
+      AC_MSG_RESULT($curl_cv_socklen_t_equiv)
41
+      AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
42
+			[type to use in place of socklen_t if not defined])],
43
+      [#include <sys/types.h>
44
+#ifdef WIN32
45
+#include <ws2tcpip.h>
46
+#else
47
+#include <sys/socket.h>
48
+#endif])
49
+])
0 50
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+dnl @synopsis AX_CPP_VARARG_MACRO_GCC
1
+dnl
2
+dnl Test if the preprocessor understands GNU GCC-style vararg macros.
3
+dnl If it does, defines HAVE_CPP_VARARG_MACRO_GCC to 1.
4
+dnl
5
+dnl @version
6
+dnl @author James Yonan <jim@yonan.net>, Matthias Andree <matthias.andree@web.de>
7
+AC_DEFUN([AX_CPP_VARARG_MACRO_GCC], [dnl
8
+    AS_VAR_PUSHDEF([VAR],[ax_cv_cpp_vararg_macro_gcc])dnl
9
+    AC_CACHE_CHECK([for GNU GCC vararg macro support], VAR, [dnl
10
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
11
+	#define macro(a, b...) func(a, b)
12
+	int func(int a, int b, int c);
13
+	int test() { return macro(1, 2, 3); }
14
+	])], [ VAR=yes ], [VAR=no])])
15
+    if test $VAR = yes ; then
16
+    AC_DEFINE([HAVE_CPP_VARARG_MACRO_GCC], 1,
17
+      [Define to 1 if your compiler supports GNU GCC-style variadic macros])
18
+    fi
19
+    AS_VAR_POPDEF([VAR])dnl
20
+])
21
+
22
+dnl @synopsis AX_CPP_VARARG_MACRO_ISO
23
+dnl
24
+dnl Test if the preprocessor understands ISO C 1999 vararg macros.
25
+dnl If it does, defines HAVE_CPP_VARARG_MACRO_ISO to 1.
26
+dnl
27
+dnl @version
28
+dnl @author James Yonan <jim@yonan.net>, Matthias Andree <matthias.andree@web.de>
29
+AC_DEFUN([AX_CPP_VARARG_MACRO_ISO], [dnl
30
+    AS_VAR_PUSHDEF([VAR],[ax_cv_cpp_vararg_macro_iso])dnl
31
+    AC_CACHE_CHECK([for ISO C 1999 vararg macro support], VAR, [dnl
32
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
33
+#define macro(a, ...) func(a, __VA_ARGS__)
34
+	int func(int a, int b, int c);
35
+	int test() { return macro(1, 2, 3); }
36
+	])], [ VAR=yes ], [VAR=no])])
37
+    if test $VAR = yes ; then
38
+    AC_DEFINE([HAVE_CPP_VARARG_MACRO_ISO], 1,
39
+      [Define to 1 if your compiler supports ISO C99 variadic macros])
40
+    fi
41
+    AS_VAR_POPDEF([VAR])dnl
42
+])