1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
dnl auto-configuration macros for Florist
dnl This version requires autoconf-2.10.
dnl AC_POSIX_HEADER(HEADER-FILE,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl side-effect: extend file "pconfig.h",
dnl with includes for this header, if present.
AC_DEFUN(AC_POSIX_HEADER,
[dnl Do the transliteration at runtime so arg 1 can be a shell variable.
ac_old_cflags=$CFLAGS
# CFLAGS="$CFLAGS -Werror"
ac_safe=`echo "$1" | tr './\055' '___'`
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_header_$ac_safe,
[AC_TRY_CPP([#include <$1>],
AC_TRY_COMPILE([#include "pconfig.h"
#include <$1>],,
eval "ac_cv_header_$ac_safe=yes",
eval "ac_cv_header_$ac_safe=no"),
eval "ac_cv_header_$ac_safe=no")])dnl
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
AC_MSG_RESULT(yes)
echo "#include <$1>" >> pconfig.h
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
ifelse([$3], , , [$3
])dnl
fi
CFLAGS=$ac_old_cflags
])dnl
dnl AC_POSIX_HEADERS(NAMES...)
dnl side-effect: create file "pconfig.h" containing includes
dnl for all the headers that are present.
AC_DEFUN(AC_POSIX_HEADERS,
[rm -f pconfig.h
cp pconfig.h.in pconfig.h
chmod 644 pconfig.h
if ( test ! -f pconfig.h ) then
AC_MSG_ERROR(missing pconfig.h);
fi
for ac_hdr in $1
do
AC_POSIX_HEADER($ac_hdr,
[changequote(, )dnl
ac_tr_hdr=HAVE_`echo $ac_hdr |
tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
changequote([, ])dnl
AC_DEFINE_UNQUOTED($ac_tr_hdr)])dnl
done
])dnl
dnl AC_POSIX5C_HEADERS(NAMES...)
dnl side-effect: create file "pconfig.h" containing includes
dnl for all the headers that are present.
AC_DEFUN(AC_POSIX5C_HEADERS,
[for ac_hdr in $1
do
AC_POSIX_HEADER($ac_hdr,
[changequote(, )dnl
ac_tr_hdr=HAVE_`echo $ac_hdr |
tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
changequote([, ])dnl
AC_DEFINE_UNQUOTED($ac_tr_hdr)])dnl
done
AC_POSIX_HEADER(xti.h, AC_DEFINE_UNQUOTED(HAVE_XTI_H)
[ echo "-- don't want TLI because we have xti.h
TLI := False" >> gnatprep.config;],
AC_POSIX_HEADER(tli.h, AC_DEFINE_UNQUOTED(HAVE_TLI_H)
[ echo "-- using TLI because could not find xti.h
TLI := True" >> gnatprep.config;],
[ echo "-- could not find tli.h
TLI := False" >> gnatprep.config;],
))
AC_TRY_COMPILE([#include "pconfig.h"],
[ struct msghdr hdr;
hdr.msg_controllen = 0;],
[echo "Socket interface Looks like BSD 4.4";
# Put BSD flag in gnatprep.config
if (grep BSD4_3 gnatprep.config >/dev/null 2>&1); then true;
else
echo "-- set BSD4_3 to False if using 4.4 style socket msghdr" \
>> gnatprep.config
echo "BSD4_3 := False" >> gnatprep.config;
fi;
if (grep _BSD4_4_ pconfig.h >/dev/null 2>&1); then true;
else
echo "#define _BSD4_4_" >> pconfig.h;
fi;],
[echo "Socket interface Looks like BSD 4.3";
if (grep BSD4_3 gnatprep.config >/dev/null 2>&1); then true;
else
echo "-- set BSD4_3 to False if using 4.4 style socket msghdr
BSD4_3 := True" >> gnatprep.config;
fi;
if (grep _BSD4_3_ pconfig.h >/dev/null 2>&1); then true;
else
echo "#define _BSD4_3_" >> pconfig.h;
fi;])
[if (grep xti.h pconfig.h >/dev/null 2>&1); then
if (grep _XTI_ pconfig.h >/dev/null 2>&1); then true;
else
echo "#define _XTI_" >> pconfig.h;
fi ;
else
if [ -f /usr/include/sys/tiuser.h ]; then
echo "Have only TLI, will use that in place of XTI";
if (grep _TLI_ pconfig.h >/dev/null 2>&1); then true;
else
echo "#define _TLI_" >> pconfig.h;
echo "#include <sys/tiuser.h>" >> pconfig.h;
fi;
fi;
fi]
AC_CHECK_FUNC(getaddrinfo,
[ADDRINFO_OBJECTS=""
AC_SUBST(ADDRINFO_OBJECTS)
],
[AC_MSG_WARN(No getaddrinfo provided by the OS. Will use our own version.)
ADDRINFO_OBJECTS="getaddrinfo.o inet_pton.o inet_ntop.o"
AC_SUBST(ADDRINFO_OBJECTS)
echo '#include "addrinfo.h"' >> pconfig.h;
])
])dnl
dnl AC_POSIX_LIBS(LIBRARY..., FUNCTION
dnl [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_POSIX_LIBS,
[for ac_lib in $1
do
AC_POSIX_LIB($ac_lib,$2,ac_lib_success="yes",ac_lib_success="no")
if [[ "$ac_lib_success" = "yes" ]]
then break;
fi
done])
dnl AC_POSIX_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_POSIX_LIB,
[AC_MSG_CHECKING([for $2 in -l$1])
dnl Use a cache variable name containing both the library and function name,
dnl because the test really is for library $1 defining function $2, not
dnl just for library $1. Separate tests with the same $1 and different $2s
dnl may have different results.
ac_lib_var=`echo $1[_]$2 | tr ':.-/+' '____p'`
ac_save_LIBS="$LIBS"
LIBS="-l$1 $LIBS"
AC_TRY_LINK([/* Override any gcc2 internal prototype to avoid an error. */
]
AC_LANG_CASE(CPLUSPLUS,
[#ifdef __cplusplus
extern "C"
#endif
],[])dnl
[char $2();
],
[$2()],
eval "ac_cv_lib_$ac_lib_var=yes",
eval "ac_cv_lib_$ac_lib_var=no")
LIBS="$ac_save_LIBS"
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
AC_MSG_RESULT(yes)
if echo ${LIBS} | grep $1; then true;
else
LIBS="-l$1 ${LIBS}"
fi
ifelse([$3], , , [$3
])dnl
else
AC_MSG_RESULT(no)
ifelse([$4], , , [$4
])dnl
fi
])
dnl AC_POSIX_TYPE(TYPE-NAME)
AC_DEFUN(AC_POSIX_TYPE,
[AC_REQUIRE([AC_POSIX_HEADERS])dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_type_$1,
AC_EGREP_CPP($1[[[^0-9A-Za-z_]]],[#include "pconfig.h"],
eval "ac_cv_type_$1=yes", eval "ac_cv_type_$1=no"))
if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
AC_DEFINE_UNQUOTED(HAVE_$1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
dnl AC_POSIX_TYPES(TYPE-NAME...)
AC_DEFUN(AC_POSIX_TYPES,
[for ac_typ in $1
do
AC_POSIX_TYPE($ac_typ)
done
])
dnl AC_POSIX_CONST(CONST)
AC_DEFUN(AC_POSIX_CONST,
[AC_REQUIRE([AC_POSIX_HEADERS])dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_const_$1,
[AC_EGREP_CPP($1, [#include "pconfig.h"], eval "ac_cv_const_$1=yes",
AC_EGREP_CPP(yes, [#include "pconfig.h"
#ifdef $1
yes
#endif], eval "ac_cv_const_$1=yes",
eval "ac_cv_const_$1=no"))])dnl
if eval "test \"`echo '$ac_cv_const_'$1`\" = yes"; then
AC_DEFINE_UNQUOTED(HAVE_$1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
dnl AC_POSIX_CONSTS(CONST-NAME...)
AC_DEFUN(AC_POSIX_CONSTS,
[for ac_const in $1
do
AC_POSIX_CONST($ac_const)
done
])
dnl AC_POSIX_STRUCT(NAME,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_POSIX_STRUCT,
[AC_REQUIRE([AC_POSIX_HEADERS])dnl
AC_MSG_CHECKING(for struct $1)
AC_CACHE_VAL(ac_cv_struct_$1,
[AC_TRY_COMPILE([#include "pconfig.h"
struct $1 x;],,eval "ac_cv_struct_$1=yes",
eval "ac_cv_struct_$1=no")])dnl
if eval "test \"`echo '$ac_cv_struct_'$1`\" = yes"; then
AC_DEFINE_UNQUOTED(HAVE_struct_$1)
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
ifelse([$3], , , [$3])dnl
fi
])
dnl AC_POSIX_STRUCTS(NAME...)
AC_DEFUN(AC_POSIX_STRUCTS,
[for ac_struct in $1
do
AC_POSIX_STRUCT($ac_struct)
done
])
dnl AC_POSIX_FUNCS(FUNCTION... )
AC_DEFUN(AC_POSIX_FUNCS,
[for ac_func in $1
do
AC_CHECK_FUNC($ac_func,
[AC_DEFINE_UNQUOTED(HAVE_$ac_func,1)],
[AC_DEFINE_UNQUOTED(HAVE_$ac_func,0)])dnl
done
])
dnl AC_POSIX_VAR(NAME)
AC_DEFUN(AC_POSIX_VAR,
[AC_REQUIRE([AC_POSIX_HEADERS])dnl
AC_MSG_CHECKING(for global variable or macro $1)
AC_CACHE_VAL(ac_cv_comp_$1,
[AC_EGREP_CPP($1, [#include "pconfig.h"], eval "ac_cv_comp_$1=yes",
eval "ac_cv_comp_$1=no")])dnl
if eval "test \"`echo '$ac_cv_comp_'$1`\" = yes"; then
AC_DEFINE_UNQUOTED(HAVE_$1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
dnl AC_POSIX_COMP(STRUCTNAME, COMPNAME)
AC_DEFUN(AC_POSIX_COMP,
[AC_REQUIRE([AC_POSIX_HEADERS])dnl
AC_MSG_CHECKING(for struct $1 component $2)
AC_CACHE_VAL(ac_cv_comp_$2,
[AC_TRY_COMPILE([#include "pconfig.h"
struct $1 x;],
[x.$2 = x.$2;], eval "ac_cv_comp_$2=yes",
eval "ac_cv_comp_$2=no")])dnl
if eval "test \"`echo '$ac_cv_comp_'$2`\" = yes"; then
AC_DEFINE_UNQUOTED(HAVE_component_$2)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
dnl AC_POSIX_COMP_OVERLAY(STRUCTNAME, COMPNAME1, COMPNAME2)
dnl check for COMPNAME1 but only if it does not overlay in memory
dnl layout with COMPNAME2; e.g. see overlaying of sigaction components
dnl sa_handler and sa_sigaction
AC_DEFUN(AC_POSIX_COMP_OVERLAY,
[AC_REQUIRE([AC_POSIX_HEADERS])dnl
AC_MSG_CHECKING(for struct $1 component $2 overlaying $3)
AC_CACHE_VAL(ac_cv_comp_$2,
AC_TRY_RUN([#include "pconfig.h"
main()
{
struct $1 x;
if (&x.$2 == &x.$3) {
fprintf(stderr,"$2 overlays $3...");
exit (1);
} else {
exit (0);
}
}], eval "ac_cv_comp_$2=yes",
eval "ac_cv_comp_$2=no", eval "ac_cv_comp_$2=nu"))dnl
if eval "test \"`echo '$ac_cv_comp_'$2`\" = yes"; then
AC_DEFINE_UNQUOTED(HAVE_component_$2)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
|