don't build pcre as part of the linklibs target
[AROS-Contrib.git] / regina / aclocal.m4
blob2602c67128b7f1822143179d5fae344261f513c4
1 dnl MH_HAVE_PROTO
2 dnl MH_PROG_CC
3 dnl MH_CHECK_CC_O
4 dnl MH_CHECK__SIGHANDLER_T
5 dnl MH_STRUCT_RANDOM_DATA
6 dnl MH_GETGRGID_R_INT_RETURN_5_PARAMS
7 dnl MH_GETGRGID_R_INT_RETURN_4_PARAMS
8 dnl MH_GETGRGID_R_STRUCT_RETURN
9 dnl MH_GETPWUID_R_INT_RETURN
10 dnl MH_GETPWUID_R_STRUCT_RETURN
11 dnl MH_GETHOSTBYNAME_R_INT_RETURN_6_PARAMS
12 dnl MH_GETHOSTBYNAME_R_STRUCT_RETURN_5_PARAMS
13 dnl MH_CHECK_POSIX_THREADS
14 dnl MH_CHECK_LEADING_USCORE
15 dnl MH_HOWTO_DYN_LINK
16 dnl MH_HOWTO_SHARED_LIBRARY
17 dnl MH_CHECK_LIB
18 dnl MH_CHECK_CRYPT
19 dnl MH_SHLPST
20 dnl MH_SET_SHLPST
21 dnl MH_SHARED_LIBRARY
22 dnl MH_STATIC_LOADING
23 dnl MH_CHECK_UNSIGNED_CHAR_COMPILER_SWITCH
24 dnl MH_CHECK_RPM
25 dnl MH_C_LONG_LONG
26 dnl MH_CHECK_TYPE_SOCKLEN_T
27 dnl MH_CHECK_F_MNTFROMNAME
28 dnl
29 dnl ---------------------------------------------------------------------------
30 dnl Determine if C compiler handles ANSI prototypes
31 dnl ---------------------------------------------------------------------------
32 AC_DEFUN([MH_HAVE_PROTO],
34 AC_MSG_CHECKING(if compiler supports ANSI prototypes)
35 dnl
36 dnl override existing value of $ac_compile so we use the correct compiler
37 dnl SHOULD NOT NEED THIS
38 dnl
39 ac_compile='$ac_cv_prog_CC conftest.$ac_ext $CFLAGS $CPPFLAGS -c 1>&5 2>&5'
40 AC_TRY_COMPILE([#include <stdio.h>],
41 [extern int xxx(int, char *);],
42   mh_have_proto=yes; AC_DEFINE(HAVE_PROTO), mh_have_proto=no )
43 AC_MSG_RESULT($mh_have_proto)
44 ])dnl
45 dnl ---------------------------------------------------------------------------
46 dnl Determine the best C compiler to use given a list
47 dnl ---------------------------------------------------------------------------
48 AC_DEFUN([MH_PROG_CC],
50 mh_sysv_incdir=""
51 mh_sysv_libdir=""
52 all_words="$CC_LIST"
53 ac_dir=""
54 AC_MSG_CHECKING(for one of the following C compilers: $all_words)
55 AC_CACHE_VAL(ac_cv_prog_CC,[
56 if test -n "$CC"; then
57   ac_cv_prog_CC="$CC" # Let the user override the test.
58 else
59   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
60   for mh_cc in $all_words; do
61     for ac_dir in $PATH; do
62       test -z "$ac_dir" && ac_dir=.
63       if test -f $ac_dir/$mh_cc; then
64         ac_cv_prog_CC="$mh_cc"
65         if test "$ac_dir" = "/usr/5bin"; then
66           mh_sysv_incdir="/usr/5include"
67           mh_sysv_libdir="/usr/5lib"
68         fi
69         break 2
70       fi
71     done
72   done
73   IFS="$ac_save_ifs"
74   test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc"
76 CC="$ac_cv_prog_CC"
78 AC_SUBST(CC)
79 if test "$ac_dir" = ""; then
80    AC_MSG_RESULT(using $ac_cv_prog_CC specified in CC env variable)
81 else
82    AC_MSG_RESULT(using $ac_dir/$ac_cv_prog_CC)
84 ])dnl
85 dnl ---------------------------------------------------------------------------
86 dnl Check if C compiler supports -c -o file.ooo
87 dnl ---------------------------------------------------------------------------
88 AC_DEFUN([MH_CHECK_CC_O],
90 AC_MSG_CHECKING(whether $CC understands -c and -o together)
91 set dummy $CC; ac_cc="`echo [$]2 |
92 changequote(, )dnl
93                        sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
94 changequote([, ])dnl
95 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
96 [echo 'int foo(){}' > conftest.c
97 # We do the test twice because some compilers refuse to overwrite an
98 # existing .o file with -o, though they will create one.
99 eval ac_cv_prog_cc_${ac_cc}_c_o=no
100 ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
101 if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
102 then
103   ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
104   if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
105   then
106     eval ac_cv_prog_cc_${ac_cc}_c_o=yes
107   fi
109 rm -f conftest*
110 ])dnl
111 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
112         O2SHO=""
113         O2SAVE=""
114         SAVE2O=""
115         O2TSO=""
116         O2TSAVE=""
117         TSAVE2O=""
118         CC2O="-o $"'@'
119         AC_MSG_RESULT(yes)
120 else
121         O2SHO="-mv \`basename "$'@'" .so.o\`.o "$'@'
122         O2SAVE="-mv \`basename "$'@'" .so.o\`.o \`basename "$'@'" .so.o\`.o.save"
123         SAVE2O="-mv \`basename "$'@'" .so.o\`.o.save \`basename "$'@'" .so.o\`.o"
124         O2TSO="-mv \`basename "$'@'" .tso\`.o "$'@'
125         O2TSAVE="-mv \`basename "$'@'" .tso\`.o \`basename "$'@'" .tso\`.tso.save"
126         TSAVE2O="-mv \`basename "$'@'" .tso\`.tso.save \`basename "$'@'" .tso\`.o"
127         CC2O=""
128         AC_MSG_RESULT(no)
131 dnl ---------------------------------------------------------------------------
132 dnl Check if gcc compiler supports -fno-strict-aliasing
133 dnl ---------------------------------------------------------------------------
134 AC_DEFUN([MH_CHECK_GCC_STRICT_ALIASING],
136 AC_MSG_CHECKING(whether gcc understands -fno-strict-aliasing)
137 AC_CACHE_VAL(
138 [mh_strict_aliasing],
140 mh_save_libs="$LIBS"
141 LIBS="-fno-strict-aliasing"
142 AC_LINK_IFELSE(
143 [AC_LANG_PROGRAM([#include <stdio.h>],
144 [exit(0)])],
145 [mh_strict_aliasing=yes],
146 [mh_strict_aliasing=no]
148 LIBS="$mh_save_libs"
149 if test "$mh_strict_aliasing" = yes; then
150         MH_STRICT_ALIASING="-fno-strict-aliasing"
151 else
152         MH_STRICT_ALIASING=""
154 AC_SUBST(MH_STRICT_ALIASING)
156 AC_MSG_RESULT($mh_strict_aliasing)
158 dnl ---------------------------------------------------------------------------
159 dnl Check if compiler supports __builtin_return_address
160 dnl ---------------------------------------------------------------------------
161 AC_DEFUN([MH_CHECK_BUILTIN_RETURN_ADDRESS],
163 AC_MSG_CHECKING(whether compiler supports __builtin_return_address inline function)
164 AC_CACHE_VAL(
165 [mh_cv_builtin_return_address],
167 AC_TRY_LINK(
168 [#include <stdio.h>],
169 [__builtin_return_address(0)],
170 [mh_cv_builtin_return_address=yes],
171 [mh_cv_builtin_return_address=no]
174 AC_MSG_RESULT($mh_cv_builtin_return_address)
175 if test "$mh_cv_builtin_return_address" = yes; then
176         AC_DEFINE(HAVE_BUILTIN_RETURN_ADDRESS)
180 dnl ---------------------------------------------------------------------------
181 dnl Determine compiler's "unsigned char" is default switch
182 dnl ---------------------------------------------------------------------------
183 AC_DEFUN([MH_CHECK_UNSIGNED_CHAR_COMPILER_SWITCH],
185 AC_C_CHAR_UNSIGNED()
186 AC_MSG_CHECKING(compiler switch for unsigned char)
188 # QNX4 Watcom compiler is unsigned char by default
190 if test "$on_qnx4" = yes -a "$ac_cv_prog_CC" = "cc" ; then
191         qnx4_char_unsigned="yes"
194 if test "$ac_cv_c_char_unsigned" = yes -o "$qnx4_char_unsigned" = yes; then
195         MH_UNSIGNED_CHAR_SWITCH=""
196         msg="not needed - char is unsigned by default"
197 else
198         case "$ac_cv_prog_CC" in
199                 gcc)
200                         MH_UNSIGNED_CHAR_SWITCH="-funsigned-char"
201                         msg="$MH_UNSIGNED_CHAR_SWITCH"
202                         ;;
203                 xlC)
204                         MH_UNSIGNED_CHAR_SWITCH="-qchars=unsigned"
205                         msg="$MH_UNSIGNED_CHAR_SWITCH"
206                         ;;
207                 *)
208                         save_cflags="$CFLAGS"
209                         mh_have_unsigned_char_switch=no
210                         mh_unsigned_flags="-funsigned-char -xchar=unsigned"
211                         for mh_flag in $mh_unsigned_flags; do
212                                 CFLAGS="$CFLAGS $mh_flag"
213 AC_TRY_COMPILE([#include <stdio.h>],
214 [char x;],
215   MH_UNSIGNED_CHAR_SWITCH="$mh_flag"; msg="$MH_UNSIGNED_CHAR_SWITCH"; mh_have_unsigned_char_switch=yes )
216                                 CFLAGS="$save_cflags"
217                                 if test "$mh_have_unsigned_char_switch" = yes; then
218                                         break
219                                 fi
220                         done
221                         if test "$mh_have_unsigned_char_switch" = no; then
222                                 msg="unknown - assuming unsigned by default but running execiser will confirm"
223                         fi
224                         ;;
225         esac
227 AC_MSG_RESULT("$msg")
228 AC_SUBST(MH_UNSIGNED_CHAR_SWITCH)
230 dnl ---------------------------------------------------------------------------
231 dnl Check if gcc compiler supports --version-script
232 dnl ---------------------------------------------------------------------------
233 AC_DEFUN([MH_CHECK_GCC_VERSION_SCRIPT],
235 AC_MSG_CHECKING(whether gcc understands --version-script)
236 AC_CACHE_VAL(
237 [mh_cv_version_script],
239 echo "TEST {" > conftest.def
240 echo "global:" >> conftest.def
241 echo "Test;" >> conftest.def
242 echo "};" >> conftest.def
243 mh_save_libs="$LDFLAGS"
244 LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.def"
245 AC_LINK_IFELSE(
246 [AC_LANG_PROGRAM([#include <stdio.h>],
247 [exit(0);])],
248 [mh_cv_version_script=yes],
249 [mh_cv_version_script=no]
251 LDFLAGS="$mh_save_libs"
252 rm -f conftest.def
254 if test "$mh_cv_version_script" = yes; then
255         SHL_SCRIPT="-Wl,--version-script=${srcdir}/regina_elf.def"
256 else
257         SHL_SCRIPT=""
259 AC_SUBST(SHL_SCRIPT)
260 AC_MSG_RESULT($mh_cv_version_script)
263 dnl ---------------------------------------------------------------------------
264 dnl Check if __sighandler_t is defined
265 dnl ---------------------------------------------------------------------------
266 AC_DEFUN([MH_CHECK__SIGHANDLER_T],
268 AC_MSG_CHECKING(whether __sighandler_t is defined)
270 AC_CACHE_VAL(
271 [mh_cv__sighandler_t],
273 AC_TRY_COMPILE(
274 [#include <sys/types.h>]
275 [#include <signal.h>],
276 [__sighandler_t fred],
277 [mh_cv__sighandler_t=yes],
278 [mh_cv__sighandler_t=no]
281 AC_MSG_RESULT($mh_cv__sighandler_t)
282 if test "$mh_cv__sighandler_t" = yes ; then
283         AC_DEFINE(HAVE__SIGHANDLER_T)
288 dnl ---------------------------------------------------------------------------
289 dnl Work out if struct random_data is defined
290 dnl ---------------------------------------------------------------------------
291 AC_DEFUN(MH_STRUCT_RANDOM_DATA,
292 [AC_CACHE_CHECK([for struct random_data], mh_cv_struct_random_data,
293 [AC_TRY_COMPILE([#include <stdlib.h>
294 #include <stdio.h>],
295 [struct random_data s;],
296 mh_cv_struct_random_data=yes, mh_cv_struct_random_data=no)])
297 if test $mh_cv_struct_random_data = yes; then
298   AC_DEFINE(HAVE_RANDOM_DATA)
302 dnl ---------------------------------------------------------------------------
303 dnl Work out if getgrgid_r returns an int and has 5 parameters
304 dnl ---------------------------------------------------------------------------
305 AC_DEFUN(MH_GETGRGID_R_INT_RETURN_5_PARAMS,
306 [AC_CACHE_CHECK([if getgrgid_r has 5 args and returns an int], mh_cv_getgrgid_r_int5,
307 [AC_TRY_COMPILE([#include <sys/types.h>
308 #include <grp.h>
309 #include <pwd.h>],
311 struct group *ptr,result;
312 int rc;
313 gid_t gid;
314 char buf[100];
315 rc = getgrgid_r(gid,&result,buf,sizeof(buf),&ptr);
317 mh_cv_getgrgid_r_int5=yes, mh_cv_getgrgid_r_int5=no)])
318 if test $mh_cv_getgrgid_r_int5 = yes; then
319   AC_DEFINE(HAVE_GETGRGID_R_RETURNS_INT_5_PARAMS)
323 dnl ---------------------------------------------------------------------------
324 dnl Work out if getgrgid_r returns an int and has 4 parameters
325 dnl ---------------------------------------------------------------------------
326 AC_DEFUN(MH_GETGRGID_R_INT_RETURN_4_PARAMS,
327 [AC_CACHE_CHECK([if getgrgid_r has 4 args and returns an int], mh_cv_getgrgid_r_int4,
328 [AC_TRY_COMPILE([#include <sys/types.h>
329 #include <grp.h>
330 #include <pwd.h>],
332 struct group *ptr,result;
333 int rc;
334 gid_t gid;
335 char buf[100];
336 rc = getgrgid_r(gid,&result,buf,sizeof(buf));
338 mh_cv_getgrgid_r_int4=yes, mh_cv_getgrgid_r_int4=no)])
339 if test $mh_cv_getgrgid_r_int4 = yes; then
340   AC_DEFINE(HAVE_GETGRGID_R_RETURNS_INT_4_PARAMS)
344 dnl ---------------------------------------------------------------------------
345 dnl Work out if getgrgid_r returns a struct group *
346 dnl ---------------------------------------------------------------------------
347 AC_DEFUN(MH_GETGRGID_R_STRUCT_RETURN,
348 [AC_CACHE_CHECK([if getgrgid_r returns a struct group *], mh_cv_getgrgid_r_struct,
349 [AC_TRY_COMPILE([#include <sys/types.h>
350 #include <grp.h>
351 #include <pwd.h>],
353 struct group *ptr,result;
354 int rc;
355 gid_t gid;
356 char buf[100];
357 ptr = getgrgid_r(gid,&result,buf,sizeof(buf));
359 mh_cv_getgrgid_r_struct=yes, mh_cv_getgrgid_r_struct=no)])
360 if test $mh_cv_getgrgid_r_struct = yes; then
361   AC_DEFINE(HAVE_GETGRGID_R_RETURNS_STRUCT)
365 dnl ---------------------------------------------------------------------------
366 dnl Work out if getpwuid_r returns an int
367 dnl ---------------------------------------------------------------------------
368 AC_DEFUN(MH_GETPWUID_R_INT_RETURN,
369 [AC_CACHE_CHECK([if getpwuid_r returns an int], mh_cv_getpwuid_r_int,
370 [AC_TRY_COMPILE([#include <sys/types.h>
371 #include <grp.h>
372 #include <pwd.h>],
374 struct passwd *ptr,*result;
375 int rc;
376 uid_t uid;
377 char buf[100];
378 rc = getpwuid_r(uid,&result,buf,sizeof(buf),&ptr);
380 mh_cv_getpwuid_r_int=yes, mh_cv_getpwuid_r_int=no)])
381 if test $mh_cv_getpwuid_r_int = yes; then
382   AC_DEFINE(HAVE_GETPWUID_R_RETURNS_INT)
386 dnl ---------------------------------------------------------------------------
387 dnl Work out if getpwuid_r returns a struct group *
388 dnl ---------------------------------------------------------------------------
389 AC_DEFUN(MH_GETPWUID_R_STRUCT_RETURN,
390 [AC_CACHE_CHECK([if getpwuid_r returns a struct passwd *], mh_cv_getpwuid_r_struct,
391 [AC_TRY_COMPILE([#include <sys/types.h>
392 #include <grp.h>
393 #include <pwd.h>],
395 struct group *ptr,*result;
396 int rc;
397 uid_t uid;
398 char buf[100];
399 ptr = getpwuid_r(uid,&result,buf,sizeof(buf));
401 mh_cv_getpwuid_r_struct=yes, mh_cv_getpwuid_r_struct=no)])
402 if test $mh_cv_getpwuid_r_struct = yes; then
403   AC_DEFINE(HAVE_GETPWUID_R_RETURNS_STRUCT)
407 dnl ---------------------------------------------------------------------------
408 dnl Work out if gethostbyname_r returns a struct and has 6 parameters
409 dnl ---------------------------------------------------------------------------
410 AC_DEFUN(MH_GETHOSTBYNAME_R_INT_RETURN_6_PARAMS,
411 [AC_CACHE_CHECK([if gethostbyname_r has 6 args and returns an int], mh_cv_gethostbyname_r_int6,
412 [AC_TRY_COMPILE([#include <sys/types.h>
413 #include <netdb.h>],
415 int herr;
416 struct hostent *he,*rc;
417 char buf[8192];
418 struct hostent retval;
419 rc = gethostbyname_r("fred",&retval,buf,sizeof(buf),&he,&herr);
421 mh_cv_gethostbyname_r_int6=yes, mh_cv_gethostbyname_r_int6=no)])
422 if test $mh_cv_gethostbyname_r_int6 = yes; then
423   AC_DEFINE(HAVE_GETHOSTBYNAME_R_RETURNS_INT_6_PARAMS)
427 dnl ---------------------------------------------------------------------------
428 dnl Work out if gethostbyname_r returns a struct and has 5 parameters
429 dnl ---------------------------------------------------------------------------
430 AC_DEFUN(MH_GETHOSTBYNAME_R_STRUCT_RETURN_5_PARAMS,
431 [AC_CACHE_CHECK([if gethostbyname_r has 5 args and returns a struct], mh_cv_gethostbyname_r_struct5,
432 [AC_TRY_COMPILE([#include <sys/types.h>
433 #include <netdb.h>],
435 int herr;
436 struct hostent *he,*rc;
437 char buf[8192];
438 struct hostent retval;
439 rc = gethostbyname_r("fred",&retval,buf,sizeof(buf),&herr);
441 mh_cv_gethostbyname_r_struct5=yes, mh_cv_gethostbyname_r_struct5=no)])
442 if test $mh_cv_gethostbyname_r_struct5 = yes; then
443   AC_DEFINE(HAVE_GETHOSTBYNAME_R_RETURNS_STRUCT_5_PARAMS)
447 dnl ---------------------------------------------------------------------------
448 dnl Work out if POSIX Threads are supported
449 dnl ---------------------------------------------------------------------------
450 AC_DEFUN([MH_CHECK_POSIX_THREADS],
452 MH_MT_LIBS=""
453 THREADING_COMPILE=""
454 THREADING_LINK=""
455 THREADSAFE_TARGET=""
456 MT_FILE="mt_notmt"
457 if test "$enable_posix_threads" = yes; then
458    dnl
459    dnl -lrt is needed by posix threads on Solaris
460    dnl
461    AC_CHECK_LIB(rt,main,mh_rt_lib_found=yes,mh_rt_lib_found=no)
462    AC_MSG_CHECKING(whether Posix Threads are supported)
463    tmpLIBS=$LIBS
464    save_cflags="$CFLAGS"
465    pthread_libs="pthreads pthread c_r"
466    case "$target" in
467       *freebsd*)
468          CFLAGS="$CFLAGS -pthread"
469          ;;
470    esac
471    for mh_lib in $pthread_libs; do
472       LIBS="$tmpLIBS -l${mh_lib}"
473       AC_TRY_LINK(
474       [#include <pthread.h>],
475       [pthread_create(NULL,NULL,NULL,NULL)],
476       [mh_has_pthreads=yes],
477       [mh_has_pthreads=no]
478       )
479       if test "$mh_has_pthreads" = yes; then
480          MH_MT_LIBS="-l${mh_lib}"
481          AC_REQUIRE([AC_CANONICAL_SYSTEM])
482          THREADING_COMPILE="-D_REENTRANT -DPOSIX"
483          THREADING_LINK=""
484          THREADSAFE_TARGET="threader${binarybitprefix}${EXEEXT}"
485          MT_FILE="mt_posix"
486          case "$target" in
487             *solaris*)
488                if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
489                   THREADING_COMPILE="-D_REENTRANT -DPOSIX"
490                   if test "$mh_rt_lib_found" = "yes"; then
491                      THREADING_LINK="-lrt"
492                   fi
493                else
494                   THREADING_COMPILE="-mt -D_REENTRANT -DREENTRANT -D_PTHREAD_SEMANTICS"
495                   THREADING_LINK="-mt"
496                fi
497                ;;
498             *hp-hpux1*)
499                if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
500                   THREADING_COMPILE="-D_REENTRANT -DPOSIX"
501                fi
502                if test "$mh_rt_lib_found" = "yes"; then
503                   THREADING_LINK="-lrt"
504                fi
505                ;;
506             *linux*)
507                ;;
508             *freebsd*)
509                THREADING_COMPILE="-pthread -D_REENTRANT -DPOSIX"
510                THREADING_LINK="-pthread"
511                ;;
512             *cygwin*)
513                THREADING_COMPILE="-D_REENTRANT -DPOSIX"
514                THREADING_LINK=""
515                ;;
516             *)
517                if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
518                   THREADING_COMPILE="-D_REENTRANT -DPOSIX"
519                fi
520                ;;
521          esac
522          break
523       fi
524    done
525    LIBS="$tmpLIBS"
526    CFLAGS="$save_cflags"
527    AC_MSG_RESULT($mh_has_pthreads)
529 AC_SUBST(THREADING_COMPILE)
530 AC_SUBST(THREADING_LINK)
531 AC_SUBST(THREADSAFE_TARGET)
532 AC_SUBST(MH_MT_LIBS)
533 AC_SUBST(MT_FILE)
536 dnl ---------------------------------------------------------------------------
537 dnl Work out if functions in dynamically loadable libraries need leading _
538 dnl Tests based on glib code and only valid for dlopen() mechanism
539 dnl ---------------------------------------------------------------------------
540 AC_DEFUN([MH_CHECK_LEADING_USCORE],
542 if test "$ac_cv_header_dlfcn_h" = "yes" -o "$HAVE_DLFCN_H" = "1"; then
543    AC_MSG_CHECKING(if symbols need underscore prepended in loadable modules)
544    tmpLIBS="$LIBS"
545    save_cflags="$CFLAGS"
546    LIBS="$LIBS $DLFCNLIBDIR"
547    CFLAGS="$CFLAGS $DLFCNINCDIR"
548    AC_CACHE_VAL(mh_cv_uscore,[
549    AC_RUN_IFELSE([
550    #include <dlfcn.h>
551    int mh_underscore_test (void) { return 42; }
552    int main() {
553      void *f1 = (void*)0, *f2 = (void*)0, *handle;
554      handle = dlopen ((void*)0, 0);
555      if (handle) {
556        f1 = dlsym (handle, "mh_underscore_test");
557        f2 = dlsym (handle, "_mh_underscore_test");
558      } return (!f2 || f1);
559    }],
560    [mh_cv_uscore=yes],
561    [mh_cv_uscore=no],
562    [mh_cv_uscore=no]
563    )
564    ])
565    AC_MSG_RESULT($mh_cv_uscore)
566    if test "x$mh_cv_uscore" = "xyes"; then
567      AC_DEFINE(MODULES_NEED_USCORE)
568    fi
569    LIBS="$tmpLIBS"
570    CFLAGS="$save_cflags"
574 dnl ---------------------------------------------------------------------------
575 dnl Work out how to create a dynamically loaded module
576 dnl ---------------------------------------------------------------------------
577 AC_DEFUN([MH_HOWTO_DYN_LINK],
579 mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&AC_FD_CC'
580 cat > conftest.$ac_ext <<EOF
581 dnl [#]line __oline__ "[$]0"
582 [#]line __oline__ "configure"
583 int foo()
585 return(0);
588 if AC_TRY_EVAL(mh_compile) && test -s conftest.o; then
589         mh_dyn_link='ld -shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
590 #       mh_dyn_link='${CC} -Wl,-shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
591         if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
592                 LD_RXLIB_A1="ld -shared -o \$(@)"
593                 LD_RXLIB_A2="ld -shared -o \$(@)"
594                 LD_RXLIB_UTILA="ld -shared -o \$(@)"
595 #               LD_RXLIB1="${CC} -Wl,-shared"
596                 LD_RXLIB_B1="-L. -l${SHLFILE}"
597                 LD_RXLIB_B2="-L. -l${SHLFILE}"
598                 LD_RXLIB_UTILB="-L. -l${SHLFILE}"
599                 SHLPRE="lib"
600                 SHLPST=".so"
601         else
602                 mh_dyn_link='ld -G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
603 #               mh_dyn_link='${CC} -Wl,-G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
604                 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
605                         LD_RXLIB_A1="ld -G -o \$(@)"
606                         LD_RXLIB_A2="ld -G -o \$(@)"
607                         LD_RXLIB_UTILA="ld -G -o \$(@)"
608 #                       LD_RXLIB1="${CC} -Wl,-G"
609                         LD_RXLIB_B1="-L. -l${SHLFILE}"
610                         LD_RXLIB_B2="-L. -l${SHLFILE}"
611                         LD_RXLIB_UTILB="-L. -l${SHLFILE}"
612                         SHLPRE="lib"
613                         SHLPST=".so"
614                 else
615                         LD_RXLIB_A1=""
616                         LD_RXLIB_A2=""
617                         LD_RXLIB_UTILA=""
618                         LD_RXLIB_B1=""
619                         LD_RXLIB_B2=""
620                         LD_RXLIB_UTILB=""
621                         SHLPRE=""
622                         SHLPST=""
623                 fi
624         fi
626 rm -f conftest*
627 ])dnl
629 dnl ---------------------------------------------------------------------------
630 dnl Work out how to create a shared library
631 dnl ---------------------------------------------------------------------------
632 AC_DEFUN(MH_HOWTO_SHARED_LIBRARY,
634 AC_MSG_CHECKING(how to create a shared library)
635 mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&AC_FD_CC'
636 cat > conftest.$ac_ext <<EOF
637 dnl [#]line __oline__ "[$]0"
638 [#]line __oline__ "configure"
639 int foo()
641 return(0);
644 if AC_TRY_EVAL(mh_compile) && test -s conftest.o; then
645         mh_dyn_link='ld -shared -o conftest.so.1.0 conftest.o -lc 1>&AC_FD_CC'
646 #       mh_dyn_link='${CC} -Wl,-shared -o conftest.so.1.0 conftest.o -lc 1>&AC_FD_CC'
647         if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.so.1.0; then
648                 SHL_LD="ld -shared -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'" -lc"
649 #               SHL_LD="${CC} -Wl,-shared -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'" -lc"
650         else
651                 mh_dyn_link='ld -G -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
652 #               mh_dyn_link='${CC} -Wl,-G -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
653                 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.so.1.0; then
654                         SHL_LD="ld -G -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
655 #                       SHL_LD="${CC} -Wl,-G -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
656                 else
657                         mh_dyn_link='ld -o conftest.so.1.0 -shared -no_archive conftest.o  -lc 1>&AC_FD_CC'
658 #                       mh_dyn_link='${CC} -o conftest.so.1.0 -Wl,-shared,-no_archive conftest.o  -lc 1>&AC_FD_CC'
659                         if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.so.1.0; then
660                                 SHL_LD="ld -o ${SHLPRE}${SHLFILE}${SHLPST} -shared -no_archive "'$('SHOFILES')'" -lc"
661 #                               SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST} -Wl,-shared,-no_archive "'$('SHOFILES')'" -lc"
662                         else
663                                 mh_dyn_link='ld -b -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
664 #                               mh_dyn_link='${CC} -Wl,-b -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
665                                 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.so.1.0; then
666                                         SHL_LD="ld -b -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
667 #                                       SHL_LD="${CC} -Wl,-b -o ${SHLPRE}${SHLFILE}.${SHLPST} "'$('SHOFILES')'
668                                 else
669                                         mh_dyn_link='ld -Bshareable -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
670 #                                       mh_dyn_link='${CC} -Wl,-Bshareable -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
671                                         if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.so.1.0; then
672                                                 SHL_LD="ld -Bshareable -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
673 #                                               SHL_LD="${CC} -Wl,-Bshareable -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
674                                         else
675                                                 mh_dyn_link='ld -assert pure-text -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
676 #                                               mh_dyn_link='${CC} -Wl,-assert pure-text -o conftest.so.1.0 conftest.o 1>&AC_FD_CC'
677                                                 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.so.1.0; then
678                                                         SHL_LD="ld -assert pure-text -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
679 #                                                       SHL_LD="${CC} -Wl,-assert pure-text -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
680                                                 else
681                                                         SHL_LD=""
682                                                 fi
683                                         fi
684                                 fi
685                         fi
686                 fi
687         fi
689 if test "$SHL_LD" = ""; then
690         AC_MSG_RESULT(unknown)
691 else
692         AC_MSG_RESULT(found)
694 rm -f conftest*
697 dnl ---------------------------------------------------------------------------
698 dnl Check for presence of various libraries
699 dnl ---------------------------------------------------------------------------
700 AC_DEFUN([MH_CHECK_LIB],
702 MH_EXTRA_LIBS=''
703 for mh_lib in $1; do
704    if test "$on_qnx4" = yes -a "$ac_cv_prog_CC" != "gcc"; then
705       AC_MSG_CHECKING(for library -l${mh_lib})
706       if test -r /usr/lib/${mh_lib}3r.lib; then
707          AC_MSG_RESULT(found)
708          MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
709       else
710          AC_MSG_RESULT(not found)
711       fi
712    else
713       AC_CHECK_LIB($mh_lib,main,mh_lib_found=yes,mh_lib_found=no)
714       if test "$mh_lib_found" = yes; then
715          MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
716       fi
717    fi
718 done
719 ])dnl
721 dnl ---------------------------------------------------------------------------
722 dnl Check for presence of various libraries
723 dnl ---------------------------------------------------------------------------
724 AC_DEFUN([MH_CHECK_CRYPT],
726 mh_save_libs="$LIBS"
728 if test "$on_qnx4" = no; then
729    AC_CHECK_LIB(crypt,main,mh_crypt_found=yes,mh_crypt_found=no)
730    if test "$mh_crypt_found" = yes; then
731       LIBS="${LIBS} -lcrypt"
732    fi
735 AC_MSG_CHECKING(for crypt function)
737 AC_CACHE_VAL(
738 [mh_cv_func_crypt],
740         AC_TRY_LINK(
741 [#include <unistd.h>],
742 [crypt("fred","aa")],
743         [mh_cv_func_crypt=yes],
744         [mh_cv_func_crypt=no]
745         )
746 ])dnl
747 AC_MSG_RESULT($mh_cv_func_crypt)
748 if test "$mh_cv_func_crypt" = yes ; then
749         AC_DEFINE(HAVE_CRYPT)
750         if test "$mh_crypt_found" = yes; then
751                 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -lcrypt"
752         fi
755 LIBS="$mh_save_libs"
757 ])dnl
759 dnl ---------------------------------------------------------------------------
760 dnl Determines the file extension for shared libraries
761 dnl ---------------------------------------------------------------------------
762 AC_DEFUN([MH_SHLPST],
764 AC_MSG_CHECKING(shared library/external function extensions)
765 SHLPST=".so"
766 MODPST=".so"
767 AC_REQUIRE([AC_CANONICAL_SYSTEM])
768 case "$target" in
769         *hp-hpux*)
770                 SHLPST=".sl"
771                 MODPST=".sl"
772                 ;;
773         *ibm-aix5*)
774                 SHLPST=".a"
775                 MODPST=".a"
776                 ;;
777         *ibm-aix*)
778                 SHLPST=".a"
779                 MODPST=".a"
780                 ;;
781         *nto-qnx*)
782                 ;;
783         *qnx*)
784                 SHLPST=""
785                 MODPST=""
786                 ;;
787         *cygwin*)
788                 SHLPST=".dll"
789                 MODPST=".dll"
790                 ;;
791         *skyos*)
792                 SHLPST=".dll"
793                 MODPST=".dll"
794                 ;;
795         *darwin*)
796                 SHLPST=".dylib"
797                 MODPST=".dylib"
798 # MH                MODPST=".so"
799                 ;;
800 esac
801 AC_MSG_RESULT($SHLPST/$MODPST)
804 dnl ---------------------------------------------------------------------------
805 dnl Sets SHLPST and MODPST
806 dnl ---------------------------------------------------------------------------
807 AC_DEFUN([MH_SET_SHLPST],
809 AC_SUBST(SHLPST)
810 AC_SUBST(MODPST)
813 dnl ---------------------------------------------------------------------------
814 dnl Determine how to build shared libraries etc..
815 dnl ---------------------------------------------------------------------------
816 AC_DEFUN([MH_SHARED_LIBRARY],
818 AC_REQUIRE([MH_SET_SHLPST])
820 dnl If compiler is gcc, then flags should be the same for all platforms
821 dnl (just guessing on this)
823 SHLPRE="lib"
824 LIBFILE="regina"
825 SHLFILE="regina"
826 OSAVE=".o.save"
827 OBJ="o"
828 LIBPST=".a"
829 LIBPRE="lib"
830 LIBEXE="ar"
831 GETOPT=""
832 OBJECTS='$('OFILES')'
833 STATIC_LDFLAGS=""
834 AIX_DYN="no"
835 BEOS_DYN="no"
837 AC_REQUIRE([AC_CANONICAL_SYSTEM])
838 case "$target" in
839         *hp-hpux9*)
840                 SYS_DEFS="-D_HPUX_SOURCE +e" # Extended ANSI mode for c89
841                 AC_DEFINE(SELECT_IN_TIME_H)
842                 ;;
843         *hp-hpux*)
844                 if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
845                   SYS_DEFS="-D_HPUX_SOURCE"
846                 else
847                   SYS_DEFS="-D_HPUX_SOURCE +e" # Extended ANSI mode for c89
848                 fi
849                 ;;
850         *ibm-aix3*|*ibm-aix4.1*)
851                 SYS_DEFS="-D_ALL_SOURCE -DAIX"
852                 ;;
853         *ibm-aix*)
854                 SYS_DEFS="-D_ALL_SOURCE -DAIX"
855                 DYN_COMP="-DDYNAMIC"
856                 ;;
857         *dec-osf*)
858                 if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
859                         SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE"
860                 else
861                         SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800"
862                 fi
863                 ;;
864         sparc*sunos*)
865                 SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG"
866                 ;;
867         *nto-qnx*)
868                 ;;
869         *skyos*)
870                 DYN_COMP="-DDYNAMIC"
871                 ;;
872         *qnx*)
873                 LIBPRE=""
874                 LIBPST=".lib"
875                 SHLPRE=""
876                 SHLPST=".lib"
877                 SHLFILE="rexx"
878                 ;;
879         *cygwin*)
880                 LIBPRE="lib"
881                 SHLPRE=""
882                 DYN_COMP="-DDYNAMIC"
883                 LIBPST=".a"
884                 ;;
885         *darwin*)
886                 DYN_COMP="-fno-common"
887                 ;;
888 esac
891 dnl set variables for compiling if we don't already have it
893 if test "$DYN_COMP" = ""; then
894 AC_MSG_CHECKING(compiler flags for a dynamic object)
896 cat > conftest.$ac_ext <<EOF
897 dnl [#]line __oline__ "[$]0"
898 [#]line __oline__ "configure"
899 int a=0
902         DYN_COMP=""
903         mh_cv_stop=no
904         save_cflags="$CFLAGS"
905         mh_cv_flags="-fPIC -KPIC +Z"
906         for a in $mh_cv_flags; do
907                 CFLAGS="-c $a"
909                 mh_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext > conftest.tmp 2>&1'
910                 if AC_TRY_EVAL(mh_compile); then
911                         DYN_COMP=""
912                 else
913                         slash="\\"
914                         mh_dyncomp="`egrep -c $slash$a conftest.tmp`"
915                         if test "$mh_dyncomp" = "0"; then
916                                 DYN_COMP="$a -DDYNAMIC"
917                                 AC_MSG_RESULT($a)
918                                 break
919                         else
920                                 DYN_COMP=""
921                         fi
922                 fi
923         done
924         if test "$DYN_COMP" = ""; then
925                 AC_MSG_RESULT(none of $mh_cv_flags supported)
926         fi
927         CFLAGS="$save_cflags"
928         rm -f conftest.*
932 dnl set variables for linking
934 SHL_LD=""
935 TEST1EXPORTS=""
936 TEST2EXPORTS=""
937 TEST1EXP=""
938 TEST2EXP=""
939 REGINAEXP=""
940 REGUTILEXP=""
942 # If the build OS can handle version numbers in the shared library name,
943 # then set SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
944 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}"
946 # OTHER_INSTALLS is set to install a non-version numbered shared library
947 # by default; ie. no .\$(ABI) suffix. If the regina executable is not built,
948 # then there is no shared library. Set OTHER_INSTALLS="installabilib" if you
949 # are building a version numbered shared library.
950 OTHER_INSTALLS="installlib"
951 BASE_INSTALL="installbase"
952 BASE_BINARY="binarybase"
953 USE_ABI="no"
954 BUNDLE=""
955 EXTRATARGET=""
956 case "$target" in
957         *hp-hpux*)
958                 SHLPRE="lib"
959                 if test "$ac_cv_prog_CC" = "gcc"; then
960                    LD_RXLIB_A1="${CC} -fPIC -shared ${LDFLAGS} -o \$(@)"
961                    LD_RXLIB_A2="${CC} -fPIC -shared ${LDFLAGS} -o \$(@)"
962                    LD_RXLIB_UTILA="${CC} -fPIC -shared ${LDFLAGS} -o \$(@)"
963                    LD_RXLIB_B1="-L. -l${SHLFILE}"
964                    LD_RXLIB_B2="-L. -l${SHLFILE}"
965                    LD_RXLIB_UTILB="-L. -l${SHLFILE}"
966                    SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST} -fPIC -shared ${LDFLAGS} \$(SHOFILES)"
967                 else
968                    EEXTRA="-Wl,-E"
969                    LD_RXLIB_A1="ld -b -q -n -o \$(@)"
970                    LD_RXLIB_A2="ld -b -q -n -o \$(@)"
971                    LD_RXLIB_UTILA="ld -b -q -n -o \$(@)"
972                    LD_RXLIB_B1=""
973                    LD_RXLIB_B2=""
974                    LD_RXLIB_UTILB=""
975                    DYNAMIC_LDFLAGS="-Wl,+s"
976                    SHL_LD="ld -b -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
977                 fi
978                 ;;
979         *ibm-aix3*)
980                 STATIC_LDFLAGS="-bnso -bI:/lib/syscalls.exp"
981                 LD_RXLIB_A1="ld -bnoentry -bM:SRE -bT:512 -bH:512 -bI:regina.exp -o \$(@)"
982                 LD_RXLIB_A2="ld -bnoentry -bM:SRE -bT:512 -bH:512 -bI:regina.exp -o \$(@)"
983                 LD_RXLIB_UTILA="ld -bnoentry -bM:SRE -bT:512 -bH:512 -bI:regina.exp -o \$(@)"
984                 LD_RXLIB_B1="${SHLPRE}${SHLFILE}${SHLPST} -lc"
985                 LD_RXLIB_B2="${SHLPRE}${SHLFILE}${SHLPST} -lc"
986                 LD_RXLIB_UTILB="${SHLPRE}${SHLFILE}${SHLPST} -lc"
987                 SHLPRE="lib"
988                 TEST1EXPORTS="-bE:test1.exp"
989                 TEST2EXPORTS="-bE:test2.exp"
990                 TEST1EXP="test1.exp"
991                 TEST2EXP="test2.exp"
992                 REGINAEXP="regina.exp"
993                 REGUTILEXP="regutil.exp"
994                 if test "$ac_cv_header_dlfcn_h" = "yes" -o "$HAVE_DLFCN_H" = "1"; then
995                         AIX_DYN="yes"
996                         DYN_COMP="-DDYNAMIC"
997                         SHL_LD="ld -o ${SHLPRE}${SHLFILE}${SHLPST} -bnoentry -bE:regina.exp -bM:SRE -bT:512 -bH:512 "'$('SHOFILES')'" -lc"
998                 else
999                         SHL_LD=" "'$('LIBEXE')'" "'$('LIBFLAGS')'" "'$('SHOFILES')'
1000                         DYN_COMP=""
1001                 fi
1002                 ;;
1003         *ibm-aix*)
1004 #                STATIC_LDFLAGS="-bnso -bI:/lib/syscalls.exp"
1005                 SHLPRE="lib"
1006                 if test "$ac_cv_prog_CC" = "gcc"; then
1007                    LD_RXLIB_A1="${CC} -shared ${LDFLAGS} -o \$(@)"
1008                    LD_RXLIB_A2="${CC} -shared ${LDFLAGS} -o \$(@)"
1009                    LD_RXLIB_UTILA="${CC} -shared ${LDFLAGS} -o \$(@)"
1010                    LD_RXLIB_B1="-L. -l${SHLFILE}"
1011                    LD_RXLIB_B2="-L. -l${SHLFILE}"
1012                    LD_RXLIB_UTILB="-L. -l${SHLFILE}"
1013                 else
1014                    LD_RXLIB_A1="ld -bnoentry -bM:SRE ${LDFLAGS} -o \$(@)"
1015                    LD_RXLIB_A2="ld -bnoentry -bM:SRE ${LDFLAGS} -o \$(@)"
1016                    LD_RXLIB_UTILA="ld -bnoentry -bM:SRE ${LDFLAGS} -o \$(@)"
1017                    LD_RXLIB_B1="${SHLPRE}${SHLFILE}${SHLPST} -lc"
1018                    LD_RXLIB_B2="${SHLPRE}${SHLFILE}${SHLPST} -lc"
1019                    LD_RXLIB_UTILB="${SHLPRE}${SHLFILE}${SHLPST} -lc"
1020                    TEST1EXPORTS="-bE:test1.exp"
1021                    TEST2EXPORTS="-bE:test2.exp"
1022                    TEST1EXP="test1.exp"
1023                    TEST2EXP="test2.exp"
1024                    REGUTILEXPORTS="-bE:regutil.exp"
1025                    REGUTILEXP="regutil.exp"
1026                 fi
1027                 REGINAEXP="regina.exp"
1028                 if test "$ac_cv_header_dlfcn_h" = "yes" -o "$HAVE_DLFCN_H" = "1"; then
1029                    AIX_DYN="yes"
1030                    DYN_COMP="-DDYNAMIC"
1031                    if test "$ac_cv_prog_CC" = "gcc"; then
1032                       SHL_LD="${CC} -shared -o ${SHLPRE}${SHLFILE}${SHLPST} -Wl,-bnoentry -Wl,-bE:regina.exp -Wl,-bM:SRE ${LDFLAGS} \$(SHOFILES) -lc \$(SHLIBS) \$(MH_MT_LIBS)"
1033                    else
1034                       SHL_LD="ld -o ${SHLPRE}${SHLFILE}${SHLPST} -bnoentry -bE:regina.exp -bM:SRE ${LDFLAGS} \$(SHOFILES) -lc \$(SHLIBS) \$(MH_MT_LIBS)"
1035                    fi
1036                 else
1037                    SHL_LD=" "'$('LIBEXE')'" "'$('LIBFLAGS')'" "'$('SHOFILES')'
1038                    DYN_COMP=""
1039                 fi
1040                 ;;
1041         *dec-osf*)
1042                 LD_RXLIB_A1="ld -shared -o \$(@)"
1043                 LD_RXLIB_A2="ld -shared -o \$(@)"
1044                 LD_RXLIB_UTILA="ld -shared -o \$(@)"
1045                 LD_RXLIB_B1="-lc -L. -l${SHLFILE}"
1046                 LD_RXLIB_B2="-lc -L. -l${SHLFILE}"
1047                 LD_RXLIB_UTILB="-lc -L. -l${SHLFILE}"
1048                 SHLPRE="lib"
1049                 SHL_LD="ld -o ${SHLPRE}${SHLFILE}${SHLPST} -shared -no_archive "'$('SHOFILES')'" -lc"
1050                 ;;
1051         *esix*)
1052                 LD_RXLIB_A1="ld -G -o \$(@)"
1053                 LD_RXLIB_A2="ld -G -o \$(@)"
1054                 LD_RXLIB_UTILA="ld -G -o \$(@)"
1055                 LD_RXLIB_B1=""
1056                 LD_RXLIB_B2=""
1057                 LD_RXLIB_UTILB=""
1058                 DYNAMIC_LDFLAGS=""
1059                 SHLPRE="lib"
1060                 SHL_LD="ld -G -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1061                 ;;
1062         *dgux*)
1063                 LD_RXLIB_A1="ld -G -o \$(@)"
1064                 LD_RXLIB_A2="ld -G -o \$(@)"
1065                 LD_RXLIB_UTILA="ld -G -o \$(@)"
1066                 LD_RXLIB_B1=""
1067                 LD_RXLIB_B2=""
1068                 LD_RXLIB_UTILB=""
1069                 DYNAMIC_LDFLAGS=""
1070                 SHLPRE="lib"
1071                 SHL_LD="ld -G -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1072                 ;;
1073         *pc-sco*)
1074                 LD_RXLIB_A1="ld -dy -G -o \$(@)"
1075                 LD_RXLIB_A2="ld -dy -G -o \$(@)"
1076                 LD_RXLIB_UTILA="ld -dy -G -o \$(@)"
1077                 LD_RXLIB_B1=""
1078                 LD_RXLIB_B2=""
1079                 LD_RXLIB_UTILB=""
1080                 DYNAMIC_LDFLAGS=""
1081                 SHLPRE="lib"
1082                 SHL_LD="ld -dy -G -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1083                 ;;
1084         *solaris*)
1085                 if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
1086                    LD_RXLIB_A1="$ac_cv_prog_CC -shared ${LDFLAGS} -o \$(@)"
1087                    LD_RXLIB_A2="$ac_cv_prog_CC -shared ${LDFLAGS} -o \$(@)"
1088                    LD_RXLIB_UTILA="$ac_cv_prog_CC -shared ${LDFLAGS} -o \$(@)"
1089                    SHL_LD="$ac_cv_prog_CC -shared ${LDFLAGS} -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1090                 else
1091                    LD_RXLIB_A1="ld -G ${LDFLAGS} -o \$(@)"
1092                    LD_RXLIB_A2="ld -G ${LDFLAGS} -o \$(@)"
1093                    LD_RXLIB_UTILA="ld -G ${LDFLAGS} -o \$(@)"
1094                    SHL_LD="ld -G ${LDFLAGS} -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1095                 fi
1096                 LD_RXLIB_B1=""
1097                 LD_RXLIB_B2=""
1098                 LD_RXLIB_UTILB=""
1099                 DYNAMIC_LDFLAGS=""
1100                 SHLPRE="lib"
1101                 ;;
1102         sparc*sunos*)
1103                 LD_RXLIB_A1="ld -o \$(@)"
1104                 LD_RXLIB_A2="ld -o \$(@)"
1105                 LD_RXLIB_UTILA="ld -o \$(@)"
1106                 LD_RXLIB_B1=""
1107                 LD_RXLIB_B2=""
1108                 LD_RXLIB_UTILB=""
1109                 SHLPRE="lib"
1110                 SHL_LD="ld -assert pure-text -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1111                 ;;
1112         *freebsd*)
1113                 LD_RXLIB_A1="ld -Bdynamic -Bshareable ${LDFLAGS} -o \$(@)"
1114                 LD_RXLIB_A2="ld -Bdynamic -Bshareable ${LDFLAGS} -o \$(@)"
1115                 LD_RXLIB_UTILA="ld -Bdynamic -Bshareable ${LDFLAGS} -o \$(@)"
1116                 LD_RXLIB_B1="-lc -L. -l${SHLFILE}"
1117                 LD_RXLIB_B2="-lc -L. -l${SHLFILE}"
1118                 LD_RXLIB_UTILB="-lc -L. -l${SHLFILE}"
1119                 SHLPRE="lib"
1120                 SHL_LD="ld -Bdynamic -Bshareable ${LDFLAGS} -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1121                 ;;
1122         *linux*)
1123                 LD_RXLIB_A1="${CC} -shared ${LDFLAGS} -o \$(@)"
1124                 LD_RXLIB_A2="${CC} -shared ${LDFLAGS} -o \$(@)"
1125                 LD_RXLIB_UTILA="${CC} -shared ${LDFLAGS} -o \$(@)"
1126 #                LD_RXLIB_B1="-L. -l${SHLFILE}"
1127 #                LD_RXLIB_B2="-L. -l${SHLFILE}"
1128                 LD_RXLIB_B1="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1129                 LD_RXLIB_B2="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1130                 LD_RXLIB_UTILB="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1131                 SHLPRE="lib"
1132                 SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI) -shared ${LDFLAGS} ${SHL_SCRIPT} \$(SHOFILES) -lc"
1133                 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1134                 OTHER_INSTALLS="installabilib"
1135                 USE_ABI="yes"
1136                 ;;
1137         *hurd*)
1138                 LD_RXLIB_A1="${CC} -shared -o \$(@)"
1139                 LD_RXLIB_A2="${CC} -shared -o \$(@)"
1140                 LD_RXLIB_UTILA="${CC} -shared -o \$(@)"
1141                 LD_RXLIB_B1="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1142                 LD_RXLIB_B2="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1143                 LD_RXLIB_UTILB="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1144                 SHLPRE="lib"
1145                 SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI) -shared ${SHL_SCRIPT} -Wl,-soname=${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI_MAJOR) \$(SHOFILES) -lc"
1146                 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1147                 OTHER_INSTALLS="installabilib"
1148                 USE_ABI="yes"
1149                 ;;
1150         *atheos*)
1151                 LD_RXLIB_A1="${CC} -shared ${LDFLAGS} -o \$(@)"
1152                 LD_RXLIB_A2="${CC} -shared ${LDFLAGS} -o \$(@)"
1153                 LD_RXLIB_UTILA="${CC} -shared ${LDFLAGS} -o \$(@)"
1154                 LD_RXLIB_B1="-L. -l${SHLFILE} "'$('BOTHLIBS')'
1155                 LD_RXLIB_B2="-L. -l${SHLFILE} "'$('BOTHLIBS')'
1156                 LD_RXLIB_UTILB="-L. -l${SHLFILE} "'$('BOTHLIBS')'
1157                 SHLPRE="lib"
1158                 SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST} -shared ${LDFLAGS} \$(SHOFILES) "'$('BOTHLIBS')'
1159                 SHL_BASE="${LIBPRE}${SHLFILE}${SHLPST}"
1160                 BASE_BINARY="atheosbinary"
1161                 ;;
1162         *beos*)
1163                 LD_RXLIB_A1="${CC} -Wl,-shared -nostart -Xlinker -o\$(@)"
1164                 LD_RXLIB_A2="${CC} -Wl,-shared -nostart -Xlinker -o\$(@)"
1165                 LD_RXLIB_UTILA="${CC} -Wl,-shared -nostart -Xlinker -o\$(@)"
1166                 LD_RXLIB_B1="-L. -l${SHLFILE}"
1167                 LD_RXLIB_B2="-L. -l${SHLFILE}"
1168                 LD_RXLIB_UTILB="-L. -l${SHLFILE}"
1169                 SHLPRE="lib"
1170                 SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST} -Wl,-shared -nostart -Xlinker \$(SHOFILES)"
1171                 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}"
1172                 BEOS_DYN="yes"
1173                 BASE_INSTALL="beosinstall"
1174                 BASE_BINARY="beosbinary"
1175                 OTHER_INSTALLS=""
1176                 ;;
1177         *nto-qnx*)
1178                 LD_RXLIB_A1="${CC} -shared -o \$(@)"
1179                 LD_RXLIB_A2="${CC} -shared -o \$(@)"
1180                 LD_RXLIB_UTILA="${CC} -shared -o \$(@)"
1181                 LD_RXLIB_B1="-L. -l${SHLFILE}"
1182                 LD_RXLIB_B2="-L. -l${SHLFILE}"
1183                 LD_RXLIB_UTILB="-L. -l${SHLFILE}"
1184                 SHLPRE="lib"
1185                 SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST} -shared \$(SHOFILES)"
1186                 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}"
1187                 ;;
1188         *skyos*)
1189                 LD_RXLIB_A1="${CC} -shared -o \$(@)"
1190                 LD_RXLIB_A2="${CC} -shared -o \$(@)"
1191                 LD_RXLIB_UTILA="${CC} -shared -o \$(@)"
1192                 LD_RXLIB_B1="-L. -l${SHLFILE}"
1193                 LD_RXLIB_B2="-L. -l${SHLFILE}"
1194                 LD_RXLIB_UTILB="-L. -l${SHLFILE}"
1195                 SHLPRE="lib"
1196                 SHL_LD="${CC} -o ${SHLPRE}${SHLFILE}${SHLPST} -shared \$(SHOFILES)"
1197                 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}"
1198                 ;;
1199         *qnx*)
1200                 LD_RXLIB_A1=""
1201                 LD_RXLIB_A2=""
1202                 LD_RXLIB_UTILA=""
1203                 LD_RXLIB_B1=""
1204                 LD_RXLIB_B2=""
1205                 LD_RXLIB_UTILB=""
1206                 SHLPRE=""
1207                 # set BUNDLE to unique junk names to stop the Makefile
1208                 # getting duplicate targets
1209                 BUNDLE=".junk2"
1210                 SHLPST=".junk"
1211                 SHL_LD=""
1212                 EEXTRA="-mf -N0x20000 -Q"
1213                 LIBPRE=""
1214                 LIBPST=".lib"
1215                 LIBFILE="rexx"
1216                 ;;
1217         *cygwin*)
1218                 LD_RXLIB_A1="dllwrap --target i386-cygwin32 --def ${srcdir}/test1_w32_dll.def --dllname rxtest1.dll -o \$(@)"
1219                 LD_RXLIB_A2="dllwrap --target i386-cygwin32 --def ${srcdir}/test2_w32_dll.def --dllname rxtest2.dll -o \$(@)"
1220                 LD_RXLIB_UTILA="dllwrap --target i386-cygwin32 --def ${srcdir}/regutil/regutil.def --dllname regutil.dll -o \$(@)"
1221                 LD_RXLIB_B1="-L. -lregina"
1222                 LD_RXLIB_B2="-L. -lregina"
1223                 LD_RXLIB_UTILB="-L. -lregina"
1224                 SHLPRE=""
1225                 SHL_LD="dllwrap --def ${srcdir}/regina_w32_dll.def --output-lib libregina.a --target i386-cygwin32 --dllname regina.dll -o regina.dll \$(SHOFILES)"
1226                 EEXTRA=""
1227                 LIBPRE="lib"
1228                 LIBPST=".a"
1229                 LIBFILE="rexx"
1230                 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}"
1231                 TEST1EXPORTS=""
1232                 TEST2EXPORTS=""
1233                 REGUTILEXPORTS=""
1234                 TEST1EXP="${srcdir}/test1_w32_dll.def"
1235                 TEST2EXP="${srcdir}/test2_w32_dll.def"
1236                 REGINAEXP="${srcdir}/regina_w32_dll.def"
1237                 REGUTILEXP="${srcdir}/regutil/regutil.def"
1238                 BASE_INSTALL="cygwininstall"
1239                 OTHER_INSTALLS=""
1240                 ;;
1241         *apple-darwin*)
1242                 # to test on platform other than real Mac OSX use: --build=ppc-apple-darwin10.1 --target=ppc-apple-darwin10.1
1243                 #
1244                 # Link switches for building "bundles"
1245                 #
1246 # MH                LD_RXLIB_A1="${CC} -bundle -flat_namespace -undefined suppress -o \$(@)"
1247 # MH                LD_RXLIB_A2="${CC} -bundle -flat_namespace -undefined suppress -o \$(@)"
1248                 EEXTRA="$valid_arch_flags"
1249                 LD_RXLIB_A1="${CC} ${EEXTRA} -dynamiclib ${LDFLAGS} -o \$(@)"
1250                 LD_RXLIB_A2="${CC} ${EEXTRA} -dynamiclib ${LDFLAGS} -o \$(@)"
1251                 LD_RXLIB_UTILA="${CC} ${EEXTRA} -dynamiclib ${LDFLAGS} -o \$(@)"
1252                 LD_RXLIB_B1="-L. -l${SHLFILE} -lc \$(SHLIBS)"
1253                 LD_RXLIB_B2="-L. -l${SHLFILE} -lc \$(SHLIBS)"
1254                 LD_RXLIB_UTILB="-L. -l${SHLFILE} -lc \$(SHLIBS)"
1255                 DYN_COMP="-DDYNAMIC -fno-common"
1256                 SHLPRE="lib"
1257 # MH                BUNDLE=".so"
1258                 BUNDLE=".junk"
1259                 SHL_LD="${CC} ${EEXTRA} -dynamiclib ${LDFLAGS} -install_name ${SHLPRE}${SHLFILE}${SHLPST} -o ${SHLPRE}${SHLFILE}${SHLPST} "'$('SHOFILES')'
1260                 SHL_BASE="${LIBPRE}${SHLFILE}${SHLPST}"
1261 # MH                EXTRATARGET="libregina$BUNDLE"
1262                 OTHER_INSTALLS="installlib"
1263                 ;;
1264         *)
1265                 MH_HOWTO_SHARED_LIBRARY()
1266                 MH_HOWTO_DYN_LINK()
1267                 ;;
1268 esac
1270 LIBFLAGS="cr ${LIBPRE}${LIBFILE}${LIBPST}"
1271 LIBLINK="-L. -l${LIBFILE}"
1272 LINKSHL="-L. -l${SHLFILE}"
1274 case "$target" in
1275         *hp-hpux*)
1276                 #
1277                 # For HPUX, we must link the "regina" executable with -lregina
1278                 # otherwise you can't move the shared library anywhere other
1279                 # than where it was built. Fix by PJM
1280                 #
1281                 LINKREG="${LINKSHL}"
1282                 ;;
1283         *cygwin*)
1284                 #
1285                 # For CygWin, we must link with the import library
1286                 # not the actual DLL
1287                 #
1288                 LINKREG="${LINKSHL}"
1289                 ;;
1290         *skyos*)
1291                 #
1292                 # SkyOS requires linking with -L. -lregina format
1293                 #
1294                 LINKREG="${LINKSHL}"
1295                 ;;
1296         *linux*)
1297                 LINKSHL="${SHLPRE}${SHLFILE}${SHLPST}.\$(ABI)"
1298                 LINKREG="${LINKSHL}"
1299                 ;;
1300         *)
1301                 LINKREG="${SHLPRE}${SHLFILE}${SHLPST}"
1302                 ;;
1303 esac
1305 if test "$SHL_LD" != ""; then
1306    SHL_LD="$SHL_LD \$(BOTHLIBS) \$(MH_MT_LIBS)"
1309 AC_MSG_CHECKING(if dynamic loading of external functions is supported)
1310 if test "$HAVE_DLFCN_H" = "1" -o "$ac_cv_header_dl_h" = "yes" -o "$ac_cv_header_dlfcn_h" = "yes" -o "$AIX_DYN" = "yes" -o "$BEOS_DYN" = "yes"; then
1311    SHL_TARGETS="${SHL_BASE} regina${binarybitprefix}${EXEEXT} ${SHLPRE}regutil${MODPST} ${SHLPRE}rxtest1${MODPST} ${SHLPRE}rxtest2${MODPST} $EXTRATARGET"
1312    EXECISER_DEP="${SHL_BASE}"
1313    OTHER_INSTALLS="regina${binarybitprefix}${EXEEXT} $OTHER_INSTALLS"
1314    AC_MSG_RESULT("yes")
1315 else
1316    SHL_TARGETS=""
1317    EXECISER_DEP="${STATICLIB}"
1318    OTHER_INSTALLS=""
1319    AC_MSG_RESULT("no")
1322 if test "$AIX_DYN" = "yes"; then
1323    STATICLIB=""
1324    LIBPST=".junk"
1325 else
1326    STATICLIB="${LIBPRE}${LIBFILE}${LIBPST}"
1329 RANLIB_DYNAMIC=""
1330 AC_SUBST(BASE_BINARY)
1331 AC_SUBST(BASE_INSTALL)
1332 AC_SUBST(BOTHLIBS)
1333 AC_SUBST(CC2O)
1334 AC_SUBST(CEXTRA)
1335 AC_SUBST(DYNAMIC_LDFLAGS)
1336 AC_SUBST(DYN_COMP)
1337 AC_SUBST(EEXTRA)
1338 AC_SUBST(EXECISER_DEP)
1339 AC_SUBST(GETOPT)
1340 AC_SUBST(LD_RXLIB_A1)
1341 AC_SUBST(LD_RXLIB_A2)
1342 AC_SUBST(LD_RXLIB_UTILA)
1343 AC_SUBST(LD_RXLIB_B1)
1344 AC_SUBST(LD_RXLIB_B2)
1345 AC_SUBST(LD_RXLIB_UTILB)
1346 AC_SUBST(LIBEXE)
1347 AC_SUBST(LIBFILE)
1348 AC_SUBST(LIBFLAGS)
1349 AC_SUBST(LIBLINK)
1350 AC_SUBST(LIBPRE)
1351 AC_SUBST(LIBPST)
1352 AC_SUBST(LINKSHL)
1353 AC_SUBST(LINKREG)
1354 AC_SUBST(O2SAVE)
1355 AC_SUBST(O2TSAVE)
1356 AC_SUBST(O2SHO)
1357 AC_SUBST(O2TSO)
1358 AC_SUBST(OBJ)
1359 AC_SUBST(OBJECTS)
1360 AC_SUBST(OSAVE)
1361 AC_SUBST(OTHER_INSTALLS)
1362 AC_SUBST(REGINAEXP)
1363 AC_SUBST(SAVE2O)
1364 AC_SUBST(SHLFILE)
1365 AC_SUBST(SHLIBS)
1366 AC_SUBST(SHLPRE)
1367 AC_SUBST(BUNDLE)
1368 AC_SUBST(SHL_LD)
1369 AC_SUBST(SHL_TARGETS)
1370 AC_SUBST(STATICLIB)
1371 AC_SUBST(STATIC_LDFLAGS)
1372 AC_SUBST(TEST1EXP)
1373 AC_SUBST(TEST1EXPORTS)
1374 AC_SUBST(TEST2EXP)
1375 AC_SUBST(TEST2EXPORTS)
1376 AC_SUBST(REGUTILEXP)
1377 AC_SUBST(REGUTILEXPORTS)
1378 AC_SUBST(USE_ABI)
1379 AC_SUBST(RANLIB_DYNAMIC)
1380 ])dnl
1382 dnl ---------------------------------------------------------------------------
1383 dnl Determine how to build shared libraries etc..
1384 dnl ---------------------------------------------------------------------------
1385 AC_DEFUN([MH_STATIC_LOADING],
1387 SHLPRE="lib"
1388 SHLPST=".a"
1389 MODPST=".a"
1390 LIBFILE="rexx"
1391 SHLFILE="regina"
1392 OSAVE=".o.save"
1393 OBJ="o"
1394 LIBPST=".a"
1395 LIBPRE="lib"
1396 LIBEXE="ar"
1397 GETOPT=""
1398 OBJECTS='$('OFILES')'
1399 STATIC_LDFLAGS=""
1400 AIX_DYN="no"
1401 BEOS_DYN="no"
1402 DYN_COMP="-DDYNAMIC"
1405 dnl set variables for linking
1407 SHL_LD=""
1408 TEST1EXPORTS=""
1409 TEST2EXPORTS=""
1410 TEST1EXP=""
1411 TEST2EXP=""
1412 REGINAEXP=""
1413 REGUTILEXPORTS=""
1414 REGUTILEXP=""
1417 # OTHER_INSTALLS is set to install a non-version numbered shared library
1418 # by default; ie. no .\$(ABI) suffix. If the regina executable is not built,
1419 # then there is no shared library. Set OTHER_INSTALLS="installabilib" if you
1420 # are building a version numbered shared library.
1421 OTHER_INSTALLS="installlib"
1422 BASE_INSTALL="installbase"
1423 BASE_BINARY="binarybase"
1424 USE_ABI="no"
1425 BUNDLE=""
1426 EXTRATARGET=""
1427 AC_REQUIRE([AC_CANONICAL_SYSTEM])
1428 case "$target" in
1429         *hp-hpux9*)
1430                 SYS_DEFS="-D_HPUX_SOURCE"
1431                 AC_DEFINE(SELECT_IN_TIME_H)
1432                 ;;
1433         *hp-hpux*)
1434                 SYS_DEFS="-D_HPUX_SOURCE"
1435                 ;;
1436         *ibm-aix*)
1437                 SYS_DEFS="-D_ALL_SOURCE -DAIX"
1438 #                STATIC_LDFLAGS="-bnso -bI:/lib/syscalls.exp"
1439                 ;;
1440         *dec-osf*)
1441                 if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
1442                    SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE"
1443                 else
1444                    SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800"
1445                 fi
1446                 ;;
1447         sparc*sunos*)
1448                 SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG"
1449                 ;;
1450         *atheos*)
1451                 BASE_BINARY="atheosbinary"
1452                 ;;
1453         *beos*)
1454                 BASE_INSTALL="beosinstall"
1455                 BASE_BINARY="beosbinary"
1456                 OTHER_INSTALLS=""
1457                 ;;
1458         *nto-qnx*)
1459                 ;;
1460         *qnx*)
1461                 SHLPRE=""
1462                 SHLPST=".lib"
1463                 MODPST=".lib"
1464                 # getting duplicate targets
1465                 BUNDLE=".junk2"
1466                 EEXTRA="-mf -N0x20000 -Q"
1467                 LIBPRE=""
1468                 LIBPST=".lib"
1469                 ;;
1470         *cygwin*)
1471                 LIBPRE="lib"
1472                 SHLPRE=""
1473                 LIBPST=".a"
1474                 BASE_INSTALL="cygwininstall"
1475                 BASE_BINARY="cygwinbinary"
1476                 OTHER_INSTALLS=""
1477                 ;;
1478         *apple-darwin*)
1479                 # to test use: --build=ppc-apple-darwin10.1 --target=ppc-apple-darwin10.1
1480                 #
1481                 # Link switches for building "bundles"
1482                 #
1483                 OTHER_INSTALLS="installlib installmacosx"
1484                 ;;
1485         *)
1486                 ;;
1487 esac
1488 LD_RXLIB_A1="${LIBEXE} cr \$(@)"
1489 LD_RXLIB_A2="${LIBEXE} cr \$(@)"
1490 LD_RXLIB_UTILA="${LIBEXE} cr \$(@)"
1491 LD_RXLIB_B1=""
1492 LD_RXLIB_B2=""
1493 LD_RXLIB_UTILB=""
1494 SHL_LD="${LIBEXE} cr ${SHLPRE}${SHLFILE}${SHLPST} \$(SHOFILES)"
1496 STATICLIB="${LIBPRE}${LIBFILE}${LIBPST}"
1498 LIBFLAGS="cr ${LIBPRE}${LIBFILE}${LIBPST}"
1499 LIBLINK="-L. -l${LIBFILE}"
1500 LINKSHL="-L. -l${LIBFILE}" # ensure we link to static library for execiser
1501 DYN_COMP="$DYN_COMP -DDYNAMIC_STATIC"
1503 SHL_BASE="${SHLPRE}${SHLFILE}${SHLPST}"
1504 SHL_TARGETS="${SHL_BASE}  ${SHLPRE}regutil${MODPST} regina${binarybitprefix}${EXEEXT} ${SHLPRE}rxtest1${MODPST} ${SHLPRE}rxtest2${MODPST} $EXTRATARGET"
1505 EXECISER_DEP="${STATICLIB}"
1506 OTHER_INSTALLS="regina${binarybitprefix}${EXEEXT} $OTHER_INSTALLS"
1507 RANLIB_DYNAMIC="-\$(RANLIB) \$(@)"
1509 dnl Settings for Regina test package
1511 AC_ARG_WITH(testpackage,
1512     [     --with-testpackage   enable static linking with Regina test external function packages],
1513     [with_test=$withval],
1514     [with_testpackage=no],
1516 MH_FUNC_LIBS=""
1517 if test "$with_testpackage" = "yes"; then
1518    MH_FUNC_LIBS="$MH_FUNC_LIBS ${SHLPRE}rxtest1${MODPST} ${SHLPRE}rxtest2${MODPST}"
1519    AC_DEFINE(HAVE_TEST_PACKAGE)
1520    EXECISER_DEP="${EXECISER_DEP} ${SHLPRE}rxtest1${MODPST} ${SHLPRE}rxtest2${MODPST}"
1523 dnl Settings for Patrick McPhee's Regutil (now included with Regina)
1525 AC_ARG_WITH(regutil,
1526     [     --with-regutil       enable static linking with RegUtil external function package],
1527     [with_regutil=$withval],
1528     [with_regutil=no],
1530 if test "$with_regutil" = "yes" -o "x$1" = "xregutil"; then
1531    MH_FUNC_LIBS="$MH_FUNC_LIBS ${SHLPRE}regutil${MODPST}"
1532    AC_DEFINE(HAVE_REXXUTIL_PACKAGE)
1535 dnl Settings for Rexx/Curses
1537 AC_ARG_WITH(rexxcurses,
1538     [     --with-rexxcurses    enable static linking with Rexx/Curses external function package],
1539     [with_rexxcurses=$withval],
1540     [with_rexxcurses=no],
1542 if test "$with_rexxcurses" = "yes"; then
1543         AC_CHECK_PROG(rxcurses_config, [rxcurses-config], yes, no)
1544         if test "$ac_cv_prog_rxcurses_config" = yes; then
1545            EXTRA_LIB=`rxcurses-config --libs`
1546            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1547            AC_DEFINE(HAVE_REXXCURSES_PACKAGE)
1548         else
1549            AC_MSG_ERROR(rxcurses-config not found. Cannot use --with-rexxcurses switch)
1550         fi
1553 dnl Settings for Rexx/Tk
1555 AC_ARG_WITH(rexxtk,
1556     [     --with-rexxtk        enable static linking with Rexx/Tk external function package],
1557     [with_rexxtk=$withval],
1558     [with_rexxtk=no],
1560 if test "$with_rexxtk" = "yes"; then
1561         AC_CHECK_PROG(rexxtk_config, [rexxtk-config], yes, no)
1562         if test "$ac_cv_prog_rexxtk_config" = yes; then
1563            EXTRA_LIB=`rexxtk-config --libs`
1564            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1565            AC_DEFINE(HAVE_REXXTK_PACKAGE)
1566         else
1567            AC_MSG_ERROR(rexxtk-config not found. Cannot use --with-rexxtk switch)
1568         fi
1571 dnl Settings for Rexx/Gd
1573 AC_ARG_WITH(rexxgd,
1574     [     --with-rexxgd        enable static linking with Rexx/Gd external function package],
1575     [with_rexxgd=$withval],
1576     [with_rexxgd=no],
1578 if test "$with_rexxgd" = "yes"; then
1579         AC_CHECK_PROG(rexxgd_config, [rexxgd-config], yes, no)
1580         if test "$ac_cv_prog_rexxgd_config" = yes; then
1581            EXTRA_LIB=`rexxgd-config --libs`
1582            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1583            AC_DEFINE(HAVE_REXXGD_PACKAGE)
1584         else
1585            AC_MSG_ERROR(rexxgd-config not found. Cannot use --with-rexxgd switch)
1586         fi
1589 dnl Settings for Rexx/CURL
1591 AC_ARG_WITH(rexxcurl,
1592     [     --with-rexxcurl      enable static linking with Rexx/CURL external function package],
1593     [with_rexxcurl=$withval],
1594     [with_rexxcurl=no],
1596 if test "$with_rexxcurl" = "yes"; then
1597         AC_CHECK_PROG(rexxcurl_config, [rexxcurl-config], yes, no)
1598         if test "$ac_cv_prog_rexxcurl_config" = yes; then
1599            EXTRA_LIB=`rexxcurl-config --libs`
1600            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1601            AC_DEFINE(HAVE_REXXCURL_PACKAGE)
1602         else
1603            AC_MSG_ERROR(rexxcurl-config not found. Cannot use --with-rexxcurl switch)
1604         fi
1607 dnl Settings for Rexx/SQL
1609 AC_ARG_WITH(rexxsql,
1610     [     --with-rexxsql       enable static linking with Rexx/SQL external function package],
1611     [with_rexxsql=$withval],
1612     [with_rexxsql=no],
1614 if test "$with_rexxsql" = "yes"; then
1615         AC_CHECK_PROG(rexxsql_config, [rexxsql-config], yes, no)
1616         if test "$ac_cv_prog_rexxsql_config" = yes; then
1617            EXTRA_LIB=`rexxsql-config --libs`
1618            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1619            AC_DEFINE(HAVE_REXXSQL_PACKAGE)
1620         else
1621            AC_MSG_ERROR(rexxsql-config not found. Cannot use --with-rexxsql switch)
1622         fi
1625 dnl Settings for Rexx/EEC
1627 AC_ARG_WITH(rexxeec,
1628     [     --with-rexxeec       enable static linking with Rexx/EEC external function package],
1629     [with_rexxeec=$withval],
1630     [with_rexxeec=no],
1632 if test "$with_rexxeec" = "yes"; then
1633         AC_CHECK_PROG(rexxeec_config, [rexxeec-config], yes, no)
1634         if test "$ac_cv_prog_rexxeec_config" = yes; then
1635            EXTRA_LIB=`rexxeec-config --libs`
1636            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1637            AC_DEFINE(HAVE_REXXEEC_PACKAGE)
1638         else
1639            AC_MSG_ERROR(rexxeec-config not found. Cannot use --with-rexxeec switch)
1640         fi
1643 dnl Settings for Rexx/ISAM
1645 AC_ARG_WITH(rexxisam,
1646     [     --with-rexxisam      enable static linking with Rexx/ISAM external function package],
1647     [with_rexxisam=$withval],
1648     [with_rexxisam=no],
1650 if test "$with_rexxisam" = "yes"; then
1651         AC_CHECK_PROG(rexxisam_config, [rexxisam-config], yes, no)
1652         if test "$ac_cv_prog_rexxisam_config" = yes; then
1653            EXTRA_LIB=`rexxisam-config --libs`
1654            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1655            AC_DEFINE(HAVE_REXXISAM_PACKAGE)
1656         else
1657            AC_MSG_ERROR(rexxisam-config not found. Cannot use --with-rexxisam switch)
1658         fi
1661 dnl Settings for RxSock
1663 AC_ARG_WITH(rxsock,
1664     [     --with-rxsock        enable static linking with RxSock external function package],
1665     [with_rxsock=$withval],
1666     [with_rxsock=no],
1668 if test "$with_rxsock" = "yes"; then
1669         AC_CHECK_PROG(rxsock_config, [rxsock-config], yes, no)
1670         if test "$ac_cv_prog_rxsock_config" = yes; then
1671            EXTRA_LIB=`rxsock-config --libs`
1672            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1673            AC_DEFINE(HAVE_RXSOCK_PACKAGE)
1674         else
1675            AC_MSG_ERROR(rxsock-config not found. Cannot use --with-rxsock switch)
1676         fi
1679 dnl Settings for Rexx/DW
1681 AC_ARG_WITH(rexxdw,
1682     [     --with-rexxdw        enable static linking with Rexx/DW external function package],
1683     [with_rexxdw=$withval],
1684     [with_rexxdw=no],
1686 if test "$with_rexxdw" = "yes"; then
1687         AC_CHECK_PROG(rexxdw_config, [rexxdw-config], yes, no)
1688         if test "$ac_cv_prog_rexxdw_config" = yes; then
1689            EXTRA_LIB=`rexxdw-config --libs`
1690            MH_FUNC_LIBS="$MH_FUNC_LIBS $EXTRA_LIB"
1691            AC_DEFINE(HAVE_REXXDW_PACKAGE)
1692         else
1693            AC_MSG_ERROR(rexxdw-config not found. Cannot use --with-rexxdw switch)
1694         fi
1697 LINKREG="${SHLPRE}${SHLFILE}${SHLPST} ${MH_FUNC_LIBS} ${SHLPRE}${SHLFILE}${SHLPST}"
1699 AC_SUBST(MH_FUNC_LIBS)
1700 AC_SUBST(BASE_BINARY)
1701 AC_SUBST(BASE_INSTALL)
1702 AC_SUBST(BOTHLIBS)
1703 AC_SUBST(CC2O)
1704 AC_SUBST(CEXTRA)
1705 AC_SUBST(DYNAMIC_LDFLAGS)
1706 AC_SUBST(DYN_COMP)
1707 AC_SUBST(EEXTRA)
1708 AC_SUBST(EXECISER_DEP)
1709 AC_SUBST(GETOPT)
1710 AC_SUBST(LD_RXLIB_A1)
1711 AC_SUBST(LD_RXLIB_A2)
1712 AC_SUBST(LD_RXLIB_UTILA)
1713 AC_SUBST(LD_RXLIB_B1)
1714 AC_SUBST(LD_RXLIB_B2)
1715 AC_SUBST(LD_RXLIB_UTILB)
1716 AC_SUBST(LIBEXE)
1717 AC_SUBST(LIBFILE)
1718 AC_SUBST(LIBFLAGS)
1719 AC_SUBST(LIBLINK)
1720 AC_SUBST(LINKSHL)
1721 AC_SUBST(LIBPRE)
1722 AC_SUBST(LIBPST)
1723 AC_SUBST(LINKREG)
1724 AC_SUBST(O2SAVE)
1725 AC_SUBST(O2SHO)
1726 AC_SUBST(OBJ)
1727 AC_SUBST(OBJECTS)
1728 AC_SUBST(OSAVE)
1729 AC_SUBST(OTHER_INSTALLS)
1730 AC_SUBST(REGINAEXP)
1731 AC_SUBST(SAVE2O)
1732 AC_SUBST(SHLFILE)
1733 AC_SUBST(SHLIBS)
1734 AC_SUBST(SHLPRE)
1735 AC_SUBST(BUNDLE)
1736 AC_SUBST(SHL_LD)
1737 AC_SUBST(SHL_TARGETS)
1738 AC_SUBST(STATICLIB)
1739 AC_SUBST(STATIC_LDFLAGS)
1740 AC_SUBST(TEST1EXP)
1741 AC_SUBST(TEST1EXPORTS)
1742 AC_SUBST(TEST2EXP)
1743 AC_SUBST(TEST2EXPORTS)
1744 AC_SUBST(REGUTILEXP)
1745 AC_SUBST(REGUTILEXPORTS)
1746 AC_SUBST(USE_ABI)
1747 AC_SUBST(RANLIB_DYNAMIC)
1751 dnl ---------------------------------------------------------------------------
1752 dnl Determines where rpm build files are located
1753 dnl ---------------------------------------------------------------------------
1754 AC_DEFUN([MH_CHECK_RPM],
1756 AC_CHECK_PROG(mh_rpm_exists, rpm, yes, no )
1757 if test "$mh_rpm_exists" = yes; then
1758    AC_MSG_CHECKING(where rpms are built)
1759    RPMTOPDIR=`rpm --eval "%{_topdir}"`
1760    AC_MSG_RESULT($RPMTOPDIR)
1761    AC_SUBST(RPMTOPDIR)
1765 dnl ---------------------------------------------------------------------------
1766 dnl Determines whether compiler supports long long
1767 dnl ---------------------------------------------------------------------------
1768 AC_DEFUN([MH_C_LONG_LONG],
1769 [AC_CACHE_CHECK(for long long int, mh_cv_c_long_long,
1770 [if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++"; then
1771   mh_cv_c_long_long=yes
1772   else
1773         AC_TRY_COMPILE(,[long long int i;],
1774    mh_cv_c_long_long=yes,
1775    mh_cv_c_long_long=no)
1776    fi])
1777    if test $mh_cv_c_long_long = yes; then
1778      AC_DEFINE(HAVE_LONG_LONG, 1, [compiler understands long long])
1779    fi
1782 dnl ---------------------------------------------------------------------------
1783 dnl Determines if socklen_t is valid
1784 dnl ---------------------------------------------------------------------------
1785 AC_DEFUN([MH_CHECK_TYPE_SOCKLEN_T],
1786 [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
1788   AC_TRY_COMPILE(
1789   [#include <sys/types.h>
1790    #include <sys/socket.h>],
1791   [socklen_t len = 42; return 0;],
1792   ac_cv_type_socklen_t=yes,
1793   ac_cv_type_socklen_t=no)
1795   if test $ac_cv_type_socklen_t = yes; then
1796     AC_DEFINE(HAVE_SOCKLEN_T, 1, [compiler has socklen_t])
1797   fi
1800 dnl ---------------------------------------------------------------------------
1801 dnl Determines which -arch flags valid on Mac OSX with gcc
1802 dnl ---------------------------------------------------------------------------
1803 AC_DEFUN([MH_CHECK_OSX_ARCH],
1804 [AC_MSG_CHECKING(for which Mac OSX -arch flags are supported)
1805 valid_arch_flags=""
1806 found_arch_flags=""
1807 arch_flags="ppc ppc64 x86_64 i386"
1808 for a in $arch_flags; do
1809   save_ldflags="$LDFLAGS"
1810   LDFLAGS="$LDFLAGS -arch $a"
1811   AC_LINK_IFELSE(
1812   [AC_LANG_PROGRAM([#include <stdio.h>],
1813   [exit(0)])],
1814   [valid_arch_flags="$valid_arch_flags -arch $a";found_arch_flags="$found_arch_flags $a"],
1815   [a="$a"]
1816   )
1817   LDFLAGS="$save_ldflags"
1818 done
1819 AC_MSG_RESULT($found_arch_flags)
1820 AC_SUBST(valid_arch_flags)
1823 dnl ---------------------------------------------------------------------------
1824 dnl Determines is struct statvfs contains f_mntfromname member
1825 dnl ---------------------------------------------------------------------------
1826 AC_DEFUN([MH_CHECK_F_MNTFROMNAME],
1827 [AC_CHECKING(if statvfs.f_mntfromname exists)
1828 AC_TRY_COMPILE([
1829   #include <sys/types.h>
1830   #include <sys/statvfs.h>
1831 ], [
1832   struct statvfs buf;
1833   char *p = buf.f_mntfromname;
1835   statvfs(".", &buf);
1836 ], [
1837   AC_DEFINE(HAVE_STATVFS_F_MNTFROMNAME,, Define if you have statvfs.f_mntfromname)
1838   AC_MSG_RESULT(yes)
1839 ], [
1840   AC_MSG_RESULT(no)