Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

root/branches/dp2mp-move/base/aclocal.m4

Revision 26175, 22.0 KB (checked in by jmpp@…, 19 months ago)

Merging landonf's r26135: Autoconf support for objc, foundation, and optionally-enabled -Werror.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1builtin(include,tcl.m4)
2builtin(include,objc.m4)
3builtin(include,foundation.m4)
4
5#------------------------------------------------------------------------
6# MP_CHECK_FRAMEWORK_COREFOUNDATION --
7#
8#       Check if CoreFoundation framework is available, define HAVE_FRAMEWORK_COREFOUNDATION if so.
9#
10# Arguments:
11#       None.
12#
13# Requires:
14#       None.
15#
16# Depends:
17#               AC_LANG_PROGRAM
18#
19# Results:
20#       Result is cached.
21#
22#       If CoreFoundation framework is available, defines the following variables:
23#               HAVE_FRAMEWORK_COREFOUNDATION
24#
25#------------------------------------------------------------------------
26AC_DEFUN(MP_CHECK_FRAMEWORK_COREFOUNDATION, [
27        FRAMEWORK_LIBS="-framework CoreFoundation"
28
29        AC_MSG_CHECKING([for CoreFoundation framework])
30
31        AC_CACHE_VAL(mp_cv_have_framework_corefoundation, [
32                ac_save_LIBS="$LIBS"
33                LIBS="$FRAMEWORK_LIBS $LIBS"
34               
35                AC_LINK_IFELSE([
36                        AC_LANG_PROGRAM([
37                                        #include <CoreFoundation/CoreFoundation.h>
38                                ], [
39                                        CFURLRef url = CFURLCreateWithFileSystemPath(NULL, CFSTR("/testing"), kCFURLPOSIXPathStyle, 1);
40                                        CFArrayRef bundles = CFBundleCreateBundlesFromDirectory(NULL, url, CFSTR("pkg"));
41                        ])
42                        ], [
43                                mp_cv_have_framework_corefoundation="yes"
44                        ], [
45                                mp_cv_have_framework_corefoundation="no"
46                        ]
47                )
48
49                LIBS="$ac_save_LIBS"
50        ])
51
52        AC_MSG_RESULT(${mp_cv_have_framework_corefoundation})
53
54        if test x"${mp_cv_have_framework_corefoundation}" = "xyes"; then
55                AC_DEFINE([HAVE_FRAMEWORK_COREFOUNDATION], [], [Define if CoreFoundation framework is available])
56        fi
57
58        AC_SUBST(HAVE_FRAMEWORK_COREFOUNDATION)
59])
60
61
62#------------------------------------------------------------------------
63# MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER --
64#
65#       Check if if the routine CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
66#       is available in CoreFoundation.
67#
68# Arguments:
69#       None.
70#
71# Requires:
72#       None.
73#
74# Depends:
75#               AC_LANG_PROGRAM
76#
77# Results:
78#       Result is cached.
79#
80#       If function CFNotificationCenterGetDarwinNotifyCenter is in the CoreFoundation framework, defines the following variables:
81#               HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
82#
83#------------------------------------------------------------------------
84AC_DEFUN(MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER, [
85        FRAMEWORK_LIBS="-framework CoreFoundation"
86
87        AC_MSG_CHECKING([for CFNotificationCenterGetDarwinNotifyCenter])
88
89        AC_CACHE_VAL(mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter, [
90                ac_save_LIBS="$LIBS"
91                LIBS="$FRAMEWORK_LIBS $LIBS"
92               
93                AC_LINK_IFELSE([
94                        AC_LANG_PROGRAM([
95                                        #include <CoreFoundation/CoreFoundation.h>
96                                ], [
97                                        CFNotificationCenterRef ref = CFNotificationCenterGetDarwinNotifyCenter();
98                        ])
99                        ], [
100                                mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="yes"
101                        ], [
102                                mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="no"
103                        ]
104                )
105
106                LIBS="$ac_save_LIBS"
107        ])
108
109        AC_MSG_RESULT(${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter})
110
111        if test x"${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter}" = "xyes"; then
112                AC_DEFINE([HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER], [], [Define if function CFNotificationCenterGetDarwinNotifyCenter in CoreFoundation framework])
113        fi
114
115        AC_SUBST(HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER)
116])
117
118
119#------------------------------------------------------------------------
120# MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION --
121#
122#       Check if SystemConfiguration framework is available, define HAVE_FRAMEWORK_SYSTEMCONFIGURATION if so.
123#
124# Arguments:
125#       None.
126#
127# Requires:
128#       None.
129#
130# Depends:
131#               AC_LANG_PROGRAM
132#
133# Results:
134#       Result is cached.
135#
136#       If SystemConfiguration framework is available, defines the following variables:
137#               HAVE_FRAMEWORK_SYSTEMCONFIGURATION
138#
139#------------------------------------------------------------------------
140AC_DEFUN(MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION, [
141        FRAMEWORK_LIBS="-framework SystemConfiguration"
142
143        AC_MSG_CHECKING([for SystemConfiguration framework])
144
145        AC_CACHE_VAL(mp_cv_have_framework_systemconfiguration, [
146                ac_save_LIBS="$LIBS"
147                LIBS="$FRAMEWORK_LIBS $LIBS"
148               
149                AC_LINK_IFELSE([
150                        AC_LANG_PROGRAM([
151                                        #include <SystemConfiguration/SystemConfiguration.h>
152                                ], [
153                                        int err = SCError();
154                                        SCDynamicStoreRef dsRef = SCDynamicStoreCreate(NULL, NULL, NULL, NULL);
155                        ])
156                        ], [
157                                mp_cv_have_framework_systemconfiguration="yes"
158                        ], [
159                                mp_cv_have_framework_systemconfiguration="no"
160                        ]
161                )
162
163                LIBS="$ac_save_LIBS"
164        ])
165
166        AC_MSG_RESULT(${mp_cv_have_framework_systemconfiguration})
167
168        if test x"${mp_cv_have_framework_systemconfiguration}" = "xyes"; then
169                AC_DEFINE([HAVE_FRAMEWORK_SYSTEMCONFIGURATION], [], [Define if SystemConfiguration framework is available])
170        fi
171
172        AC_SUBST(HAVE_FRAMEWORK_SYSTEMCONFIGURATION)
173])
174
175
176#------------------------------------------------------------------------
177# MP_CHECK_FRAMEWORK_IOKIT --
178#
179#       Check if IOKit framework is available, define HAVE_FRAMEWORK_IOKIT if so.
180#
181# Arguments:
182#       None.
183#
184# Requires:
185#       None.
186#
187# Depends:
188#               AC_LANG_PROGRAM
189#
190# Results:
191#       Result is cached.
192#
193#       If IOKit framework is available, defines the following variables:
194#               HAVE_FRAMEWORK_IOKIT
195#
196#------------------------------------------------------------------------
197AC_DEFUN(MP_CHECK_FRAMEWORK_IOKIT, [
198        FRAMEWORK_LIBS="-framework IOKit"
199
200        AC_MSG_CHECKING([for IOKit framework])
201
202        AC_CACHE_VAL(mp_cv_have_framework_iokit, [
203                ac_save_LIBS="$LIBS"
204                LIBS="$FRAMEWORK_LIBS $LIBS"
205               
206                AC_LINK_IFELSE([
207                        AC_LANG_PROGRAM([
208                                        #include <IOKit/IOKitLib.h>
209                                ], [
210                                        IOCreateReceivePort(0, NULL);
211                                        IORegisterForSystemPower(0, NULL, NULL, NULL);
212                        ])
213                        ], [
214                                mp_cv_have_framework_iokit="yes"
215                        ], [
216                                mp_cv_have_framework_iokit="no"
217                        ]
218                )
219
220                LIBS="$ac_save_LIBS"
221        ])
222
223        AC_MSG_RESULT(${mp_cv_have_framework_iokit})
224
225        if test x"${mp_cv_have_framework_iokit}" = "xyes"; then
226                AC_DEFINE([HAVE_FRAMEWORK_IOKIT], [], [Define if IOKit framework is available])
227        fi
228
229        AC_SUBST(HAVE_FRAMEWORK_IOKIT)
230])
231
232
233dnl This macro checks if the user specified a ports tree
234dnl explicitly. If not, search for it
235
236# MP_PATH_PORTSDIR(DEFAULT_PORTSDIR)
237#---------------------------------------
238 AC_DEFUN([MP_PATH_PORTSDIR],[
239        dnl For ease of reading, run after gcc has been found/configured
240        AC_REQUIRE([AC_PROG_CC])
241
242        AC_ARG_WITH(ports-dir, [AC_HELP_STRING([--with-ports-dir=DIR], [Specify alternate ports directory])], [ portsdir="$withval" ] )
243
244
245        AC_MSG_CHECKING([for ports tree])
246        if test "x$portsdir" != "x" ; then
247          if test -d "$portsdir" -a -e "$portsdir/PortIndex" ; then
248                :
249          else
250                AC_MSG_ERROR([$portsdir not a valid ports tree])
251          fi
252        else
253                dnl If the user didn't give a path, look for default
254                if test "x$1" != "x" ; then
255                  if test -d "$1" -a -e "$1/PortIndex" ; then
256                        portsdir=$1
257                  fi
258                fi
259        fi
260
261        if test "x$portsdir" != "x" ; then
262                AC_MSG_RESULT($portsdir)
263                PORTSDIR="$portsdir"
264                AC_SUBST(PORTSDIR)
265        else
266                AC_MSG_WARN([No ports tree found])
267        fi
268
269         ])
270
271
272# MP_PATH_MPCONFIGDIR
273#---------------------------------------
274AC_DEFUN([MP_PATH_MPCONFIGDIR],[
275        dnl if the user actually specified --prefix, shift
276        dnl mpconfigdir to $prefix/etc/macports
277        dnl     AC_REQUIRE([MP_PATH_PORTSDIR])
278       
279        AC_MSG_CHECKING([for MacPorts config directory])
280
281        mpconfigdir='${sysconfdir}/macports'
282
283        AC_MSG_RESULT([$mpconfigdir])
284        MPCONFIGDIR="$mpconfigdir"
285        AC_SUBST(MPCONFIGDIR)
286
287        ])
288
289# MP_CHECK_INSTALLUSER
290#-------------------------------------------------
291AC_DEFUN([MP_CHECK_INSTALLUSER],[
292        dnl if with user specifies --with-install-user,
293        dnl use it. otherwise default to platform defaults
294        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
295
296        AC_ARG_WITH(install-user, [AC_HELP_STRING([--with-install-user=USER], [Specify user ownership of installed files])], [ DSTUSR=$withval ] )
297       
298        AC_MSG_CHECKING([for install user])
299        if test "x$DSTUSR" = "x" ; then
300           DSTUSR=root
301        fi
302
303        AC_MSG_RESULT([$DSTUSR])
304        AC_SUBST(DSTUSR)
305])
306
307# MP_CHECK_INSTALLGROUP
308#-------------------------------------------------
309AC_DEFUN([MP_CHECK_INSTALLGROUP],[
310        dnl if with user specifies --with-install-group,
311        dnl use it. otherwise default to platform defaults
312        AC_REQUIRE([MP_CHECK_INSTALLUSER])
313
314        AC_ARG_WITH(install-group, [AC_HELP_STRING([--with-install-group=GROUP], [Specify group ownership of installed files])], [ DSTGRP=$withval ] )
315
316        AC_MSG_CHECKING([for install group])
317        if test "x$DSTGRP" = "x" ; then
318           
319           case $host_os in
320           darwin*)
321                DSTGRP="admin"
322                ;;
323           *)
324                DSTGRP="wheel"
325                ;;
326           esac
327        fi
328
329        AC_MSG_RESULT([$DSTGRP])
330        AC_SUBST(DSTGRP)
331])
332
333# MP_DIRECTORY_MODE
334#-------------------------------------------------
335AC_DEFUN([MP_DIRECTORY_MODE],[
336        dnl if with user specifies --with-directory-mode,
337        dnl use the specified permissions for ${prefix} directories
338        dnl otherwise use 0775
339        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
340
341        AC_ARG_WITH(directory-mode, [AC_HELP_STRING([--with-directory-mode=MODE], [Specify directory mode of installed directories])], [ DSTMODE=$withval ] )
342       
343        AC_MSG_CHECKING([what permissions to use for installation directories])
344        if test "x$DSTMODE" = "x" ; then
345           DSTMODE=0775
346        fi
347
348        AC_MSG_RESULT([$DSTMODE])
349        AC_SUBST(DSTMODE)
350])
351
352# MP_LIB_MD5
353#---------------------------------------
354# Check for an md5 implementation
355AC_DEFUN([MP_LIB_MD5],[
356
357        # Check for libmd, which is prefered
358        AC_CHECK_LIB([md], [MD5Update],[
359                AC_CHECK_HEADERS([md5.h], ,[
360                        case $host_os in
361                                darwin*)       
362                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
363                                        ;;
364                                *)     
365                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
366                                        ;;
367                        esac
368                        AC_MSG_ERROR([libmd was found, but md5.h is missing.])
369                ])
370                AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
371                MD5_LIBS="-lmd"]
372        )
373        if test "x$MD5_LIBS" = "x" ; then
374                # If libmd is not found, check for libcrypto from OpenSSL
375                AC_CHECK_LIB([crypto], [MD5_Update],[
376                        AC_CHECK_HEADERS([openssl/md5.h],,[
377                                case $host_os in
378                                        darwin*)       
379                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
380                                                ;;
381                                        *)     
382                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
383                                                ;;
384                                esac
385                                AC_MSG_ERROR([libcrypt was found, but header file openssl/md5.h is missing.])
386                        ])
387                        AC_DEFINE([HAVE_LIBCRYPTO],,[Define if you have the `crypto' library (-lcrypto).])
388                        MD5_LIBS="-lcrypto"
389                ], [
390                        AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
391                ])
392        fi
393        if test "x$MD5_LIBS" = "x"; then
394                AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
395        fi
396        AC_SUBST([MD5_LIBS])
397])
398
399dnl This macro checks for X11 presence. If the libraries are
400dnl present, so must the headers be. If nothing is present,
401dnl print a warning
402
403# MP_CHECK_X11
404# ---------------------
405AC_DEFUN([MP_CHECK_X11], [
406
407        AC_PATH_XTRA
408
409        # Check for libX11
410        AC_CHECK_LIB([X11], [XOpenDisplay],[
411                has_x_runtime=yes
412                ], [ has_x_runtime=no ], [-L/usr/X11R6/lib $X_LIBS])
413
414#       echo "------done---------"
415#       echo "x_includes=${x_includes}"
416#       echo "x_libraries=${x_libraries}"
417#       echo "no_x=${no_x}"
418#       echo "X_CFLAGS=${X_CFLAGS}"
419#       echo "X_LIBS=${X_LIBS}"
420#       echo "X_DISPLAY_MISSING=${X_DISPLAY_MISSING}"
421#       echo "has_x_runtime=${has_x_runtime}"
422#       echo "host_os=${host_os}"
423#       echo "------done---------"
424
425        state=
426
427        case "__${has_x_runtime}__${no_x}__" in
428                "__no__yes__")
429                # either the user said --without-x, or it was not found
430                # at all (runtime or headers)
431                        AC_MSG_WARN([X11 not available. You will not be able to use ports that use X11])
432                        state=0
433                        ;;
434                "__yes__yes__")
435                        state=1
436                        ;;
437                "__yes____")
438                        state=2
439                        ;;
440                *)
441                        state=3
442                        ;;
443        esac
444
445        case $host_os in
446                darwin*)       
447                        case $state in
448                                1)
449                                        cat <<EOF;
450Please install the X11 SDK packages from the
451Xcode Developer Tools CD
452EOF
453                                        AC_MSG_ERROR([Broken X11 install. No X11 headers])
454
455                                        ;;
456                                3)
457                                        cat <<EOF;
458Unknown configuration problem. Please install the X11 runtime
459and/or X11 SDK  packages from the Xcode Developer Tools CD
460EOF
461                                        AC_MSG_ERROR([Broken X11 install])
462                                        ;;
463                        esac
464                        ;;
465                *)     
466                        case $state in
467                                1)
468                                        cat <<EOF;
469Please install the X11 developer headers for your platform
470EOF
471                                        AC_MSG_ERROR([Broken X11 install. No X11 headers])
472
473                                        ;;
474                                3)
475                                        cat <<EOF;
476Unknown configuration problem. Please install the X11
477implementation for your platform
478EOF
479                                        AC_MSG_ERROR([Broken X11 install])
480                                        ;;
481                        esac
482                        ;;
483        esac
484
485])
486
487# MP_PROG_XAR
488#---------------------------------------
489AC_DEFUN([MP_PROG_XAR],[
490
491        AC_PATH_PROG([XAR], [xar], ,  [/usr/bin:/usr/sbin:/bin:/sbin])
492
493        if test "x$XAR" = "x" ; then
494                AC_CONFIG_SUBDIRS([src/programs/xar])
495                XAR='$(TOPSRCDIR)/src/programs/xar/xar'
496                REPLACEMENT_PROGS="$REPLACEMENT_PROGS xar"
497        fi
498
499        AC_SUBST(XAR)
500])
501
502# MP_PROG_DAEMONDO
503#---------------------------------------
504AC_DEFUN([MP_PROG_DAEMONDO],[
505        AC_REQUIRE([MP_CHECK_FRAMEWORK_COREFOUNDATION])
506        AC_REQUIRE([MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION])
507        AC_REQUIRE([MP_CHECK_FRAMEWORK_IOKIT])
508        AC_REQUIRE([MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER])
509       
510    AC_MSG_CHECKING(for whether we will build daemondo)
511    result=no
512        case $host_os in
513        darwin*)
514                if test "x$mp_cv_have_framework_corefoundation" == "xyes" &&
515                   test "x$mp_cv_have_framework_systemconfiguration" == "xyes" &&
516                   test "x$mp_cv_have_framework_iokit" == "xyes" &&
517                   test "x$mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter" == "xyes"; then
518                        result=yes
519                        EXTRA_PROGS="$EXTRA_PROGS daemondo"
520                        AC_CONFIG_FILES([src/programs/daemondo/Makefile])
521                fi
522                ;;
523        *)
524        esac
525        AC_MSG_RESULT(${result})
526])
527
528#------------------------------------------------------------------------
529# MP_TCL_PACKAGE_DIR --
530#
531#       Locate the correct directory for Tcl package installation
532#
533# Arguments:
534#       None.
535#
536# Requires:
537#       TCLVERSION must be set
538#       CYGPATH must be set
539#       TCLSH must be set
540#
541# Results:
542#
543#       Adds a --with-tclpackage switch to configure.
544#       Result is cached.
545#
546#       Substs the following vars:
547#               TCL_PACKAGE_DIR
548#------------------------------------------------------------------------
549
550AC_DEFUN(MP_TCL_PACKAGE_DIR, [
551    AC_MSG_CHECKING(for Tcl package directory)
552
553    AC_ARG_WITH(tclpackage, [  --with-tclpackage       Tcl package installation directory.], with_tclpackagedir=${withval})
554
555    if test x"${with_tclpackagedir}" != x ; then
556        ac_cv_c_tclpkgd=${with_tclpackagedir}
557    else
558        AC_CACHE_VAL(ac_cv_c_tclpkgd, [
559            # Use the value from --with-tclpackage, if it was given
560
561            if test x"${with_tclpackagedir}" != x ; then
562                echo "tclpackagedir"
563                ac_cv_c_tclpkgd=${with_tclpackagedir}
564            else
565                # On darwin we can do some intelligent guessing
566                case $host_os in
567                    darwin*)
568                        tcl_autopath=`echo 'puts -nonewline \$auto_path' | $TCLSH`
569                        for path in $tcl_autopath; do
570                            if test "$path" = "/Library/Tcl"; then
571                                ac_cv_c_tclpkgd="$path"
572                                break
573                            fi
574                            if test "$path" = "/System/Library/Tcl"; then
575                                if test -d "$path"; then
576                                    ac_cv_c_tclpkgd="$path"
577                                    break
578                                fi
579                            fi
580                        done
581                    ;;
582                esac
583                if test x"${ac_cv_c_tclpkgd}" = x ; then
584                    # Fudge a path from the first entry in the auto_path
585                    tcl_pkgpath=`echo 'puts -nonewline [[lindex \$auto_path 0]]' | $TCLSH`
586                    if test -d "$tcl_pkgpath"; then
587                        ac_cv_c_tclpkgd="$tcl_pkgpath"
588                    fi
589                    # If the first entry does not exist, do nothing
590                fi
591            fi
592        ])
593    fi
594
595    if test x"${ac_cv_c_tclpkgd}" = x ; then
596        AC_MSG_ERROR(Tcl package directory not found.  Please specify its location with --with-tclpackage)
597    else
598        AC_MSG_RESULT(${ac_cv_c_tclpkgd})
599    fi
600
601    # Convert to a native path and substitute into the output files.
602
603    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
604
605    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
606
607    AC_SUBST(TCL_PACKAGE_DIR)
608])
609
610# MP_PROG_TCLSH
611#---------------------------------------
612AC_DEFUN([MP_PROG_TCLSH],[
613
614
615        case $host_os in
616                *)
617                        # Otherwise, look for a non-versioned tclsh
618                        AC_PATH_PROG([TCLSH], [tclsh tclsh${TCL_VERSION}])
619                        ;;
620        esac
621        if test "x$TCLSH" = "x" ; then
622                AC_MSG_ERROR([Could not find tclsh])
623        fi
624
625        AC_SUBST(TCLSH)
626])
627
628# MP_TCL_PACKAGE
629#       Determine if a Tcl package is present.
630#
631# Arguments:
632#       Package name (may include the version)
633#
634# Syntax:
635#   MP_TCL_PACKAGE (package, [action-if-found], [action-if-not-found])
636#
637# Requires:
638#       TCLSH must be set
639#
640# Results:
641#       Execute action-if-found or action-if-not-found
642#---------------------------------------
643AC_DEFUN([MP_TCL_PACKAGE],[
644        AC_MSG_CHECKING([for Tcl $1 package])
645        package_present=`echo 'if {[[catch {package require $1}]]} {puts -nonewline 0} else {puts -nonewline 1}' | $TCLSH`
646        AS_IF([test "$package_present" = "1"], [$2], [$3])[]
647])
648
649# MP_TCL_THREAD_SUPPORT
650#       Determine if thread support is available in tclsh.
651#
652# Arguments:
653#       None.
654#
655# Requires:
656#       TCLSH must be set
657#
658# Results:
659#   Fails if thread support isn't available.
660#---------------------------------------
661AC_DEFUN([MP_TCL_THREAD_SUPPORT],[
662        AC_MSG_CHECKING([whether tclsh was compiled with threads])
663        tcl_threadenabled=`echo 'puts -nonewline [[info exists tcl_platform(threaded)]]' | $TCLSH`
664        if test "$tcl_threadenabled" = "1" ; then
665                AC_MSG_RESULT([yes])
666        else
667                AC_MSG_RESULT([no])
668                AC_MSG_ERROR([tcl wasn't compiled with threads enabled])
669        fi
670])
671
672# MP_LIBCURL_FLAGS
673#       Sets the flags to compile with libcurl.
674#
675# Arguments:
676#       None.
677#
678# Requires:
679#   curl-config or user parameters to define the flags.
680#
681# Results:
682#   defines some help strings.
683#   sets CFLAGS_LIBCURL and LDFLAGS_LIBCURL
684#---------------------------------------
685AC_DEFUN([MP_LIBCURL_FLAGS],[
686        AC_ARG_WITH(curlprefix,
687                   [  --with-curlprefix       base directory for the cURL install '/usr', '/usr/local',...],
688                   [  curlprefix=$withval ])
689
690        if test "x$curlprefix" = "x"; then
691                AC_PATH_PROG([CURL_CONFIG], [curl-config])
692        else
693                AC_PATH_PROG([CURL_CONFIG], [curl-config], , [$curlprefix/bin])
694        fi
695
696        if test "x$CURL_CONFIG" = "x"; then
697                AC_MSG_ERROR([cannot find curl-config. Is libcurl installed?])
698        fi
699
700        CFLAGS_LIBCURL=$($CURL_CONFIG --cflags)
701        # Due to a bug in dist, --arch flags are improperly supplied by curl-config.
702        # Get rid of them.
703        LDFLAGS_LIBCURL=$($CURL_CONFIG --libs | [sed 's/-arch [A-Za-z0-9]* //g'])
704
705        AC_SUBST(CFLAGS_LIBCURL)
706        AC_SUBST(LDFLAGS_LIBCURL)
707])
708
709# MP_LIBCURL_VERSION
710#       Determine the version of libcurl.
711#
712# Arguments:
713#       None.
714#
715# Requires:
716#       CURL must be set (AC_PATH_PROG(CURL, [curl], []))
717#
718# Results:
719#   sets libcurl_version to "0" or some number
720#---------------------------------------
721AC_DEFUN([MP_LIBCURL_VERSION],[
722        if test "x$CURL" = "x"; then
723                libcurl_version="0"
724        else
725                AC_MSG_CHECKING([libcurl version])
726                libcurl_version=`$CURL -V | sed '2,$d' | awk '{print $ 2}' | sed -e 's/\.//g' -e 's/-.*//g'`
727                AC_MSG_RESULT([$libcurl_version])
728        fi
729])
730
731
732dnl This macro tests if the compiler supports GCC's
733dnl __attribute__ syntax for unused variables/parameters
734AC_DEFUN([MP_COMPILER_ATTRIBUTE_UNUSED], [
735        AC_MSG_CHECKING([how to mark unused variables])
736        AC_COMPILE_IFELSE(
737                [AC_LANG_SOURCE([[int a __attribute__ ((unused));]])],
738                [AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])],
739                [AC_DEFINE(UNUSED, [])])
740
741        AC_MSG_RESULT([])
742       
743])
744
745dnl This macro ensures MP installation prefix bin/sbin paths are NOT in PATH
746dnl for configure to prevent potential problems when base/ code is updated
747dnl and ports are installed that would match needed items.
748AC_DEFUN([MP_PATH_SCAN],[
749        oldprefix=$prefix
750        if test "x$prefix" = "xNONE" ; then
751                prefix=$ac_default_prefix
752        fi
753        oldPATH=$PATH
754        newPATH=
755        as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
756        for as_dir in $oldPATH
757        do
758                IFS=$as_save_IFS
759                if test "x$as_dir" != "x$prefix/bin" &&
760                        test "x$as_dir" != "x$prefix/sbin"; then
761                        if test -z "$newPATH"; then
762                                newPATH=$as_dir
763                        else
764                                newPATH=$newPATH$PATH_SEPARATOR$as_dir
765                        fi
766                fi
767        done
768        PATH=$newPATH; export PATH
769        prefix=$oldprefix
770])
771
772dnl This macro tests for tar support of --no-same-owner
773AC_DEFUN([MP_TAR_NO_SAME_OWNER],[
774        AC_PATH_PROG(TAR, [tar])
775        AC_PATH_PROG(GNUTAR, [gnutar])
776       
777        AC_MSG_CHECKING([for which tar variant to use])
778        AS_IF([test -n "$GNUTAR"], [TAR_CMD=$GNUTAR], [TAR_CMD=$TAR])
779        AC_MSG_RESULT([$TAR_CMD])
780        AC_SUBST(TAR_CMD)
781
782        AC_MSG_CHECKING([for $TAR_CMD --no-same-owner support])
783        [no_same_owner_support=`$TAR_CMD --help 2>&1 | grep no-same-owner`]
784        if test -z "$no_same_owner_support" ; then
785                AC_MSG_RESULT([no])
786        else
787                AC_MSG_RESULT([yes])
788                TAR_CMD="$TAR_CMD --no-same-owner"
789        fi
790])
791
792#------------------------------------------------------------------------
793# MP_CHECK_READLINK_IS_P1003_1A --
794#
795#       Check if readlink conforms to POSIX 1003.1a standard, define
796#       READLINK_IS_NOT_P1003_1A if it doesn't.
797#
798# Arguments:
799#       None.
800#
801# Requires:
802#       None.
803#
804# Depends:
805#               AC_LANG_PROGRAM
806#
807# Results:
808#       Result is cached.
809#
810#       If readlink doesn't conform to POSIX 1003.1a, defines the following variables:
811#               READLINK_IS_NOT_P1003_1A
812#
813#------------------------------------------------------------------------
814AC_DEFUN(MP_CHECK_READLINK_IS_P1003_1A, [
815        AC_MSG_CHECKING([if readlink conforms to POSIX 1003.1a])
816
817        AC_CACHE_VAL(mp_cv_readlink_is_posix_1003_1a, [
818                AC_COMPILE_IFELSE([
819                        AC_LANG_PROGRAM([
820                                        #include <unistd.h>
821                                        ssize_t readlink(const char *, char *, size_t);
822                                ], [
823                        ])
824                        ], [
825                                mp_cv_readlink_is_posix_1003_1a="yes"
826                        ], [
827                                mp_cv_readlink_is_posix_1003_1a="no"
828                        ]
829                )
830        ])
831
832        AC_MSG_RESULT(${mp_cv_readlink_is_posix_1003_1a})
833
834        if test x"${mp_cv_readlink_is_posix_1003_1a}" = "xno"; then
835                AC_DEFINE([READLINK_IS_NOT_P1003_1A], [], [Define to 1 if readlink does not conform with POSIX 1003.1a (where third argument is a size_t and return value is a ssize_t)])
836        fi
837
838        AC_SUBST(READLINK_IS_NOT_P1003_1A)
839])
840
841#------------------------------------------------------------------------
842# MP_WERROR --
843#
844#       Enable -Werror
845#
846# Arguments:
847#       None.
848#
849# Requires:
850#       none
851#
852# Depends:
853#       none
854#
855# Results:
856#       Substitutes WERROR_CFLAGS variable
857#------------------------------------------------------------------------
858AC_DEFUN([MP_WERROR],[
859        AC_REQUIRE([AC_PROG_CC])
860        AC_ARG_ENABLE(werror, AC_HELP_STRING([--enable-werror], [Add -Werror to CFLAGS. Used for development.]), [enable_werror=${enableval}], [enable_werror=no])
861        if test x"$enable_werror" != "xno"; then
862                CFLAGS_WERROR="-Werror"
863        else
864                CFLAGS_WERROR=""
865        fi
866        AC_SUBST([CFLAGS_WERROR])
867])
Note: See TracBrowser for help on using the browser.