1 dnl ---------------------------------------------------------------------------
2 dnl This file offers the following macros...
3 dnl ---------------------------------------------------------------------------
15 dnl MH_CHECK_MAX_SIGNALS
17 dnl ---------------------------------------------------------------------------
18 dnl Determine if the system has System V IPC. ie sys/ipc.h and sys/shm.h
20 dnl ---------------------------------------------------------------------------
23 AC_CHECK_HEADER(sys/ipc.h)
24 if test $ac_cv_header_sys_ipc_h = no; then
25 AC_MSG_ERROR(Cannot find required header file sys/ipc.h; PDCurses cannot be configured)
29 dnl ---------------------------------------------------------------------------
30 dnl Set up the correct X header file location
31 dnl ---------------------------------------------------------------------------
32 AC_DEFUN([MH_CHECK_X_INC],
37 mh_inc_dirs="$ac_x_header_dirs"
39 dnl Provide for user supplying directory
41 if test "x$x_includes" != xNONE ; then
42 mh_inc_dirs="$x_includes $mh_inc_dirs"
45 dnl Try to determine the directory containing X headers
46 dnl We will append X11 to all the paths above as an extra check
48 for ac_dir in $mh_inc_dirs ; do
49 if test -r $ac_dir/Intrinsic.h; then
53 if test -r $ac_dir/X11/Intrinsic.h; then
54 mh_x11_dir="$ac_dir/X11"
59 dnl Try to determine the directory containing Xaw headers
60 dnl We will append X11 to all the paths above as an extra check
62 if test "$with_xaw3d" = yes; then
65 if test "$with_nextaw" = yes; then
71 for ac_dir in $mh_inc_dirs ; do
72 if test -r $ac_dir/$mh_xaw_dir/Box.h; then
73 mh_x11_xaw_dir=$ac_dir
76 if test -r $ac_dir/X11/$mh_xaw_dir/Box.h; then
77 mh_x11_xaw_dir="$ac_dir/X11"
82 if test "x$mh_x11_dir" != "x" ; then
83 mh_x11_dir_no_x11=`echo $mh_x11_dir | sed 's/\/X11$//'`
85 if test "$mh_x11_dir_no_x11" != "$mh_x11_dir" ; then
86 MH_XINC_DIR="-I$mh_x11_dir -I$mh_x11_dir_no_x11"
88 MH_XINC_DIR="-I$mh_x11_dir"
91 AC_MSG_ERROR(Cannot find required header file Intrinsic.h; PDCurses cannot be configured)
94 if test "x$mh_x11_xaw_dir" != "x"; then
95 if test "$mh_x11_xaw_dir" != "$mh_x11_dir" ; then
96 MH_XINC_DIR="-I$mh_x11_xaw_dir $MH_XINC_DIR"
99 AC_MSG_ERROR(Cannot find required Xaw header file Box.h; PDCurses cannot be configured)
102 AC_SUBST(MH_XINC_DIR)
106 dnl ---------------------------------------------------------------------------
107 dnl Set up the correct X library file location
108 dnl ---------------------------------------------------------------------------
109 AC_DEFUN([MH_CHECK_X_LIB],
111 dnl Some systems require extra libraries...
115 AC_REQUIRE([AC_CANONICAL_SYSTEM])
125 if test "$ac_cv_prog_CC" = "gcc" ; then
126 extra_ld_flags="-Wl,-Bstatic"
127 extra_ld_flags2="-Wl,-Bdynamic"
129 extra_ld_flags="-Bstatic"
130 extra_ld_flags2="-Bdynamic"
138 if test "$with_xaw3d" = yes; then
139 MH_X11_LIBS="Xaw3d Xmu Xt X11"
141 if test "$with_nextaw" = yes; then
142 MH_X11_LIBS="neXtaw Xmu Xt X11"
144 MH_X11_LIBS="Xaw Xmu Xt X11"
147 MH_X11R6_LIBS="SM ICE Xext"
150 mh_lib_dirs="$x_libraries `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`"
152 dnl try to find libSM.[a,sl,so,dylib]. If we find it we are using X11R6
153 for ac_dir in $mh_lib_dirs ; do
154 for mh_xsm in libSM.a libSM.so libSM.sl libSM.dylib; do
155 if test -r $ac_dir/$mh_xsm; then
162 if test "$mh_x11r6" = yes ; then
163 mh_libs="$MH_X11_LIBS $MH_X11R6_LIBS"
165 mh_libs="$MH_X11_LIBS $extra_x_libs"
169 dnl Ensure that all required X libraries are found
173 mh_where_found_dirs=""
175 for mh_lib in $mh_libs; do
177 for ac_dir in $mh_lib_dirs ; do
178 for mh_ext in a so sl dll.a dylib; do
179 if test -r $ac_dir/lib$mh_lib.$mh_ext; then
180 if test "x$mh_prev_dir" != "x$ac_dir" ; then
181 if test "x$mh_prev_dir" = "x" ; then
182 mh_where_found="$mh_where_found found in $ac_dir"
184 mh_where_found="$mh_where_found and in $ac_dir"
187 mh_where_found_dirs="$mh_where_found_dirs $ac_dir"
188 MH_XLIBS="$MH_XLIBS -L$ac_dir"
189 mh_solaris_path="${mh_solaris_path}:$ac_dir"
191 MH_XLIBS="$MH_XLIBS -l$mh_lib"
197 if test "$mh_lib_found" = no; then
198 AC_MSG_ERROR(Cannot find required X library; lib$mh_lib. PDCurses cannot be configured)
202 mh_solaris_path=`echo $mh_solaris_path | sed 's/^://'`
203 if test "$mh_solaris_flag" = yes ; then
204 MH_XLIBS="-R$mh_solaris_path $extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
206 MH_XLIBS="$extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
208 if test "$mh_hpux9_flag" = yes ; then
209 grep -q XtSetLanguageProc $mh_x11_dir/Intrinsic.h
210 if test $? -eq 0 ; then
211 mh_found_xtshellstrings=no
212 for mh_acdir in $mh_where_found_dirs ; do
213 for mh_xaw in `ls $mh_acdir/libXaw.*` ; do
214 nm $mh_xaw | grep XtShellStrings | grep -qv extern
215 if test $? -eq 0 ; then
216 mh_found_xtshellstrings=yes
220 if test "$mh_found_xtshellstrings" = no ; then
221 AC_MSG_WARN(The X11 development environment has not been installed correctly.)
222 AC_MSG_WARN(The header file; Intrinsic.h, is for X11R5 while the Athena Widget)
223 AC_MSG_WARN(Set library; libXaw is for X11R4. This is a common problem with)
224 AC_MSG_WARN(HP-UX 9.x.)
225 AC_MSG_ERROR(X11 installation incomplete; cannot continue)
234 dnl ---------------------------------------------------------------------------
235 dnl Determine if the supplied X headers exist.
236 dnl ---------------------------------------------------------------------------
237 AC_DEFUN([MH_CHECK_X_HEADERS],
239 save_CPPFLAGS="$CPPFLAGS"
240 CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
241 for mh_header in $1; do
242 AC_CHECK_HEADERS($mh_header)
244 CPPFLAGS="$save_CPPFLAGS"
247 dnl ---------------------------------------------------------------------------
248 dnl Determine if various key definitions exist in keysym.h
249 dnl ---------------------------------------------------------------------------
250 AC_DEFUN([MH_CHECK_X_KEYDEFS],
252 save_CPPFLAGS="$CPPFLAGS"
253 CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
254 for mh_keydef in $1; do
255 AC_MSG_CHECKING(for $mh_keydef in keysym.h)
256 mh_upper_name="HAVE_`echo $mh_keydef | tr '[a-z]' '[A-Z]'`"
257 AC_TRY_COMPILE([#include <keysym.h>],
258 [int i = $mh_keydef;],
259 mh_have_key=yes; AC_DEFINE_UNQUOTED($mh_upper_name,1), mh_have_key=no )
260 AC_MSG_RESULT($mh_have_key)
262 CPPFLAGS="$save_CPPFLAGS"
265 dnl ---------------------------------------------------------------------------
266 dnl Determine if supplied types have been typedefed
267 dnl ---------------------------------------------------------------------------
268 AC_DEFUN([MH_CHECK_X_TYPEDEF],
270 save_CPPFLAGS="$CPPFLAGS"
271 CPPFLAGS="$CPPFLAGS $SYS_DEFS $MH_XINC_DIR"
273 AC_MSG_CHECKING(if $td is typedefed:)
275 [#include "X11/Xlib.h"],
280 if test "$mh_td" = yes ; then
281 TD_upper=`echo $td | tr a-z A-Z`
282 AC_DEFINE_UNQUOTED(${TD_upper}_TYPEDEFED, 1)
284 AC_MSG_RESULT($mh_td)
286 CPPFLAGS="$save_CPPFLAGS"
289 dnl ---------------------------------------------------------------------------
290 dnl Check for presence of various libraries
291 dnl ---------------------------------------------------------------------------
292 AC_DEFUN([MH_CHECK_LIB],
296 if test "$on_qnx" = yes; then
297 AC_MSG_CHECKING(for library -l${mh_lib})
298 if test -r /usr/lib/${mh_lib}3r.lib; then
300 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
302 AC_MSG_RESULT(not found)
305 AC_CHECK_LIB($mh_lib,main,mh_lib_found=yes,mh_lib_found=no)
306 if test "$mh_lib_found" = yes; then
307 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
313 dnl ---------------------------------------------------------------------------
314 dnl Work out how to create a dynamically loaded module
315 dnl ---------------------------------------------------------------------------
316 AC_DEFUN([MH_HOWTO_DYN_LINK],
318 mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&AC_FD_CC'
319 cat > conftest.$ac_ext <<EOF
320 dnl [#]line __oline__ "[$]0"
321 [#]line __oline__ "configure"
327 if AC_TRY_EVAL(mh_compile) && test -s conftest.o; then
328 mh_dyn_link='ld -shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
329 # mh_dyn_link='${CC} -Wl,-shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
330 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
331 LD_RXLIB1="ld -shared"
332 # LD_RXLIB1="${CC} -Wl,-shared"
336 mh_dyn_link='ld -G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
337 # mh_dyn_link='${CC} -Wl,-G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
338 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
340 # LD_RXLIB1="${CC} -Wl,-G"
353 dnl ---------------------------------------------------------------------------
354 dnl Determine how to build shared libraries etc..
355 dnl ---------------------------------------------------------------------------
356 AC_DEFUN([MH_SHARED_LIBRARY],
358 AC_REQUIRE([MH_SHLPST])
360 dnl If compiler is gcc, then flags should be the same for all platforms
361 dnl (just guessing on this)
371 AC_REQUIRE([AC_CANONICAL_SYSTEM])
374 SYS_DEFS="-D_HPUX_SOURCE"
375 LD_RXLIB1="ld -b -q -n"
378 SYS_DEFS="-D_ALL_SOURCE -DAIX"
381 LD_RXLIB1="ld -bnoentry -bM:SRE"
382 RXPACKEXPORTS="-bE:$SHLFILE.exp"
383 RXPACKEXP="$SHLFILE.exp"
386 if test "$ac_cv_prog_CC" = "gcc"; then
387 SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE"
389 SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800"
391 LD_RXLIB1="ld -shared"
393 *sequent-dynix*|*esix*|*dgux*)
397 if test "$ac_cv_prog_CC" = "gcc"; then
398 LD_RXLIB1="gcc -shared"
404 SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG"
407 *linux*|*atheos*|*nto-qnx*)
408 LD_RXLIB1="${CC} -shared"
411 LD_RXLIB1="ld -Bdynamic -Bshareable"
414 LD_RXLIB1="ld -dy -G"
417 LD_RXLIB1="${CC} -Wl,-shared -nostart -Xlinker -soname=\$(@)"
422 DYN_COMP="-Q" # force no check for dynamic loading
428 LD_RXLIB1="dllwrap --def \$(srcdir)/../win32/pdcurses.def --target i386-cygwin32 --dllname \$(@)"
429 # cygwininstall target MUST install the shared library itself because
430 # it puts it into $(bindir) not $(libdir) as all other platforms
433 DYN_COMP="-fno-common"
434 LD_RXLIB1="${CC} -flat_namespace -undefined suppress -dynamiclib -install_name=\$(@)"
440 dnl determine what switches our compiler uses for building objects
441 dnl suitable for inclusion in shared libraries
442 dnl Only call this if DYN_COMP is not set. If we have set DYN_COMP
443 dnl above, then we know how to compile AND link for dynamic libraries
445 if test "$DYN_COMP" = ""; then
446 AC_MSG_CHECKING(compiler flags for a dynamic object)
448 cat > conftest.$ac_ext <<EOF
449 dnl [#]line __oline__ "[$]0"
450 [#]line __oline__ "configure"
456 save_cflags="$CFLAGS"
457 mh_cv_flags="-fPIC -KPIC +Z"
458 for a in $mh_cv_flags; do
461 mh_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext > conftest.tmp 2>&1'
462 if AC_TRY_EVAL(mh_compile); then
466 mh_dyncomp="`grep -E -c $slash$a conftest.tmp`"
467 if test "$mh_dyncomp" = "0"; then
468 DYN_COMP="$a -DDYNAMIC"
476 if test "$DYN_COMP" = ""; then
477 AC_MSG_RESULT(none of $mh_cv_flags supported)
479 if test "$LD_RXLIB1" = ""; then
489 if test "$AIX_DYN" = "yes"; then
490 aix_exports="config.exports.aix"
491 echo "" > $aix_exports
494 if 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
495 EXPS="1,2,3,4,5,6,7,8,9"
498 SHL_TARGETS="${SHL_TARGETS} ${SHLPRE}${a}${SHLPST}"
499 this=`echo $EXPS | cut -d, -f1`
500 EXPS=`echo $EXPS | cut -d, -f2-`
501 if test "$AIX_DYN" = "yes"; then
502 echo "RXPACKEXP$this=$a.exp" >> $aix_exports
503 echo "RXPACKEXPORTS$this=-bE:$a.exp" >> $aix_exports
513 AC_SUBST(SHL_TARGETS)
517 AC_SUBST(RXPACKEXPORTS)
520 dnl ---------------------------------------------------------------------------
521 dnl Check if C compiler supports -c -o file.ooo
522 dnl ---------------------------------------------------------------------------
523 AC_DEFUN([MH_CHECK_CC_O],
525 AC_MSG_CHECKING(whether $CC understand -c and -o together)
526 set dummy $CC; ac_cc="`echo [$]2 |
528 sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
530 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
531 [echo 'foo(){}' > conftest.c
532 # We do the test twice because some compilers refuse to overwrite an
533 # existing .o file with -o, though they will create one.
534 eval ac_cv_prog_cc_${ac_cc}_c_o=no
535 ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
536 if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
538 ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
539 if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
541 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
546 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
552 O2SAVE="-mv \`basename "$'@'" .sho\`.o \`basename "$'@'" .sho\`.o.save;"
553 SAVE2O="-mv \`basename "$'@'" .sho\`.o "$'@'"; mv \`basename "$'@'" .sho\`.o.save \`basename "$'@'" .sho\`.o"
559 dnl ---------------------------------------------------------------------------
560 dnl Determines the file extension for shared libraries
561 dnl ---------------------------------------------------------------------------
562 AC_DEFUN([MH_SHLPST],
564 AC_MSG_CHECKING(shared library extension)
566 AC_REQUIRE([AC_CANONICAL_SYSTEM])
585 AC_MSG_RESULT($SHLPST)
588 dnl ---------------------------------------------------------------------------
589 dnl Determine the system limit for number of signals
590 dnl ---------------------------------------------------------------------------
591 AC_DEFUN([MH_CHECK_MAX_SIGNALS],
593 save_CPPFLAGS="$CPPFLAGS"
594 CPPFLAGS="$CPPFLAGS $SYS_DEFS"
595 AC_MSG_CHECKING(for maximum signal specifier:)
596 AC_CACHE_VAL(mh_cv_max_signals,
598 for mh_sigs in $1; do
599 AC_TRY_COMPILE([#include <signal.h>],
601 mh_found="yes"; mh_cv_max_signals="$mh_sigs" )
602 if test "$mh_found" = "yes"; then
606 CPPFLAGS="$save_CPPFLAGS"
607 if test "$mh_found" = "no"; then
608 AC_MSG_ERROR(Cannot find a system limit for number of signals. PDCurses cannot be configured on this machine.)
610 AC_DEFINE_UNQUOTED(PDC_MAX_SIGNALS,$mh_cv_max_signals)
611 AC_MSG_RESULT($mh_cv_max_signals)