source: trunk/base/aclocal.m4 @ 57343

Last change on this file since 57343 was 55417, checked in by jmr@…, 11 years ago

remove objc.m4 since it conflicts with autoconf 2.64, regenerate configure

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