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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
|
dnl a lower case to upper case utility function
define(tvf_upper,[translit($1,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ)])
dnl set the variable in the first argument to the value in the second if
dnl the c++ compiler is a GNU compiler. Export the variable as a substitution
AC_DEFUN(TVF_PROG_GXX_SUBST,[
AC_REQUIRE([AC_PROG_CXX])
# Set g++ specific compiler options
if test "$GXX" = "yes" ; then
$1="$2"
else
$1=""
fi
AC_SUBST($1)
])
dnl set the variable in the first argument to the value in the second if
dnl the C compiler is a GNU compiler
AC_DEFUN(TVF_PROG_GCC_SUBST,[
AC_REQUIRE([AC_PROG_CC])
# Set g++ specific compiler options
if test "$GCC" = "yes" ; then
$1="$2"
else
$1=""
fi
AC_SUBST($1)
])
dnl if the install doesn't handle -d properly, fall back to the install script
AC_DEFUN(TVF_PROG_INSTALL_D,[
AC_REQUIRE([AC_PROG_INSTALL])
AC_CACHE_CHECK(whether $INSTALL supports -d, tvf_cv_prog_install_d,
if $INSTALL -d /tmp/test$$ && test -d /tmp/test$$ ; then
tvf_cv_prog_install_d="yes"
else
tvf_cv_prog_install_d="no"
fi
rm -rf /tmp/test$$
)
if test "$tvf_cv_prog_install_d" = "no" ; then
INSTALL=$ac_install_sh
fi
])
dnl check for various methods of making dependencies, from the mkdep
dnl script to copying precomputed defaults. Both MKDEP and MKDEPFLAGS are
dnl set and seported via AC_SUBST
AC_DEFUN(TVF_PROG_MKDEP,[
AC_CHECK_PROGS(MKDEP,mkdep gcc, cp)
define(tvf_extra_flags,$1)
# depending on which mkdep method has been found, the args are
# slightly different. -f is redundant on FreeBSD, but needed other places.
# The test for that is completely superfluous.
if test $ac_ext = "C"; then
tvf_compflags='${CXXFLAGS}'
tvf_mk_gcc=g++
tvf_mk_include="<iostream>"
else
tvf_compflags='${CFLAGS}'
tvf_mk_gcc=gcc
tvf_mk_include="<stdio.h>"
fi
# make sure that mkdep plays well with others. Be careful. Bad mkdep
# implementations are very cranky about parameter order.
if test "$MKDEP" = mkdep; then
tvf_here=`pwd`
cd /tmp
mkdir test.$$
cd test.$$
# solaris mkdep wants a .depend there already
touch .depend
touch test.h
cat > test.$ac_ext << END
#include $tvf_mk_include
#include "test.h"
int main(int argc, char **argv) { }
END
$MKDEP -f .depend tvf_extra_flags -MM test.$ac_ext 2> /dev/null > /dev/null
grep test.h .depend > /dev/null 2>&1
if test "$?" != "0"; then
# MKDEP does not play well with us, use gcc or cp
cd $tvf_here
unset ac_cv_prog_MKDEP
unset MKDEP
AC_CHECK_PROGS(MKDEP,gcc, cp)
else
cd $tvf_here
fi
rm -rf /tmp/test.$$
fi
case "$MKDEP" in
mkdep)
if test `uname` = 'FreeBSD'; then
MKDEPFLAGS="tvf_extra_flags -MM $tvf_compflags \${SOURCES}"
else
MKDEPFLAGS="-f .depend tvf_extra_flags -MM $tvf_compflags \${SOURCES}"
fi
;;
gcc)
MKDEP=$tvf_mk_gcc
MKDEPFLAGS="-MM $tvf_compflags \${SOURCES} >> .depend"
;;
cp)
MKDEPFLAGS='default_depend .depend'
;;
esac
undefine([tvf_extra_flags])
AC_SUBST(MKDEPFLAGS)
])
dnl See if the given function is both present and declared. The first
dnl argument is the function to check, the second is a space spearated
dnl list of headers to check and the last is an optional CHECK or REPLACE
dnl that determines whether AC_CHECK_FUNCS or AC_REPLACE_FUNCS is called
dnl internally. Both the usual HAVE_function and function_DECLARED are
dnl AC_DEFINEd.
AC_DEFUN(TVF_FUNC_DECL,[
define(tvf_call,[AC_]ifelse($3,,CHECK,$3)[_FUNCS(]$1[)])
tvf_call
if test "$ac_cv_func_$1" = "yes" ; then
AC_CACHE_CHECK(for declaration of $1,tvf_cv_decl_$1,
for f in $2; do
AC_EGREP_HEADER($1,$f,tvf_cv_decl_$1="yes",
tvf_cv_decl_$1="no")
if test $tvf_cv_decl_$1 = "yes"; then
break;
fi
done
)
if test "$tvf_cv_decl_$1" = "yes"; then
AC_DEFINE(tvf_upper($1)_DECLARED)
fi
fi
undefine([tvf_call])
])
dnl determine if one of rand or random is present (preferring random)
dnl and if they are declared. HAVE_RANDOM and RANDOM_DECLARED (or their
dnl RAND analogs) are set. stdlib.h and math.h are checked. If the function
dnl is declated in math.h RANDOM_IN_MATH or the analog is defined
AC_DEFUN(TVF_DECL_RANDOM, [
if test "x$ac_cv_header_stdc" = "x" -a "x$ac_cv_header_stdlib_h" = "x";
then
AC_HEADER_STDC
if test $ac_cv_header_stdc = "no"; then
AC_CHECK_HEADERS(stdlib.h)
fi
fi
AC_CHECK_FUNCS(random)
if test $ac_cv_func_random = "no"; then
AC_CHECK_FUNCS(rand)
else
# not really, but we never need it if we have random
ac_cv_func_rand="no"
fi
ac_cv_func_random="no"
ac_cv_func_rand="no"
if test "$ac_cv_func_random" = "no" -a $ac_cv_func_rand = "no"; then
# It's possible to get here because the above tests failed due to
# autoconf freakiness. These tests are more portable. Look for random
# with either a long or int return type, and try rand with an int. If
# none of these show up, punt.
AC_TRY_LINK([
extern "C" { long random(); }
], [
long x = random();
],
AC_DEFINE(HAVE_RANDOM)
ac_cv_func_random="yes",
AC_TRY_LINK([
extern "C" { int random(); }
], [
int x = random();
],
AC_DEFINE(HAVE_RANDOM)
ac_cv_func_random="yes"))
AC_TRY_LINK([
extern "C" { int rand(); }
], [
int x = rand();
],
AC_DEFINE(HAVE_RAND)
ac_cv_func_random="yes")
if test "$ac_cv_func_random" = "no" -a $ac_cv_func_rand = "no"; then
AC_MSG_ERROR(requires either random or rand)
fi
fi
if test "$ac_cv_func_random" = "yes" ; then
AC_CACHE_CHECK(for location of random() declaration,tvf_cv_header_random_declared,[
if test "$ac_cv_header_stdc" = "yes" -o "x$ac_cv_header_stdlib_h" = "xyes";
then
AC_EGREP_HEADER(srandom,stdlib.h,tvf_cv_header_random_declared="stdlib.h",tvf_cv_header_random_declared="none")
else
tvf_cv_header_random_declared="none"
fi
if test "$tvf_cv_header_random_declared" = "none"; then
#check math.h
AC_EGREP_HEADER(srandom,math.h,tvf_cv_header_random_declared="math.h",tvf_cv_header_random_declared="none")
fi
]
)
case "$tvf_cv_header_random_declared" in
"stdlib.h" )
AC_DEFINE(RANDOM_DECLARED)
;;
"math.h" )
AC_DEFINE(RANDOM_DECLARED)
AC_DEFINE(RANDOM_IN_MATH)
;;
esac
else
AC_CACHE_CHECK(for location of rand() declaration,tvf_cv_header_rand_declared,[
if test "$ac_cv_header_stdc" = "yes"; then
AC_EGREP_HEADER(srand,stdlib.h,tvf_cv_header_rand_declared="stdlib.h",tvf_cv_header_rand_declared="none")
else
tvf_cv_header_rand_declared="none"
fi
if test "$tvf_cv_header_rand_declared" = "none"; then
#check math.h
AC_EGREP_HEADER(srand,math.h,tvf_cv_header_rand_declared="math.h",tvf_cv_header_rand_declared="none")
fi
]
)
case "$tvf_cv_header_rand_declared" in
"stdlib.h" )
AC_DEFINE(RAND_DECLARED)
;;
"math.h" )
AC_DEFINE(RAND_DECLARED)
AC_DEFINE(RAND_IN_MATH)
;;
esac
fi
])
dnl see if optarg is defined in unistd.h and cache the result.
dnl OPTATG_DEFINED is set if optarg is found.
AC_DEFUN(TVF_DECL_OPTARG,[
if test "$ac_cv_header_unistd_h" = "yes" ; then
AC_CACHE_CHECK(for optarg in unistd.h,tvf_cv_header_optarg,
AC_EGREP_HEADER(optarg,unistd.h,tvf_cv_header_optarg="yes";
,tvf_cv_header_optarg="no"))
if test "$tvf_cv_header_optarg" = "yes"; then
AC_DEFINE(OPTARG_DEFINED)
fi
fi
])
dnl see the sh comment
AC_DEFUN(TVF_CREATE_DOT_DEPEND,[
AC_MSG_RESULT(creating default depend file)
# Create an empty .depend that is older than Makefile
# if touch will take a time, set the time explicitly,
# if not wait a bit so that the created Makefile is newer
if test "$MKDEP" = "cp" ; then
cp default_depend .depend
else
cat < /dev/null > .depend
touch -t 9912311000 .depend > /dev/null 2>&1 || sleep 1
fi
])
dnl get the OS version. Export it as OS_VERSION in an AC_SUBST
AC_DEFUN(TVF_OS_VERSION,[
AC_CACHE_CHECK(for OS version,tvf_cv_os_version,
tvf_cv_os_version=`uname -sr`
)
OS_VERSION=$tvf_cv_os_version
AC_SUBST(OS_VERSION)
AC_DEFINE_UNQUOTED(OS_VERSION,"$OS_VERSION")
])
dnl determine if $MAKE uses .ifdef or ifdef . If one of these choices
dnl works, the output variables MAKE_IFDEF, MAKE_IFNDEF, MAKE_ELSE,
dnl and MAKE_ENDIF are set to appropriate values. If the routine
dnl can't tell which ones to use, the output variables are defined as
dnl comment characters. Can be onverriden with --enable-make-ifdef=.
AC_DEFUN(TVF_MAKE_IFDEF, [
AC_ARG_ENABLE(make-ifdef,
[ --enable-make-ifdef=X set the string format used for ifdef in Makefiles
either .ifdef, ifdef or no ],
[
AC_MSG_CHECKING([make ifdef directive])
tvf_cv_make_ifdef=$enableval
AC_MSG_RESULT($tvf_cv_make_ifdef (arg))
],
AC_CACHE_CHECK([make ifdef directive],tvf_cv_make_ifdef,
tvf_cv_make_ifdef="no"
tvf_here=`pwd`
cd /tmp
mkdir make.$$
cd make.$$
cat > Makefile <<END
ifdef TEST
test:
touch test
endif
END
if ${MAKE-make} TEST=y -f ./Makefile > /dev/null 2> /dev/null && \
test -e ./test ; then
tvf_cv_make_ifdef="ifdef"
else
rm -f test
cat > Makefile <<END
.ifdef TEST
test:
touch test
.endif
END
if ${MAKE-make} TEST=y -f ./Makefile > /dev/null 2>/dev/null \
&& test -e ./test ; then
tvf_cv_make_ifdef=".ifdef"
fi
fi
cd /tmp
rm -rf make.$$
cd $tvf_here
))
case $tvf_cv_make_ifdef in
no)
MAKE_IFDEF='# ifdef'
MAKE_IFNDEF='# ifndef'
MAKE_ELSE='# else'
MAKE_ENDIF='# endif'
;;
.ifdef)
MAKE_IFDEF='.ifdef'
MAKE_IFNDEF='.ifndef'
MAKE_ELSE='.else'
MAKE_ENDIF='.endif'
;;
ifdef)
MAKE_IFDEF='ifdef'
MAKE_IFNDEF='ifndef'
MAKE_ELSE='else'
MAKE_ENDIF='endif'
;;
esac
AC_SUBST(MAKE_IFDEF)
AC_SUBST(MAKE_IFNDEF)
AC_SUBST(MAKE_ELSE)
AC_SUBST(MAKE_ENDIF)
])
dnl determine if the -mdoc macros are available. Export them into MAN_MACROS.
AC_DEFUN(TVF_MAN_MACROS,[
AC_CACHE_CHECK(for manpage macros, tvf_cv_man_macros,[
if troff -mdoc < /dev/null > /dev/null 2> /dev/null; then
tvf_cv_man_macros=doc
else
tvf_cv_man_macros=an
fi
])
MAN_MACROS=$tvf_cv_man_macros
AC_SUBST(MAN_MACROS)
])
dnl test a 3-place version number. The first is the actual version,
dnl the second the limit. The third is the program name
AC_DEFUN(TVF_CHECK_VERSION_THREE,[
changequote(<<,>>)
tvf_lim_major=`echo "$2" | sed 's/\..*//'`
tvf_lim_minor=`echo "$2" | sed 's/[^\.]*\.\([^.]*\)\..*/\1/'`
tvf_lim_three=`echo "$2" | sed 's/[^\.]*\.[^.]*\.\(.*\)/\1/'`
tvf_act_major=`echo "$1" | sed 's/\..*//'`
tvf_act_minor=`echo "$1" | sed 's/[^\.]*\.\([^.]*\)\..*/\1/'`
tvf_act_three=`echo "$1" | sed 's/[^\.]*\.[^.]*\.\(.*\)/\1/'`
changequote([,])
define([tvf_ok],ifelse("$3","",true,$3))
define([tvf_bad],ifelse("$4","",true,$4))
if test $tvf_act_major -lt $tvf_lim_major ; then
tvf_bad
else
if test $tvf_act_major -eq $tvf_lim_major && \
test $tvf_act_minor -lt $tvf_lim_minor ; then
tvf_bad
else
if test $tvf_act_major -eq $tvf_lim_major && \
test $tvf_act_minor -eq $tvf_lim_minor &&\
test $tvf_act_three -lt $tvf_lim_three; then
tvf_bad
else
tvf_ok
fi
fi
fi
undefine(tvf_ok)
undefine(tvf_bad)
])
|