source: trunk/base/aclocal.m4 @ 33499

Last change on this file since 33499 was 33499, checked in by afb@…, 12 years ago

add placeholder configuration for applications/frameworks installation directory

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