1dnl --------------------------------------------------------------------------- 2dnl This file offers the following macros... 3dnl --------------------------------------------------------------------------- 4dnl MH_IPC 5dnl MH_CHECK_X_INC 6dnl MH_CHECK_X_LIB 7dnl MH_CHECK_X_HEADERS 8dnl MH_CHECK_X_KEYDEFS 9dnl MH_CHECK_X_TYPEDEF 10dnl MH_CHECK_LIB 11dnl MH_SHARED_LIBRARY 12dnl MH_HOWTO_DYN_LINK 13dnl MH_CHECK_CC_O 14dnl MH_SHLPST 15dnl MH_CHECK_MAX_SIGNALS 16dnl MH_CHECK_OSX_ARCH 17dnl MH_GET_DISTRO_NAME 18dnl MH_CHECK_RPM 19dnl MH_CHECK_ARCH 20dnl AC_DEFINE_DIR 21 22dnl --------------------------------------------------------------------------- 23dnl Determine if the system has System V IPC. ie sys/ipc.h and sys/shm.h 24dnl headers. 25dnl --------------------------------------------------------------------------- 26AC_DEFUN([MH_IPC], 27[ 28AC_CHECK_HEADER(sys/ipc.h) 29if test $ac_cv_header_sys_ipc_h = no; then 30 AC_MSG_ERROR(Cannot find required header file sys/ipc.h; PDCurses cannot be configured) 31fi 32])dnl 33 34dnl --------------------------------------------------------------------------- 35dnl Set up the correct X header file location 36dnl --------------------------------------------------------------------------- 37AC_DEFUN([MH_CHECK_X_INC], 38[ 39mh_x11_dir="" 40mh_x11_xaw_dir="" 41 42mh_inc_dirs="$ac_x_header_dirs" 43 44dnl Provide for user supplying directory 45 46if test "x$x_includes" != xNONE ; then 47 mh_inc_dirs="$x_includes $mh_inc_dirs" 48fi 49 50dnl Try to determine the directory containing X headers 51dnl We will append X11 to all the paths above as an extra check 52 53for ac_dir in $mh_inc_dirs ; do 54 if test -r $ac_dir/Intrinsic.h; then 55 mh_x11_dir=$ac_dir 56 break 57 fi 58 if test -r $ac_dir/X11/Intrinsic.h; then 59 mh_x11_dir="$ac_dir/X11" 60 break 61 fi 62done 63 64dnl Try to determine the directory containing Xaw headers 65dnl We will append X11 to all the paths above as an extra check 66 67if test "$with_xaw3d" = yes; then 68 mh_xaw_dir="Xaw3d" 69else 70 if test "$with_nextaw" = yes; then 71 mh_xaw_dir="neXtaw" 72 else 73 mh_xaw_dir="Xaw" 74 fi 75fi 76for ac_dir in $mh_inc_dirs ; do 77 if test -r $ac_dir/$mh_xaw_dir/Box.h; then 78 mh_x11_xaw_dir=$ac_dir 79 break 80 fi 81 if test -r $ac_dir/X11/$mh_xaw_dir/Box.h; then 82 mh_x11_xaw_dir="$ac_dir/X11" 83 break 84 fi 85done 86 87if test "x$mh_x11_dir" != "x" ; then 88 mh_x11_dir_no_x11=`echo $mh_x11_dir | sed 's/\/X11$//'` 89 90 if test "$mh_x11_dir_no_x11" != "$mh_x11_dir" ; then 91 MH_XINC_DIR="-I$mh_x11_dir -I$mh_x11_dir_no_x11" 92 else 93 MH_XINC_DIR="-I$mh_x11_dir" 94 fi 95else 96 AC_MSG_ERROR(Cannot find required header file Intrinsic.h; PDCurses cannot be configured) 97fi 98 99if test "x$mh_x11_xaw_dir" != "x"; then 100 if test "$mh_x11_xaw_dir" != "$mh_x11_dir" ; then 101 MH_XINC_DIR="-I$mh_x11_xaw_dir $MH_XINC_DIR" 102 fi 103else 104 AC_MSG_ERROR(Cannot find required Xaw header file Box.h; PDCurses cannot be configured) 105fi 106 107AC_SUBST(MH_XINC_DIR) 108 109])dnl 110 111dnl --------------------------------------------------------------------------- 112dnl Set up the correct X library file location 113dnl --------------------------------------------------------------------------- 114AC_DEFUN([MH_CHECK_X_LIB], 115[ 116dnl Some systems require extra libraries... 117 118mh_solaris_flag=no 119mh_hpux9_flag=no 120AC_REQUIRE([AC_CANONICAL_SYSTEM]) 121case "$target" in 122 *solaris*) 123 mh_solaris_flag=yes 124 ;; 125 *pc-sco*) 126 extra_x_libs="Xext" 127 ;; 128 sparc*sunos*) 129 extra_x_libs="Xext" 130 if test "$ac_cv_prog_CC" = "gcc" ; then 131 extra_ld_flags="-Wl,-Bstatic" 132 extra_ld_flags2="-Wl,-Bdynamic" 133 else 134 extra_ld_flags="-Bstatic" 135 extra_ld_flags2="-Bdynamic" 136 fi 137 ;; 138 *hpux9*) 139 mh_hpux9_flag=yes 140 ;; 141esac 142 143if test "$with_xaw3d" = yes; then 144 MH_X11_LIBS="Xaw3d Xmu Xt X11" 145else 146 if test "$with_nextaw" = yes; then 147 MH_X11_LIBS="neXtaw Xmu Xt X11" 148 else 149 MH_X11_LIBS="Xaw Xmu Xt X11" 150 fi 151fi 152MH_X11R6_LIBS="SM ICE Xext" 153mh_x11r6=no 154 155which dpkg-architecture > /dev/null 156if test $? -eq 0; then 157 multiarch_libdir="/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`" 158else 159 multiarch_libdir="" 160fi 161 162mh_lib_dirs="$multiarch_libdir /usr/lib64 /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu $x_libraries `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`" 163 164dnl try to find libSM.[a,sl,so,dylib]. If we find it we are using X11R6 165for ac_dir in $mh_lib_dirs ; do 166 for mh_xsm in libSM.a libSM.so libSM.sl libSM.dylib; do 167 if test -r $ac_dir/$mh_xsm; then 168 mh_x11r6=yes 169 break 2 170 fi 171 done 172done 173 174if test "$mh_x11r6" = yes ; then 175 mh_libs="$MH_X11_LIBS $MH_X11R6_LIBS" 176else 177 mh_libs="$MH_X11_LIBS $extra_x_libs" 178fi 179 180 181dnl Ensure that all required X libraries are found 182 183mh_prev_dir="" 184mh_where_found="" 185mh_where_found_dirs="" 186mh_solaris_path="" 187for mh_lib in $mh_libs; do 188 mh_lib_found=no 189 for ac_dir in $mh_lib_dirs ; do 190 for mh_ext in a so sl dll.a dylib; do 191 if test -r $ac_dir/lib$mh_lib.$mh_ext; then 192 if test "x$mh_prev_dir" != "x$ac_dir" ; then 193 if test "x$mh_prev_dir" = "x" ; then 194 mh_where_found="$mh_where_found found in $ac_dir" 195 else 196 mh_where_found="$mh_where_found and in $ac_dir" 197 fi 198 mh_prev_dir=$ac_dir 199 mh_where_found_dirs="$mh_where_found_dirs $ac_dir" 200 MH_XLIBS="$MH_XLIBS -L$ac_dir" 201 mh_solaris_path="${mh_solaris_path}:$ac_dir" 202 fi 203 MH_XLIBS="$MH_XLIBS -l$mh_lib" 204 mh_lib_found=yes 205 break 2 206 fi 207 done 208 done 209 if test "$mh_lib_found" = no; then 210 AC_MSG_ERROR(Cannot find required X library; lib$mh_lib. PDCurses cannot be configured) 211 fi 212done 213 214mh_solaris_path=`echo $mh_solaris_path | sed 's/^://'` 215if test "$mh_solaris_flag" = yes ; then 216 MH_XLIBS="-R$mh_solaris_path $extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2" 217else 218 MH_XLIBS="$extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2" 219fi 220if test "$mh_hpux9_flag" = yes ; then 221 grep -q XtSetLanguageProc $mh_x11_dir/Intrinsic.h 222 if test $? -eq 0 ; then 223 mh_found_xtshellstrings=no 224 for mh_acdir in $mh_where_found_dirs ; do 225 for mh_xaw in `ls $mh_acdir/libXaw.*` ; do 226 nm $mh_xaw | grep XtShellStrings | grep -qv extern 227 if test $? -eq 0 ; then 228 mh_found_xtshellstrings=yes 229 fi 230 done 231 done 232 if test "$mh_found_xtshellstrings" = no ; then 233 AC_MSG_WARN(The X11 development environment has not been installed correctly.) 234 AC_MSG_WARN(The header file; Intrinsic.h, is for X11R5 while the Athena Widget) 235 AC_MSG_WARN(Set library; libXaw is for X11R4. This is a common problem with) 236 AC_MSG_WARN(HP-UX 9.x.) 237 AC_MSG_ERROR(X11 installation incomplete; cannot continue) 238 fi 239 fi 240fi 241 242AC_SUBST(MH_XLIBS) 243 244])dnl 245 246dnl --------------------------------------------------------------------------- 247dnl Determine if the supplied X headers exist. 248dnl --------------------------------------------------------------------------- 249AC_DEFUN([MH_CHECK_X_HEADERS], 250[ 251save_CPPFLAGS="$CPPFLAGS" 252CPPFLAGS="$CPPFLAGS $MH_XINC_DIR" 253for mh_header in $1; do 254 AC_CHECK_HEADERS($mh_header) 255done 256CPPFLAGS="$save_CPPFLAGS" 257])dnl 258 259dnl --------------------------------------------------------------------------- 260dnl Determine if various key definitions exist in keysym.h 261dnl --------------------------------------------------------------------------- 262AC_DEFUN([MH_CHECK_X_KEYDEFS], 263[ 264save_CPPFLAGS="$CPPFLAGS" 265CPPFLAGS="$CPPFLAGS $MH_XINC_DIR" 266for mh_keydef in $1; do 267 AC_MSG_CHECKING(for $mh_keydef in keysym.h) 268 mh_upper_name="HAVE_`echo $mh_keydef | tr '[a-z]' '[A-Z]'`" 269 AC_TRY_COMPILE([#include <keysym.h>], 270[int i = $mh_keydef;], 271 mh_have_key=yes; AC_DEFINE_UNQUOTED($mh_upper_name,1), mh_have_key=no ) 272 AC_MSG_RESULT($mh_have_key) 273done 274CPPFLAGS="$save_CPPFLAGS" 275])dnl 276 277dnl --------------------------------------------------------------------------- 278dnl Determine if supplied types have been typedefed 279dnl --------------------------------------------------------------------------- 280AC_DEFUN([MH_CHECK_X_TYPEDEF], 281[ 282save_CPPFLAGS="$CPPFLAGS" 283CPPFLAGS="$CPPFLAGS $SYS_DEFS $MH_XINC_DIR" 284for td in $1 ; do 285AC_MSG_CHECKING(if $td is typedefed:) 286AC_TRY_COMPILE( 287[#include "X11/Xlib.h"], 288[$td fred], 289 [mh_td=yes], 290 [mh_td=no] 291) 292if test "$mh_td" = yes ; then 293 TD_upper=`echo $td | tr a-z A-Z` 294 AC_DEFINE_UNQUOTED(${TD_upper}_TYPEDEFED, 1) 295fi 296AC_MSG_RESULT($mh_td) 297done 298CPPFLAGS="$save_CPPFLAGS" 299])dnl 300 301dnl --------------------------------------------------------------------------- 302dnl Check for presence of various libraries 303dnl --------------------------------------------------------------------------- 304AC_DEFUN([MH_CHECK_LIB], 305[ 306MH_EXTRA_LIBS='' 307for mh_lib in $1; do 308 if test "$on_qnx" = yes; then 309 AC_MSG_CHECKING(for library -l${mh_lib}) 310 if test -r /usr/lib/${mh_lib}3r.lib; then 311 AC_MSG_RESULT(found) 312 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}" 313 else 314 AC_MSG_RESULT(not found) 315 fi 316 else 317 AC_CHECK_LIB($mh_lib,main,mh_lib_found=yes,mh_lib_found=no) 318 if test "$mh_lib_found" = yes; then 319 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}" 320 fi 321 fi 322done 323])dnl 324 325dnl --------------------------------------------------------------------------- 326dnl Work out how to create a dynamically loaded module 327dnl --------------------------------------------------------------------------- 328AC_DEFUN([MH_HOWTO_DYN_LINK], 329[ 330mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&AC_FD_CC' 331cat > conftest.$ac_ext <<EOF 332dnl [#]line __oline__ "[$]0" 333[#]line __oline__ "configure" 334int foo() 335{ 336return(0); 337} 338EOF 339if AC_TRY_EVAL(mh_compile) && test -s conftest.o; then 340 mh_dyn_link='ld -shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC' 341# mh_dyn_link='${CC} -Wl,-shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC' 342 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then 343 LD_RXLIB1="ld -shared" 344# LD_RXLIB1="${CC} -Wl,-shared" 345 SHLPRE="lib" 346 SHLPST=".so" 347 else 348 mh_dyn_link='ld -G -o conftest.rxlib conftest.o 1>&AC_FD_CC' 349# mh_dyn_link='${CC} -Wl,-G -o conftest.rxlib conftest.o 1>&AC_FD_CC' 350 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then 351 LD_RXLIB1="ld -G" 352# LD_RXLIB1="${CC} -Wl,-G" 353 SHLPRE="lib" 354 SHLPST=".so" 355 else 356 LD_RXLIB1="" 357 SHLPRE="" 358 SHLPST="" 359 fi 360 fi 361fi 362rm -f conftest* 363])dnl 364 365dnl --------------------------------------------------------------------------- 366dnl Determine how to build shared libraries etc.. 367dnl --------------------------------------------------------------------------- 368AC_DEFUN([MH_SHARED_LIBRARY], 369[ 370AC_REQUIRE([MH_SHLPST]) 371dnl 372dnl If compiler is gcc, then flags should be the same for all platforms 373dnl (just guessing on this) 374dnl 375AIX_DYN="no" 376BEOS_DYN="no" 377SHLFILE="$1" 378SHLFILES="$*" 379RXPACKEXPORTS="" 380SHLPRE="lib" 381LD_RXLIB1="" 382BASE_INSTALL="installbase" 383BASE_BINARY="binarybase" 384# OTHER_INSTALLS is set to install a non-version numbered shared library 385# by default; ie. no .\$(ABI) suffix. Set OTHER_INSTALLS="installabilib" if you 386# are building a version numbered shared library. 387OTHER_INSTALLS="installlib" 388 389AC_REQUIRE([AC_CANONICAL_SYSTEM]) 390case "$target" in 391 *hp-hpux*) 392 SYS_DEFS="-D_HPUX_SOURCE" 393 LD_RXLIB1="ld -b -q -n" 394 ;; 395 *ibm-aix*) 396 SYS_DEFS="-D_ALL_SOURCE -DAIX" 397 AIX_DYN="yes" 398 DYN_COMP="-DDYNAMIC" 399 LD_RXLIB1="ld -bnoentry -bM:SRE" 400 RXPACKEXPORTS="-bE:$SHLFILE.exp" 401 RXPACKEXP="$SHLFILE.exp" 402 ;; 403 *dec-osf*) 404 if test "$ac_cv_prog_CC" = "gcc"; then 405 SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE" 406 else 407 SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800" 408 fi 409 LD_RXLIB1="ld -shared" 410 ;; 411 *sequent-dynix*|*esix*|*dgux*) 412 LD_RXLIB1="ld -G" 413 ;; 414 *solaris*) 415 if test "$ac_cv_prog_CC" = "gcc"; then 416 LD_RXLIB1="gcc -shared" 417 else 418 LD_RXLIB1="ld -G" 419 fi 420 ;; 421 sparc*sunos*) 422 SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG" 423 LD_RXLIB1="ld" 424 ;; 425 *atheos*|*nto-qnx*) 426 LD_RXLIB1="${CC} -shared" 427 ;; 428 *linux*|*kfreebsd*-gnu*) 429 LD_RXLIB1="${CC} -shared -Wl,-soname,\$(@)" 430 CAN_USE_ABI="yes" 431 if test "$USE_ABI" = "yes"; then 432 OTHER_INSTALLS="installabilib" 433 fi 434 ;; 435 *freebsd*) 436 LD_RXLIB1="ld -Bdynamic -Bshareable" 437 ;; 438 *pc-sco*) 439 LD_RXLIB1="ld -dy -G" 440 ;; 441 *beos*) 442 LD_RXLIB1="${CC} -Wl,-shared -nostart -Xlinker -soname=\$(@)" 443 BEOS_DYN="yes" 444 ;; 445 *qnx*) 446 SHLPRE="" 447 DYN_COMP="-Q" # force no check for dynamic loading 448 SHLFILE="" 449 ;; 450 *cygwin) 451 SHLPRE="" 452 DYN_COMP="-DDYNAMIC" 453 LD_RXLIB1="dllwrap --def \$(srcdir)/../win32/pdcurses.def --target i386-cygwin32 --dllname \$(@)" 454# cygwininstall target MUST install the shared library itself because 455# it puts it into $(bindir) not $(libdir) as all other platforms 456 ;; 457 *darwin*) 458 DYN_COMP="-fno-common" 459 LD_RXLIB1="${CC} -flat_namespace -undefined suppress -dynamiclib -install_name=\$(@)" 460 ;; 461 *) 462 ;; 463esac 464 465dnl determine what switches our compiler uses for building objects 466dnl suitable for inclusion in shared libraries 467dnl Only call this if DYN_COMP is not set. If we have set DYN_COMP 468dnl above, then we know how to compile AND link for dynamic libraries 469 470if test "$DYN_COMP" = ""; then 471AC_MSG_CHECKING(compiler flags for a dynamic object) 472 473cat > conftest.$ac_ext <<EOF 474dnl [#]line __oline__ "[$]0" 475[#]line __oline__ "configure" 476int a=0 477EOF 478 479 DYN_COMP="" 480 mh_cv_stop=no 481 save_cflags="$CFLAGS" 482 mh_cv_flags="-fPIC -KPIC +Z" 483 for a in $mh_cv_flags; do 484 CFLAGS="-c $a" 485 486 mh_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext > conftest.tmp 2>&1' 487 if AC_TRY_EVAL(mh_compile); then 488 DYN_COMP="" 489 else 490 slash="\\" 491 mh_dyncomp="`egrep -c $slash$a conftest.tmp`" 492 if test "$mh_dyncomp" = "0"; then 493 DYN_COMP="$a -DDYNAMIC" 494 AC_MSG_RESULT($a) 495 break 496 else 497 DYN_COMP="" 498 fi 499 fi 500 done 501 if test "$DYN_COMP" = ""; then 502 AC_MSG_RESULT(none of $mh_cv_flags supported) 503 fi 504 if test "$LD_RXLIB1" = ""; then 505 MH_HOWTO_DYN_LINK() 506 fi 507 CFLAGS=$save_cflags 508 rm -f conftest.* 509fi 510 511 512SHL_TARGETS="" 513 514if test "$AIX_DYN" = "yes"; then 515 aix_exports="config.exports.aix" 516 echo "" > $aix_exports 517fi 518 519if test "$ac_cv_header_dl_h" = "yes" -o "$ac_cv_header_dlfcn_h" = "yes" -o "$AIX_DYN" = "yes" -o "$BEOS_DYN" = "yes" -o "$DLFCNINCDIR" != "" -o "$DLFCNLIBDIR" != ""; then 520 EXPS="1,2,3,4,5,6,7,8,9" 521 for a in $SHLFILES 522 do 523 if test "$USE_ABI" = "yes" -a "$CAN_USE_ABI" = "yes"; then 524 SHL_TARGETS="${SHL_TARGETS} ${SHLPRE}${a}${SHLPST}.\$(ABI)" 525 else 526 SHL_TARGETS="${SHL_TARGETS} ${SHLPRE}${a}${SHLPST}" 527 fi 528 this=`echo $EXPS | cut -d, -f1` 529 EXPS=`echo $EXPS | cut -d, -f2-` 530 if test "$AIX_DYN" = "yes"; then 531 echo "RXPACKEXP$this=$a.exp" >> $aix_exports 532 echo "RXPACKEXPORTS$this=-bE:$a.exp" >> $aix_exports 533 fi 534 done 535fi 536 537AC_SUBST(DYN_COMP) 538AC_SUBST(LIBS) 539AC_SUBST(LD_RXLIB1) 540AC_SUBST(SHLPRE) 541AC_SUBST(SHLPST) 542AC_SUBST(SHL_TARGETS) 543AC_SUBST(O2SAVE) 544AC_SUBST(CC2O) 545AC_SUBST(SAVE2O) 546AC_SUBST(RXPACKEXPORTS) 547AC_SUBST(BASE_INSTALL) 548AC_SUBST(OTHER_INSTALLS) 549AC_SUBST(BASE_BINARY) 550AC_SUBST(CAN_USE_ABI) 551])dnl 552 553dnl --------------------------------------------------------------------------- 554dnl Check if C compiler supports -c -o file.ooo 555dnl --------------------------------------------------------------------------- 556AC_DEFUN([MH_CHECK_CC_O], 557[ 558AC_MSG_CHECKING(whether $CC understand -c and -o together) 559set dummy $CC; ac_cc="`echo [$]2 | 560changequote(, )dnl 561 sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`" 562changequote([, ])dnl 563AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o, 564[echo 'foo(){}' > conftest.c 565# We do the test twice because some compilers refuse to overwrite an 566# existing .o file with -o, though they will create one. 567eval ac_cv_prog_cc_${ac_cc}_c_o=no 568ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC' 569if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try); 570then 571 ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC' 572 if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try); 573 then 574 eval ac_cv_prog_cc_${ac_cc}_c_o=yes 575 fi 576fi 577rm -f conftest* 578])dnl 579if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then 580 O2SAVE="" 581 SAVE2O="" 582 CC2O="-o $"'@' 583 AC_MSG_RESULT(yes) 584else 585 O2SAVE="-mv \`basename "$'@'" .sho\`.o \`basename "$'@'" .sho\`.o.save;" 586 SAVE2O="-mv \`basename "$'@'" .sho\`.o "$'@'"; mv \`basename "$'@'" .sho\`.o.save \`basename "$'@'" .sho\`.o" 587 CC2O="" 588 AC_MSG_RESULT(no) 589fi 590]) 591 592dnl --------------------------------------------------------------------------- 593dnl Determines the file extension for shared libraries 594dnl --------------------------------------------------------------------------- 595AC_DEFUN([MH_SHLPST], 596[ 597AC_MSG_CHECKING(shared library extension) 598SHLPST=".so" 599AC_REQUIRE([AC_CANONICAL_SYSTEM]) 600case "$target" in 601 *hp-hpux*) 602 SHLPST=".sl" 603 ;; 604 *ibm-aix*) 605 SHLPST=".a" 606 ;; 607 *qnx*) 608 SHLPST="" 609 ;; 610 *cygwin*) 611 SHLPST=".dll" 612 ;; 613 *darwin*) 614 SHLPST=".dylib" 615 ;; 616esac 617AC_SUBST(SHLPST) 618AC_MSG_RESULT($SHLPST) 619]) 620 621dnl --------------------------------------------------------------------------- 622dnl Determine the system limit for number of signals 623dnl --------------------------------------------------------------------------- 624AC_DEFUN([MH_CHECK_MAX_SIGNALS], 625[ 626save_CPPFLAGS="$CPPFLAGS" 627CPPFLAGS="$CPPFLAGS $SYS_DEFS" 628AC_MSG_CHECKING(for maximum signal specifier:) 629AC_CACHE_VAL(mh_cv_max_signals, 630mh_found="no" 631for mh_sigs in $1; do 632 AC_TRY_COMPILE([#include <signal.h>], 633[return $mh_sigs;], 634 mh_found="yes"; mh_cv_max_signals="$mh_sigs" ) 635 if test "$mh_found" = "yes"; then 636 break; 637 fi 638done) 639CPPFLAGS="$save_CPPFLAGS" 640if test "$mh_found" = "no"; then 641 AC_MSG_ERROR(Cannot find a system limit for number of signals. PDCurses cannot be configured on this machine.) 642else 643 AC_DEFINE_UNQUOTED(PDC_MAX_SIGNALS,$mh_cv_max_signals) 644 AC_MSG_RESULT($mh_cv_max_signals) 645fi 646])dnl 647 648dnl --------------------------------------------------------------------------- 649dnl Determines which -arch flags valid on Mac OSX with gcc 650dnl --------------------------------------------------------------------------- 651AC_DEFUN([MH_CHECK_OSX_ARCH], 652[ 653valid_arch_flags="" 654found_arch_flags="" 655AC_ARG_WITH(arch, 656 [ --with-arch=option build universal binaries on OS X, option: one of "all 32bit 64bit intel ppc ppc64 x86_64 i386"], 657 [with_arch=$withval], 658 [with_arch=none], 659) 660case "$with_arch" in 661 none) 662 arch_flags="" 663 ;; 664 all) 665 arch_flags="-arch ppc -arch ppc64 -arch x86_64 -arch i386" 666 ;; 667 32bit) 668 arch_flags="-arch ppc -arch i386" 669 ;; 670 64bit) 671 arch_flags="-arch ppc64 -arch x86_64" 672 ;; 673 intel) 674 arch_flags="-arch i386 -arch x86_64" 675 ;; 676 *) 677 arch_flags="-arch $with_arch" 678 ;; 679esac 680 681valid_arch_flags="" 682found_arch_flags="" 683if test $on_osx = "yes"; then 684 AC_MSG_CHECKING(for which Mac OSX -arch flags are supported for universal binaries) 685 for a in $arch_flags; do 686 save_ldflags="$LDFLAGS" 687 LDFLAGS="$LDFLAGS -arch $a" 688 AC_LINK_IFELSE( 689 [AC_LANG_PROGRAM([#include <stdio.h>], 690 [exit(0)])], 691 [valid_arch_flags="$valid_arch_flags -arch $a";found_arch_flags="$found_arch_flags $a"], 692 [a="$a"] 693 ) 694 LDFLAGS="$save_ldflags" 695 done 696 AC_MSG_RESULT($found_arch_flags) 697 AC_SUBST(valid_arch_flags) 698fi 699]) 700 701dnl --------------------------------------------------------------------------- 702dnl Determines the Linux distribution name 703dnl --------------------------------------------------------------------------- 704AC_DEFUN([MH_GET_DISTRO_NAME], 705[ 706AC_CHECK_PROG(lsb_release, [lsb_release], yes, no) 707if test "$ac_cv_prog_lsb_release" = yes; then 708 AC_MSG_CHECKING(OS distribution name) 709 MYDISTRO="`lsb_release -i | cut -f 2`-`lsb_release -r | cut -f 2`" 710 MYDISTRO="`echo $MYDISTRO | sed \"s/ /_/g\"`" 711 AC_MSG_RESULT($MYDISTRO) 712else 713 case "$target" in 714 *freebsd* | *openbsd*) 715 MYDISTRO="`echo $target | cut -f3 -d-`" 716 ;; 717 *darwin*) 718 MYDISTRO="`echo $target | cut -f2-3 -d-`" 719 ;; 720 *pc-solaris2*) 721 MYDISTRO="`echo $target | cut -f2- -d-`" 722 ;; 723 *cygwin*) 724 MYDISTRO="`echo $target | cut -f2- -d-`" 725 ;; 726 *) 727 MYDISTRO="$target" 728 ;; 729 esac 730fi 731AC_SUBST(MYDISTRO) 732]) 733 734dnl --------------------------------------------------------------------------- 735dnl Determines where rpm build files are located 736dnl --------------------------------------------------------------------------- 737AC_DEFUN([MH_CHECK_RPM], 738[ 739AC_CHECK_PROG(mh_rpm_exists, rpm, yes, no ) 740if test "$mh_rpm_exists" = yes; then 741 AC_MSG_CHECKING(where rpms are built) 742 RPMTOPDIR=`rpm --eval "%{_topdir}"` 743 AC_MSG_RESULT($RPMTOPDIR) 744 AC_SUBST(RPMTOPDIR) 745fi 746]) 747 748dnl 749dnl Determine if the platform can handle 64 bit binaries 750dnl 751dnl Assumes AC_CANONICAL_SYSTEM has already been called 752dnl assumes we are on a 32bit system 753 754AC_DEFUN([MH_CHECK_ARCH], 755[ 756dnl ---------------------- check 32/64 bit ----------------------- 757dnl allow --with-32bit to ensure that 32bit libraries are used 758AC_ARG_ENABLE(32bit, 759 [ --enable-32bit specify if 32bit libraries are to be used], 760 [bitflag32=yes], 761 [bitflag32=no], 762) 763dnl allow --with-64bit to ensure that 64bit libraries are used 764AC_ARG_ENABLE(64bit, 765 [ --enable-64bit specify if 64bit libraries are to be used], 766 [bitflag64=yes], 767 [bitflag64=no], 768) 769 770# 771# Now do platform specific tests 772# 773gcc_64bit="-m64" 774gcc_32bit="-m32" 775on_osx="no" 776osis64bit=no 777bitflag="" 778case "$target" in 779 *hp-hpux*) 780 ;; 781 *ibm-aix*) 782 rc=`lsconf -k | grep -c 64-bit` 783 if test $rc -eq 1; then 784 bitflag="64" 785 osis64bit=yes 786 fi 787 # 788 # AIX gcc has its own special bit switches :-( 789 # 790 gcc_64bit="-maix64" 791 gcc_32bit="-maix32" 792 ;; 793 *dec-osf4*) 794 ;; 795 *dec-osf*) 796 ;; 797 *sequent-dynix*) 798 ;; 799 i*86*solaris*) 800 ;; 801 *solaris*) 802 rc=`isainfo -v | grep -c 64-bit` 803 if test $rc -eq 1; then 804 bitflag="64" 805 osis64bit=yes 806 fi 807 ;; 808 sparc*sunos*) 809 ;; 810 *linux*|*kfreebsd*-gnu*) 811 mach="`uname -m`" 812 if test "$mach" = "x86_64" -o "$mach" = "ia86" -o "$mach" = "alpha" -o "$mach" = "ppc64" -o "$mach" = "s390x"; then 813 bitflag="64" 814 osis64bit=yes 815 fi 816 ;; 817 *-freebsd*) 818 mach="`uname -m`" 819 if test "$mach" = "amd64"; then 820 bitflag="64" 821 osis64bit=yes 822 fi 823 ;; 824 *nto-qnx*) 825 ;; 826 *qnx*) 827 ;; 828 *beos*) 829 ;; 830 *cygwin*) 831 ;; 832 *apple-darwin*) 833 on_osx="yes" 834 osx_64bit=`sysctl hw.cpu64bit_capable | cut -f2 -d' '` 835 if test $osx_64bit -eq 1; then 836 bitflag="64" 837 osis64bit=yes 838 fi 839 ;; 840esac 841 842if test "x$bitflag32" = "xyes" -a "x$bitflag64" = "xyes"; then 843 AC_MSG_ERROR(--enable-32bit and --enable-64bit flags cannot both be specified.) 844fi 845 846if test "x$bitflag64" = "xyes" -a "$osis64bit" = "no"; then 847 AC_MSG_ERROR(--enable-64bit cannot be specified on non-64bit OS.) 848fi 849 850binarybitprefix="" 851if test "x$bitflag32" = "xyes"; then 852 bitflag="32" 853 if test "$osis64bit" = "yes"; then 854 binarybitprefix="32" 855 fi 856elif test "x$bitflag64" = "xyes"; then 857 bitflag="64" 858fi 859MACH_ARCH=`$ac_config_guess | cut -f1 -d-` 860AC_SUBST(MACH_ARCH) 861dnl 862dnl following variable used to name 32bit binaries on a 64bit system 863dnl allows 32bit and 64bit binaries t co-exist on a 64bit system 864AC_SUBST(binarybitprefix) 865 866dnl --------------- allow --with-arch to specify which architectures to build universal binaries 867dnl 868if test "$on_osx" = "yes"; then 869 MH_CHECK_OSX_ARCH() 870else 871dnl 872dnl Now set the correct compiler flags 873dnl 874 if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then 875 if test "$bitflag" = "32"; then 876 CFLAGS="${CFLAGS} $gcc_32bit" 877 LDFLAGS="${LDFLAGS} $gcc_32bit" 878 elif test "$bitflag" = "64"; then 879 CFLAGS="${CFLAGS} $gcc_64bit" 880 LDFLAGS="${LDFLAGS} $gcc_64bit" 881 else 882 bitflag="32" 883 fi 884 elif test "$ac_cv_prog_CC" = "xlc" -o "$ac_cv_prog_CC" = "xlC"; then 885 if test "$bitflag" = "32"; then 886 CFLAGS="${CFLAGS} -q32" 887 LDFLAGS="${LDFLAGS} -q32" 888 elif test "$bitflag" = "64"; then 889 CFLAGS="${CFLAGS} -q64" 890 LDFLAGS="${LDFLAGS} -q64" 891 else 892 bitflag="32" 893 fi 894 fi 895fi 896 897dnl allow --disable-libdir-change to ensure that building a .deb works 898#libdir_change=yes 899AC_ARG_ENABLE(libdir-change, 900 [ --enable-libdir-change specify --disable-libdir-change if building a .deb], 901 [libdir_change=$enableval], 902 [libdir_change=yes], 903) 904echo "libdir: $libdir_change" 905if test "$libdir_change" = yes; then 906 dnl 907 dnl If the user hasn't specified libdir, check for specific lib dirs 908 dnl 909 if test "${libdir}" = '${exec_prefix}/lib'; then 910 dnl 911 dnl expand the active $prefix 912 dnl 913 myprefix=$prefix 914 AC_DEFINE_DIR(MY_PREFIX,"$myprefix") 915 if test "${myprefix}" = "NONE"; then 916 myprefix="$ac_default_prefix" 917 fi 918 dnl 919 dnl check for 64bit libdir 920 dnl 921 if test -d "${myprefix}/lib/x86_64-linux-gnu"; then 922 libdir64="${myprefix}/lib/x86_64-linux-gnu" 923 elif test -d "${myprefix}/lib64"; then 924 libdir64="${myprefix}/lib64" 925 else 926 libdir64="${myprefix}/lib" 927 fi 928 dnl 929 dnl check for 32bit libdir 930 dnl 931 if test -d "${myprefix}/lib/i386-linux-gnu"; then 932 libdir32="${myprefix}/lib/i386-linux-gnu" 933 elif test -d "${myprefix}/lib32"; then 934 libdir32="${myprefix}/lib32" 935 else 936 libdir32="${myprefix}/lib" 937 fi 938 dnl 939 dnl Depending on the build type, set the default libdir 940 dnl 941 if test "$bitflag" = "64"; then 942 libdir="$libdir64" 943 else 944 libdir="$libdir32" 945 fi 946 else 947 libdir64="$libdir" 948 libdir32="$libdir" 949 fi 950else 951 libdir64="$libdir" 952 libdir32="$libdir" 953fi 954AC_SUBST(libdir64) 955AC_SUBST(libdir32) 956AC_SUBST(bitflag) 957]) 958dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) 959dnl 960dnl This macro sets VARNAME to the expansion of the DIR variable, 961dnl taking care of fixing up ${prefix} and such. 962dnl 963dnl VARNAME is then offered as both an output variable and a C 964dnl preprocessor symbol. 965dnl 966dnl Modified by Mark Hessling to fix eval bug 967dnl 968dnl Example: 969dnl 970dnl AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) 971dnl 972dnl @category Misc 973dnl @author Stepan Kasal <kasal@ucw.cz> 974dnl @author Andreas Schwab <schwab@suse.de> 975dnl @author Guido U. Draheim <guidod@gmx.de> 976dnl @author Alexandre Oliva 977dnl @version 2006-10-13 978dnl @license AllPermissive 979 980AC_DEFUN([AC_DEFINE_DIR], [ 981 prefix_NONE= 982 exec_prefix_NONE= 983 test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix 984 test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix 985dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn 986dnl refers to ${prefix}. Thus we have to use `eval' twice. 987 eval ac_define_dir="\"$2\"" 988 eval ac_define_dir="\"$ac_define_dir\"" 989 AC_SUBST($1, "$ac_define_dir") 990 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) 991 test "$prefix_NONE" && prefix=NONE 992 test "$exec_prefix_NONE" && exec_prefix=NONE 993]) 994 995