]> sjero.net Git - iperf/blob - m4/dast.m4
Original 2.0.2 iperf sources
[iperf] / m4 / dast.m4
1
2 dnl DAST_CHECK_BOOL
3 dnl Check for bool support. Defines bool, true, and false.
4
5 AH_TEMPLATE([HAVE_POSIX_THREAD], [])
6 AH_TEMPLATE([_REENTRANT], [])
7 AH_TEMPLATE([ssize_t], [Define to "int" if <sys/types.h> does not define.])
8 AH_TEMPLATE([bool])
9 AH_TEMPLATE([true])
10 AH_TEMPLATE([false])
11
12 AC_DEFUN(DAST_CHECK_BOOL, [
13
14 AC_CHECK_SIZEOF(bool)
15 if test "$ac_cv_sizeof_bool" = 0 ; then
16   AC_DEFINE(bool, int)
17 fi
18
19 AC_CACHE_CHECK(if true is defined, ac_cv_have_true,
20  [AC_LANG_SAVE
21   AC_LANG_CPLUSPLUS
22   AC_TRY_COMPILE([],
23     [unsigned int i = true],
24   ac_cv_have_true=yes,
25   ac_cv_have_true=no)
26   AC_LANG_RESTORE
27  ])
28
29 if test "$ac_cv_have_true" != yes ; then
30   AC_DEFINE(true,  1)
31   AC_DEFINE(false, 0)
32 fi
33
34 ])
35
36 dnl ===================================================================
37 dnl DAST_REPLACE_TYPE( type, sizeof )
38 dnl Check for the type as AC_CHECK_TYPE does. Define HAVE_<type>
39 dnl if type exists; don't define <type> to anything if it doesn't exist.
40 dnl Useful if there is no well-defined default type, such as int32_t
41
42 AC_DEFUN(DAST_REPLACE_TYPE, [
43
44 AC_CACHE_CHECK(for $1, ac_cv_type_$1,
45   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]],
46     [[$1 foo]])],
47   ac_cv_type_$1=yes,
48   ac_cv_type_$1=no)
49
50 if test $ac_cv_type_$1 != yes ; then
51   if test "$ac_cv_sizeof_char" = $2; then
52     ac_cv_type_$1="char"
53   elif test "$ac_cv_sizeof_short" = $2; then
54     ac_cv_type_$1="short"
55   elif test "$ac_cv_sizeof_int" = $2; then
56     ac_cv_type_$1="int"
57   elif test "$ac_cv_sizeof_long" = $2; then
58     ac_cv_type_$1="long"
59   elif test "$ac_cv_sizeof_long_long" = $2; then
60     ac_cv_type_$1="long long"
61   fi
62 fi)
63
64 if test "$ac_cv_type_$1" != no; then
65   if test "$ac_cv_type_$1" != yes; then
66     AC_DEFINE_UNQUOTED($1, $ac_cv_type_$1)
67   fi
68   AC_DEFINE_UNQUOTED(HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`)
69 fi
70
71 ])
72
73 AC_DEFUN(DAST_REPLACE_TYPE_UNSIGNED, [
74
75 AC_CACHE_CHECK(for $1, ac_cv_type_$1,
76   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]],
77     [[$1 foo]])],
78   ac_cv_type_$1=yes,
79   ac_cv_type_$1=no)
80
81 if test $ac_cv_type_$1 != yes ; then
82   if test "$ac_cv_sizeof_unsigned_char" = $2; then
83     ac_cv_type_$1="unsigned char"
84   elif test "$ac_cv_sizeof_unsigned_short" = $2; then
85     ac_cv_type_$1="unsigned short"
86   elif test "$ac_cv_sizeof_unsigned_int" = $2; then
87     ac_cv_type_$1="unsigned int"
88   elif test "$ac_cv_sizeof_unsigned_long" = $2; then
89     ac_cv_type_$1="unsigned long"
90   elif test "$ac_cv_sizeof_unsigned_long_long" = $2; then
91     ac_cv_type_$1="unsigned long long"
92   fi
93 fi)
94
95 if test "$ac_cv_type_$1" != no; then
96   if test "$ac_cv_type_$1" != yes; then
97     AC_DEFINE_UNQUOTED($1, $ac_cv_type_$1)
98   fi
99   AC_DEFINE_UNQUOTED(HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`)
100 fi
101
102 ])
103
104 dnl DAST_CHECK_ARG
105 dnl Check for the 3rd arguement to accept
106
107 AC_DEFUN(DAST_ACCEPT_ARG, [
108   if test -z "$ac_cv_accept_arg" ; then
109     AC_LANG_SAVE
110     AC_LANG_CPLUSPLUS
111
112     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
113       [[$ac_includes_default
114        #include <sys/socket.h>]],
115       [[$1 length;
116        accept( 0, 0, &length );]])],
117     ac_cv_accept_arg=$1)
118
119     AC_LANG_RESTORE
120   fi
121 ])
122
123 dnl Configure paths for Web100.  Based off of Owen Taylor's gtk.m4 from gtk+-1.2.10
124 dnl AM_PATH_WEB100([EXACT-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
125 dnl Test for Web100, and define WEB100_CFLAGS and WEB100_LIBS
126 dnl
127 AC_DEFUN(AM_PATH_WEB100,
128 [
129 web100_success=""
130
131 AC_PATH_PROG([WEB100_CONFIG], [web100-config], [no])
132
133 AC_MSG_CHECKING(for Web100)
134
135 if test "$WEB100_CONFIG" != "no"; then
136   WEB100_CFLAGS=`$WEB100_CONFIG --cflags`
137   WEB100_LIBS=`$WEB100_CONFIG --libs`
138   AC_MSG_RESULT(yes)
139 else
140   AC_MSG_RESULT(no)
141   echo "*** The web100-config script installed by Web100 could not be found"
142   echo "*** If Web100 was installed in PREFIX, make sure PREFIX/bin is in"
143   echo "*** your path, or set the WEB100_CONFIG environment variable to the"
144   echo "*** full path to web100-config"
145   web100_success="no"
146 fi
147
148 if test x$web100_success = x; then
149   if test "x$1" != "x"; then
150     AC_MSG_CHECKING(for Web100 - version $1)
151
152     WEB100_VERSION=`$WEB100_CONFIG --version`
153     if test "$WEB100_VERSION" = "$1"; then
154       AC_MSG_RESULT(yes)
155     else
156       AC_MSG_RESULT(no)
157       echo "*** The requested ($1) and installed ($WEB100_VERSION) versions"
158       echo "*** of Web100 do not match."
159       web100_success="no"
160     fi
161   fi
162 fi
163
164 if test x$web100_success = x; then
165   web100_success="yes"
166 fi
167
168 if test x$web100_success = xyes; then
169   m4_if([$2], [], [:], [$2])
170 else
171   WEB100_CFLAGS=""
172   WEB100_LIBS=""
173   m4_if([$3], [], [:], [$3])
174 fi
175
176 AC_SUBST(WEB100_CFLAGS)
177 AC_SUBST(WEB100_LIBS)
178 ])