source: trunk/base/aclocal.m4 @ 52395

Last change on this file since 52395 was 52395, checked in by toby@…, 11 years ago

change universal_archs default on 10.6+, regen

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 25.1 KB
Line 
1dnl $Id: aclocal.m4 52395 2009-06-15 20:07:44Z toby@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, [AS_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
292# MP_CHECK_NOROOTPRIVILEGES
293#-------------------------------------------------
294AC_DEFUN([MP_CHECK_NOROOTPRIVILEGES],[
295        dnl if with user specifies --with-no-root-privileges,
296        dnl use current user and group.
297        dnl use ~/Library/Tcl as Tcl package directory
298                AC_REQUIRE([MP_PATH_MPCONFIGDIR])
299
300        AC_ARG_WITH(no-root-privileges, [AS_HELP_STRING([--with-no-root-privileges],[Specify that MacPorts should be installed in your home directory])], [ROOTPRIVS=$withval] )
301
302        if test "${ROOTPRIVS+set}" = set; then
303
304                # Set install-user to current user
305                AC_MSG_CHECKING([for install user])
306                DSTUSR=`id -un`
307                AC_MSG_RESULT([$DSTUSR])
308                AC_SUBST(DSTUSR)
309               
310                # Set install-group to current user
311                AC_MSG_CHECKING([for install group])
312                DSTGRP=`id -gn`
313                AC_MSG_RESULT([$DSTGRP])
314                AC_SUBST(DSTGRP)
315
316                # Set Tcl package directory to ~/Library/Tcl
317            AC_MSG_CHECKING(for Tcl package directory)
318                ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
319            # Convert to a native path and substitute into the output files.
320            PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
321            TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
322            AC_SUBST(TCL_PACKAGE_DIR)
323                if test x"${ac_cv_c_tclpkgd}" = x ; then
324                        AC_MSG_ERROR(Tcl package directory not found.  Please specify its location with --with-tclpackage)
325            else
326                        AC_MSG_RESULT(${ac_cv_c_tclpkgd})
327            fi
328        fi
329
330])
331
332# MP_CHECK_RUNUSER
333#-------------------------------------------------
334AC_DEFUN([MP_CHECK_RUNUSER],[
335        dnl if with user specifies --with-macports-user,
336        dnl use it. otherwise default to platform defaults
337       AC_REQUIRE([MP_PATH_MPCONFIGDIR])
338
339        AC_ARG_WITH(macports-user, [AS_HELP_STRING([--with-macports-user=USER],[Specify user to drop privileges to, if possible, during compiles etc.])], [ RUNUSR=$withval ] )
340       
341        AC_MSG_CHECKING([for macports user])
342        if test "x$RUNUSR" = "x" ; then
343# dropping root privs is still buggy
344#          RUNUSR=`id -un`
345           RUNUSR=root
346        fi
347
348        AC_MSG_RESULT([$RUNUSR])
349        AC_SUBST(RUNUSR)
350])
351
352
353# MP_SHARED_DIRECTORY
354#-------------------------------------------------
355AC_DEFUN([MP_SHARED_DIRECTORY],[
356        dnl if with user specifies --with-shared-directory,
357        dnl use 0775 permissions for ${prefix} directories
358        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
359
360        AC_ARG_WITH(shared-directory, [AS_HELP_STRING([--with-shared-directory],[Use 0775 permissions for installed directories])], [ SHAREDIR=$withval ] )
361
362        if test "${SHAREDIR+set}" = set; then   
363                AC_MSG_CHECKING([whether to share the install directory with all members of the install group])
364            DSTMODE=0775
365
366                AC_MSG_RESULT([$DSTMODE])
367                AC_SUBST(DSTMODE)
368        fi
369])
370
371# MP_CHECK_INSTALLUSER
372#-------------------------------------------------
373AC_DEFUN([MP_CHECK_INSTALLUSER],[
374        dnl if with user specifies --with-install-user,
375        dnl use it. otherwise default to platform defaults
376        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
377
378        AC_ARG_WITH(install-user, [AS_HELP_STRING([--with-install-user=USER],[Specify user ownership of installed files])], [ DSTUSR=$withval ] )
379       
380        AC_MSG_CHECKING([for install user])
381        if test "x$DSTUSR" = "x" ; then
382           DSTUSR=root
383        fi
384
385        AC_MSG_RESULT([$DSTUSR])
386        AC_SUBST(DSTUSR)
387])
388
389# MP_CHECK_INSTALLGROUP
390#-------------------------------------------------
391AC_DEFUN([MP_CHECK_INSTALLGROUP],[
392        dnl if with user specifies --with-install-group,
393        dnl use it. otherwise default to platform defaults
394        AC_REQUIRE([MP_CHECK_INSTALLUSER])
395
396        AC_ARG_WITH(install-group, [AS_HELP_STRING([--with-install-group=GROUP],[Specify group ownership of installed files])], [ DSTGRP=$withval ] )
397
398        AC_MSG_CHECKING([for install group])
399        if test "x$DSTGRP" = "x" ; then
400           
401           case $host_os in
402           darwin*)
403                DSTGRP="admin"
404                ;;
405           freebsd*)
406                DSTGRP="wheel"
407                ;;
408           linux*)
409                DSTGRP="root"
410                ;;
411           *)
412                DSTGRP="wheel"
413                ;;
414           esac
415        fi
416
417        AC_MSG_RESULT([$DSTGRP])
418        AC_SUBST(DSTGRP)
419])
420
421# MP_DIRECTORY_MODE
422#-------------------------------------------------
423AC_DEFUN([MP_DIRECTORY_MODE],[
424        dnl if with user specifies --with-directory-mode,
425        dnl use the specified permissions for ${prefix} directories
426        dnl otherwise use 0755
427        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
428
429        AC_ARG_WITH(directory-mode, [AS_HELP_STRING([--with-directory-mode=MODE],[Specify directory mode of installed directories])], [ DSTMODE=$withval ] )
430       
431        AC_MSG_CHECKING([what permissions to use for installation directories])
432        if test "x$DSTMODE" = "x" ; then
433           DSTMODE=0755
434        fi
435
436        AC_MSG_RESULT([$DSTMODE])
437        AC_SUBST(DSTMODE)
438])
439
440# MP_PATH_APPLICATIONS
441#---------------------------------------
442AC_DEFUN([MP_PATH_APPLICATIONS],[
443        AC_REQUIRE([MP_CHECK_INSTALLUSER])
444
445    AC_ARG_WITH(applications-dir,[AS_HELP_STRING([--with-applications-dir],[Applications installation directory.])], MPAPPLICATIONSDIR=${withval})
446
447    oldprefix=$prefix
448    if test "x$prefix" = "xNONE" ; then
449        prefix=$ac_default_prefix
450    fi
451    AC_MSG_CHECKING([for Applications installation directory])
452
453        if test "x$MPAPPLICATIONSDIR" = "x" ; then
454            if test "$DSTUSR" = "root" ; then
455                MPAPPLICATIONSDIR="/Applications/MacPorts"
456            else
457                MPAPPLICATIONSDIR="$(eval echo ~$DSTUSR)/Applications/MacPorts"
458            fi
459        fi
460
461        AC_MSG_RESULT([$MPAPPLICATIONSDIR])
462    AC_SUBST(MPAPPLICATIONSDIR)
463    prefix=$oldprefix
464])
465
466# MP_PATH_FRAMEWORKS
467#---------------------------------------
468AC_DEFUN([MP_PATH_FRAMEWORKS],[
469        AC_REQUIRE([MP_CHECK_INSTALLUSER])
470
471    AC_ARG_WITH(frameworks-dir,[AS_HELP_STRING([--with-frameworks-dir],[Frameworks installation directory.])], MPFRAMEWORKSDIR=${withval})
472
473    oldprefix=$prefix
474    if test "x$prefix" = "xNONE" ; then
475        prefix=$ac_default_prefix
476    fi
477    AC_MSG_CHECKING([for Frameworks installation directory])
478
479        if test "x$MPFRAMEWORKSDIR" = "x" ; then
480                MPFRAMEWORKSDIR="${prefix}/Library/Frameworks"
481        fi
482
483        AC_MSG_RESULT([$MPFRAMEWORKSDIR])
484    AC_SUBST(MPFRAMEWORKSDIR)
485    prefix=$oldprefix
486])
487
488
489# MP_UNIVERSAL_OPTIONS
490#---------------------------------------
491AC_DEFUN([MP_UNIVERSAL_OPTIONS],[
492  AC_ARG_WITH(universal-archs,[AS_HELP_STRING([--with-universal-archs="CPU"],[Universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
493
494  if test "x$UNIVERSAL_ARCHS" = "x"; then
495    case "$MACOSX_VERSION" in
496      10.[[0-5]]*)
497        UNIVERSAL_ARCHS="i386 ppc"
498        ;;
499      *)
500        UNIVERSAL_ARCHS="x86_64 i386"
501        ;;
502    esac
503  fi
504
505  AC_MSG_CHECKING([for Universal CPU architectures])
506  AC_MSG_RESULT([$UNIVERSAL_ARCHS])
507  AC_SUBST(UNIVERSAL_ARCHS)
508])
509
510# MP_LIB_MD5
511#---------------------------------------
512# Check for an md5 implementation
513AC_DEFUN([MP_LIB_MD5],[
514
515        # Check for libmd, which is prefered
516        AC_CHECK_LIB([md], [MD5Update],[
517                AC_CHECK_HEADERS([md5.h], ,[
518                        case $host_os in
519                                darwin*)       
520                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
521                                        ;;
522                                *)     
523                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
524                                        ;;
525                        esac
526                        AC_MSG_ERROR([libmd was found, but md5.h is missing.])
527                ])
528                AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
529                MD5_LIBS="-lmd"]
530        )
531        if test "x$MD5_LIBS" = "x" ; then
532                # If libmd is not found, check for libcrypto from OpenSSL
533                AC_CHECK_LIB([crypto], [MD5_Update],[
534                        AC_CHECK_HEADERS([openssl/md5.h],,[
535                                case $host_os in
536                                        darwin*)       
537                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
538                                                ;;
539                                        *)     
540                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
541                                                ;;
542                                esac
543                                AC_MSG_ERROR([libcrypt was found, but header file openssl/md5.h is missing.])
544                        ])
545                        AC_DEFINE([HAVE_LIBCRYPTO],,[Define if you have the `crypto' library (-lcrypto).])
546                        MD5_LIBS="-lcrypto"
547                ], [
548                        AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
549                ])
550        fi
551        if test "x$MD5_LIBS" = "x"; then
552                AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
553        fi
554        AC_SUBST([MD5_LIBS])
555])
556
557# MP_PROG_DAEMONDO
558#---------------------------------------
559AC_DEFUN([MP_PROG_DAEMONDO],[
560        AC_REQUIRE([MP_CHECK_FRAMEWORK_COREFOUNDATION])
561        AC_REQUIRE([MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION])
562        AC_REQUIRE([MP_CHECK_FRAMEWORK_IOKIT])
563        AC_REQUIRE([MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER])
564       
565    AC_MSG_CHECKING(for whether we will build daemondo)
566    result=no
567        case $host_os in
568        darwin*)
569                if test "x$mp_cv_have_framework_corefoundation" == "xyes" &&
570                   test "x$mp_cv_have_framework_systemconfiguration" == "xyes" &&
571                   test "x$mp_cv_have_framework_iokit" == "xyes" &&
572                   test "x$mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter" == "xyes"; then
573                        result=yes
574                        EXTRA_PROGS="$EXTRA_PROGS daemondo"
575                        AC_CONFIG_FILES([src/programs/daemondo/Makefile])
576                fi
577                ;;
578        *)
579        esac
580        AC_MSG_RESULT(${result})
581])
582
583#------------------------------------------------------------------------
584# MP_TCL_PACKAGE_DIR --
585#
586#       Locate the correct directory for Tcl package installation
587#
588# Arguments:
589#       None.
590#
591# Requires:
592#       TCLVERSION must be set
593#       CYGPATH must be set
594#       TCLSH must be set
595#
596# Results:
597#
598#       Adds a --with-tclpackage switch to configure.
599#       Result is cached.
600#
601#       Substs the following vars:
602#               TCL_PACKAGE_DIR
603#------------------------------------------------------------------------
604
605AC_DEFUN(MP_TCL_PACKAGE_DIR, [
606        AC_REQUIRE([MP_CHECK_INSTALLUSER])
607
608    AC_MSG_CHECKING(for Tcl package directory)
609
610    AC_ARG_WITH(tclpackage, [  --with-tclpackage       Tcl package installation directory.], with_tclpackagedir=${withval})
611
612    if test x"${with_tclpackagedir}" != x ; then
613        ac_cv_c_tclpkgd=${with_tclpackagedir}
614    else
615        AC_CACHE_VAL(ac_cv_c_tclpkgd, [
616            # Use the value from --with-tclpackage, if it was given
617
618            if test x"${with_tclpackagedir}" != x ; then
619                echo "tclpackagedir"
620                ac_cv_c_tclpkgd=${with_tclpackagedir}
621            else
622                # On darwin we can do some intelligent guessing
623                case $host_os in
624                    darwin*)
625                        tcl_autopath=`echo 'puts -nonewline \$auto_path' | $TCLSH`
626                        for path in $tcl_autopath; do
627                        if test "$DSTUSR" = "root" ; then
628                            if test "$path" = "/Library/Tcl"; then
629                                ac_cv_c_tclpkgd="$path"
630                                break
631                            fi
632                            if test "$path" = "/System/Library/Tcl"; then
633                                if test -d "$path"; then
634                                    ac_cv_c_tclpkgd="$path"
635                                    break
636                                fi
637                            fi
638                        elif test "$path" = "~/Library/Tcl"; then
639                            ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
640                            break
641                        fi
642                        done
643                    ;;
644                esac
645                if test x"${ac_cv_c_tclpkgd}" = x ; then
646                    # Fudge a path from the first entry in the auto_path
647                    tcl_pkgpath=`echo 'puts -nonewline [[lindex \$auto_path 0]]' | $TCLSH`
648                    if test -d "$tcl_pkgpath"; then
649                        ac_cv_c_tclpkgd="$tcl_pkgpath"
650                    fi
651                    # If the first entry does not exist, do nothing
652                fi
653            fi
654        ])
655    fi
656
657    if test x"${ac_cv_c_tclpkgd}" = x ; then
658        AC_MSG_ERROR(Tcl package directory not found.  Please specify its location with --with-tclpackage)
659    else
660        AC_MSG_RESULT(${ac_cv_c_tclpkgd})
661    fi
662
663    # Convert to a native path and substitute into the output files.
664
665    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
666
667    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
668
669    AC_SUBST(TCL_PACKAGE_DIR)
670])
671
672# MP_PROG_TCLSH
673#---------------------------------------
674AC_DEFUN([MP_PROG_TCLSH],[
675
676
677        case $host_os in
678                freebsd*)
679                        # FreeBSD installs a dummy tclsh (annoying)
680                        # Look for a real versioned tclsh with threads first
681                        # Look for a real versioned tclsh without threads second
682                        AC_PATH_PROG([TCLSH], [tclsh${TCL_VERSION}-threads tclsh${TCL_VERSION} tclsh])
683                        ;;
684                *)
685                        # Otherwise, look for a non-versioned tclsh
686                        AC_PATH_PROG([TCLSH], [tclsh tclsh${TCL_VERSION}])
687                        ;;
688        esac
689        if test "x$TCLSH" = "x" ; then
690                AC_MSG_ERROR([Could not find tclsh])
691        fi
692
693        AC_SUBST(TCLSH)
694])
695
696# MP_TCL_PACKAGE
697#       Determine if a Tcl package is present.
698#
699# Arguments:
700#       Package name (may include the version)
701#
702# Syntax:
703#   MP_TCL_PACKAGE (package, [action-if-found], [action-if-not-found])
704#
705# Requires:
706#       TCLSH must be set
707#
708# Results:
709#       Execute action-if-found or action-if-not-found
710#---------------------------------------
711AC_DEFUN([MP_TCL_PACKAGE],[
712        AC_MSG_CHECKING([for Tcl $1 package])
713        package_present=`echo 'if {[[catch {package require $1}]]} {puts -nonewline 0} else {puts -nonewline 1}' | $TCLSH`
714        AS_IF([test "$package_present" = "1"], [$2], [$3])[]
715])
716
717# MP_TCL_THREAD_SUPPORT
718#       Determine if thread support is available in tclsh.
719#
720# Arguments:
721#       None.
722#
723# Requires:
724#       TCLSH must be set
725#
726# Results:
727#   Fails if thread support isn't available.
728#---------------------------------------
729AC_DEFUN([MP_TCL_THREAD_SUPPORT],[
730        AC_MSG_CHECKING([whether tclsh was compiled with threads])
731        tcl_threadenabled=`echo 'puts -nonewline [[info exists tcl_platform(threaded)]]' | $TCLSH`
732        if test "$tcl_threadenabled" = "1" ; then
733                AC_MSG_RESULT([yes])
734        else
735                AC_MSG_RESULT([no])
736                AC_MSG_ERROR([tcl wasn't compiled with threads enabled])
737        fi
738])
739
740# MP_LIBCURL_FLAGS
741#       Sets the flags to compile with libcurl.
742#
743# Arguments:
744#       None.
745#
746# Requires:
747#   curl-config or user parameters to define the flags.
748#
749# Results:
750#   defines some help strings.
751#   sets CFLAGS_LIBCURL and LDFLAGS_LIBCURL
752#---------------------------------------
753AC_DEFUN([MP_LIBCURL_FLAGS],[
754        AC_ARG_WITH(curlprefix,
755                   [  --with-curlprefix       base directory for the cURL install '/usr', '/usr/local',...],
756                   [  curlprefix=$withval ])
757
758        if test "x$curlprefix" = "x"; then
759                AC_PATH_PROG([CURL_CONFIG], [curl-config])
760        else
761                AC_PATH_PROG([CURL_CONFIG], [curl-config], , [$curlprefix/bin])
762        fi
763
764        if test "x$CURL_CONFIG" = "x"; then
765                AC_MSG_ERROR([cannot find curl-config. Is libcurl installed?])
766        fi
767
768        CFLAGS_LIBCURL=$($CURL_CONFIG --cflags)
769        # Due to a bug in dist, --arch flags are improperly supplied by curl-config.
770        # Get rid of them.
771        LDFLAGS_LIBCURL=$($CURL_CONFIG --libs | [sed 's/-arch [A-Za-z0-9_]* //g'])
772
773        AC_SUBST(CFLAGS_LIBCURL)
774        AC_SUBST(LDFLAGS_LIBCURL)
775])
776
777dnl This macro tests if the compiler supports GCC's
778dnl __attribute__ syntax for unused variables/parameters
779AC_DEFUN([MP_COMPILER_ATTRIBUTE_UNUSED], [
780        AC_MSG_CHECKING([how to mark unused variables])
781        AC_COMPILE_IFELSE(
782                [AC_LANG_SOURCE([[int a __attribute__ ((unused));]])],
783                [AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])],
784                [AC_DEFINE(UNUSED, [])])
785
786        AC_MSG_RESULT([])
787       
788])
789
790dnl This macro ensures MP installation prefix bin/sbin paths are NOT in PATH
791dnl for configure to prevent potential problems when base/ code is updated
792dnl and ports are installed that would match needed items.
793AC_DEFUN([MP_PATH_SCAN],[
794        oldprefix=$prefix
795        if test "x$prefix" = "xNONE" ; then
796                prefix=$ac_default_prefix
797        fi
798        oldPATH=$PATH
799        newPATH=
800        as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
801        for as_dir in $oldPATH
802        do
803                IFS=$as_save_IFS
804                if test "x$as_dir" != "x$prefix/bin" &&
805                        test "x$as_dir" != "x$prefix/sbin"; then
806                        if test -z "$newPATH"; then
807                                newPATH=$as_dir
808                        else
809                                newPATH=$newPATH$PATH_SEPARATOR$as_dir
810                        fi
811                fi
812        done
813        PATH=$newPATH; export PATH
814        prefix=$oldprefix
815])
816
817dnl This macro tests for sed support of -E (BSD) or -r (GNU)
818AC_DEFUN([MP_SED_EXTENDED_REGEXP],[
819        AC_PATH_PROG(SED, [sed])
820
821        if test "x$SED" = "x"; then
822                AC_MSG_ERROR([cannot find sed. Is sed installed?])
823        fi
824
825        AC_MSG_CHECKING([which sed flag to use for extended regexp])
826        [any_sed_flag=`echo foo | $SED    -e s/foo+/OK/ 2>&1 | grep OK`]
827        [bsd_sed_flag=`echo foo | $SED -E -e s/foo+/OK/ 2>&1 | grep OK`]
828        [gnu_sed_flag=`echo foo | $SED -r -e s/foo+/OK/ 2>&1 | grep OK`]
829        if test "x$any_sed_flag" = "xOK" ; then
830                AC_MSG_RESULT([none])
831                SED_EXT=
832        elif test "x$bsd_sed_flag" = "xOK" ; then
833                AC_MSG_RESULT([-E (BSD)])
834                SED_EXT=-E
835        elif test "x$gnu_sed_flag" = "xOK" ; then
836                AC_MSG_RESULT([-r (GNU)])
837                SED_EXT=-r
838        else
839                AC_MSG_RESULT([not available])
840                SED_EXT='N/A'
841        fi
842        AC_SUBST(SED_EXT)
843])
844
845dnl This macro tests for tar support of --no-same-owner
846AC_DEFUN([MP_TAR_NO_SAME_OWNER],[
847        AC_PATH_PROG(TAR, [tar])
848        AC_PATH_PROG(GNUTAR, [gnutar])
849       
850        AC_MSG_CHECKING([for which tar variant to use])
851        AS_IF([test -n "$GNUTAR"], [TAR_CMD=$GNUTAR], [TAR_CMD=$TAR])
852        AC_MSG_RESULT([$TAR_CMD])
853        AC_SUBST(TAR_CMD)
854
855        AC_MSG_CHECKING([for $TAR_CMD --no-same-owner support])
856        [no_same_owner_support=`$TAR_CMD --help 2>&1 | grep no-same-owner`]
857        if test -z "$no_same_owner_support" ; then
858                AC_MSG_RESULT([no])
859        else
860                AC_MSG_RESULT([yes])
861                TAR_CMD="$TAR_CMD --no-same-owner"
862        fi
863])
864
865#------------------------------------------------------------------------
866# MP_CHECK_READLINK_IS_P1003_1A --
867#
868#       Check if readlink conforms to POSIX 1003.1a standard, define
869#       READLINK_IS_NOT_P1003_1A if it doesn't.
870#
871# Arguments:
872#       None.
873#
874# Requires:
875#       None.
876#
877# Depends:
878#               AC_LANG_PROGRAM
879#
880# Results:
881#       Result is cached.
882#
883#       If readlink doesn't conform to POSIX 1003.1a, defines the following variables:
884#               READLINK_IS_NOT_P1003_1A
885#
886#------------------------------------------------------------------------
887AC_DEFUN(MP_CHECK_READLINK_IS_P1003_1A, [
888        AC_MSG_CHECKING([if readlink conforms to POSIX 1003.1a])
889
890        AC_CACHE_VAL(mp_cv_readlink_is_posix_1003_1a, [
891                AC_COMPILE_IFELSE([
892                        AC_LANG_PROGRAM([
893                                        #include <unistd.h>
894                                        ssize_t readlink(const char *, char *, size_t);
895                                ], [
896                        ])
897                        ], [
898                                mp_cv_readlink_is_posix_1003_1a="yes"
899                        ], [
900                                mp_cv_readlink_is_posix_1003_1a="no"
901                        ]
902                )
903        ])
904
905        AC_MSG_RESULT(${mp_cv_readlink_is_posix_1003_1a})
906
907        if test x"${mp_cv_readlink_is_posix_1003_1a}" = "xno"; then
908                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)])
909        fi
910
911        AC_SUBST(READLINK_IS_NOT_P1003_1A)
912])
913
914#------------------------------------------------------------------------
915# MP_WERROR --
916#
917#       Enable -Werror
918#
919# Arguments:
920#       None.
921#
922# Requires:
923#       none
924#
925# Depends:
926#       none
927#
928# Results:
929#       Substitutes WERROR_CFLAGS variable
930#------------------------------------------------------------------------
931AC_DEFUN([MP_WERROR],[
932        AC_REQUIRE([AC_PROG_CC])
933        AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],[Add -Werror to CFLAGS. Used for development.]), [enable_werror=${enableval}], [enable_werror=no])
934        if test x"$enable_werror" != "xno"; then
935                CFLAGS_WERROR="-Werror"
936        else
937                CFLAGS_WERROR=""
938        fi
939        AC_SUBST([CFLAGS_WERROR])
940])
Note: See TracBrowser for help on using the repository browser.