source: trunk/base/aclocal.m4 @ 77864

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

autoconf: look for CommonCrypto, libmd/FreeBSD and libcrypto/OpenSSL (with headers)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 28.6 KB
Line 
1dnl $Id: aclocal.m4 77864 2011-04-15 07:29:48Z afb@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           RUNUSR=nobody
358        fi
359
360        AC_MSG_RESULT([$RUNUSR])
361        AC_SUBST(RUNUSR)
362])
363
364
365# MP_SHARED_DIRECTORY
366#-------------------------------------------------
367AC_DEFUN([MP_SHARED_DIRECTORY],[
368        dnl if with user specifies --with-shared-directory,
369        dnl use 0775 permissions for ${prefix} directories
370        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
371
372        AC_ARG_WITH(shared-directory, [AS_HELP_STRING([--with-shared-directory],[Use 0775 permissions for installed directories])], [ SHAREDIR=$withval ] )
373
374        if test "${SHAREDIR+set}" = set; then   
375                AC_MSG_CHECKING([whether to share the install directory with all members of the install group])
376            DSTMODE=0775
377
378                AC_MSG_RESULT([$DSTMODE])
379                AC_SUBST(DSTMODE)
380        fi
381])
382
383# MP_CHECK_INSTALLUSER
384#-------------------------------------------------
385AC_DEFUN([MP_CHECK_INSTALLUSER],[
386        dnl if with user specifies --with-install-user,
387        dnl use it. otherwise default to platform defaults
388        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
389
390        AC_ARG_WITH(install-user, [AS_HELP_STRING([--with-install-user=USER],[Specify user ownership of installed files])], [ DSTUSR=$withval ] )
391       
392        AC_MSG_CHECKING([for install user])
393        if test "x$DSTUSR" = "x" ; then
394           DSTUSR=root
395        fi
396
397        AC_MSG_RESULT([$DSTUSR])
398        AC_SUBST(DSTUSR)
399])
400
401# MP_CHECK_INSTALLGROUP
402#-------------------------------------------------
403AC_DEFUN([MP_CHECK_INSTALLGROUP],[
404        dnl if with user specifies --with-install-group,
405        dnl use it. otherwise default to platform defaults
406        AC_REQUIRE([MP_CHECK_INSTALLUSER])
407
408        AC_ARG_WITH(install-group, [AS_HELP_STRING([--with-install-group=GROUP],[Specify group ownership of installed files])], [ DSTGRP=$withval ] )
409
410        AC_MSG_CHECKING([for install group])
411        if test "x$DSTGRP" = "x" ; then
412           
413           case $host_os in
414           darwin*)
415                DSTGRP="admin"
416                ;;
417           freebsd*)
418                DSTGRP="wheel"
419                ;;
420           linux*)
421                DSTGRP="root"
422                ;;
423           *)
424                DSTGRP="wheel"
425                ;;
426           esac
427        fi
428
429        AC_MSG_RESULT([$DSTGRP])
430        AC_SUBST(DSTGRP)
431])
432
433# MP_DIRECTORY_MODE
434#-------------------------------------------------
435AC_DEFUN([MP_DIRECTORY_MODE],[
436        dnl if with user specifies --with-directory-mode,
437        dnl use the specified permissions for ${prefix} directories
438        dnl otherwise use 0755
439        AC_REQUIRE([MP_PATH_MPCONFIGDIR])
440
441        AC_ARG_WITH(directory-mode, [AS_HELP_STRING([--with-directory-mode=MODE],[Specify directory mode of installed directories])], [ DSTMODE=$withval ] )
442       
443        AC_MSG_CHECKING([what permissions to use for installation directories])
444        if test "x$DSTMODE" = "x" ; then
445           DSTMODE=0755
446        fi
447
448        AC_MSG_RESULT([$DSTMODE])
449        AC_SUBST(DSTMODE)
450])
451
452# MP_PATH_APPLICATIONS
453#---------------------------------------
454AC_DEFUN([MP_PATH_APPLICATIONS],[
455        AC_REQUIRE([MP_CHECK_INSTALLUSER])
456
457    AC_ARG_WITH(applications-dir,[AS_HELP_STRING([--with-applications-dir],[Applications installation directory.])], MPAPPLICATIONSDIR=${withval})
458
459    oldprefix=$prefix
460    if test "x$prefix" = "xNONE" ; then
461        prefix=$ac_default_prefix
462    fi
463    AC_MSG_CHECKING([for Applications installation directory])
464
465        if test "x$MPAPPLICATIONSDIR" = "x" ; then
466            if test "$DSTUSR" = "root" ; then
467                MPAPPLICATIONSDIR="/Applications/MacPorts"
468            else
469                MPAPPLICATIONSDIR="$(eval echo ~$DSTUSR)/Applications/MacPorts"
470            fi
471        fi
472
473        AC_MSG_RESULT([$MPAPPLICATIONSDIR])
474    AC_SUBST(MPAPPLICATIONSDIR)
475    prefix=$oldprefix
476])
477
478# MP_PATH_FRAMEWORKS
479#---------------------------------------
480AC_DEFUN([MP_PATH_FRAMEWORKS],[
481        AC_REQUIRE([MP_CHECK_INSTALLUSER])
482
483    AC_ARG_WITH(frameworks-dir,[AS_HELP_STRING([--with-frameworks-dir],[Frameworks installation directory.])], MPFRAMEWORKSDIR=${withval})
484
485    oldprefix=$prefix
486    if test "x$prefix" = "xNONE" ; then
487        prefix=$ac_default_prefix
488    fi
489    AC_MSG_CHECKING([for Frameworks installation directory])
490
491        if test "x$MPFRAMEWORKSDIR" = "x" ; then
492                MPFRAMEWORKSDIR="${prefix}/Library/Frameworks"
493        fi
494
495        AC_MSG_RESULT([$MPFRAMEWORKSDIR])
496    AC_SUBST(MPFRAMEWORKSDIR)
497    prefix=$oldprefix
498])
499
500
501# MP_UNIVERSAL_OPTIONS
502#---------------------------------------
503AC_DEFUN([MP_UNIVERSAL_OPTIONS],[
504  AC_ARG_WITH(universal-archs,[AS_HELP_STRING([--with-universal-archs="CPU"],[Universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
505
506  if test "x$UNIVERSAL_ARCHS" = "x"; then
507    case "$MACOSX_VERSION" in
508      10.[[0-5]]*)
509        UNIVERSAL_ARCHS="i386 ppc"
510        ;;
511      *)
512        UNIVERSAL_ARCHS="x86_64 i386"
513        ;;
514    esac
515  fi
516
517  AC_MSG_CHECKING([for Universal CPU architectures])
518  AC_MSG_RESULT([$UNIVERSAL_ARCHS])
519  AC_SUBST(UNIVERSAL_ARCHS)
520])
521
522# MP_LIB_MD5
523#---------------------------------------
524# Check for an md5 implementation
525AC_DEFUN([MP_LIB_MD5],[
526
527        # Check for libmd from FreeBSD, which is preferred
528        AC_CHECK_LIB([md], [MD5File],[
529                AC_CHECK_HEADERS([md5.h sha.h], ,[
530                        AC_MSG_ERROR([libmd was found, but md5.h or sha.h is missing.])
531                ])
532                ac_save_LIBS="$LIBS"
533                LIBS="-lmd $LIBS"
534                AC_CHECK_FUNCS([SHA1_File])
535                LIBS="$ac_save_LIBS"
536                AC_CHECK_HEADERS([ripemd.h sha256.h])
537                AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
538                MD5_LIBS="-lmd"]
539        )
540        if test "x$MD5_LIBS" = "x"; then
541                # If libmd is not found, check for libcrypto from OpenSSL
542                AC_CHECK_LIB([crypto], [MD5_Update],[
543                        AC_CHECK_HEADERS([openssl/md5.h openssl/sha.h], ,[
544                                AC_MSG_ERROR([libcrypto was found, but openssl/md5.h or openssl/sha.h is missing.])
545                        ])
546                        AC_CHECK_HEADERS([openssl/ripemd.h])
547                        ac_save_LIBS="$LIBS"
548                        LIBS="-lcrypto $LIBS"
549                        AC_CHECK_FUNCS([SHA256_Update])
550                        LIBS="$ac_save_LIBS"
551                        AC_DEFINE([HAVE_LIBCRYPTO], ,[Define if you have the `crypto' library (-lcrypto).])
552                        MD5_LIBS="-lcrypto"]
553                )
554        fi
555        if test "x$MD5_LIBS" = "x"; then
556                AC_MSG_ERROR([Neither CommonCrypto, libmd nor libcrypto were found. A working md5 implementation is required.])
557        fi
558        AC_SUBST([MD5_LIBS])
559])
560
561# MP_PROG_DAEMONDO
562#---------------------------------------
563AC_DEFUN([MP_PROG_DAEMONDO],[
564        AC_REQUIRE([MP_CHECK_FRAMEWORK_COREFOUNDATION])
565        AC_REQUIRE([MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION])
566        AC_REQUIRE([MP_CHECK_FRAMEWORK_IOKIT])
567        AC_REQUIRE([MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER])
568       
569    AC_MSG_CHECKING(for whether we will build daemondo)
570    result=no
571        case $host_os in
572        darwin*)
573                if test "x$mp_cv_have_framework_corefoundation" == "xyes" &&
574                   test "x$mp_cv_have_framework_systemconfiguration" == "xyes" &&
575                   test "x$mp_cv_have_framework_iokit" == "xyes" &&
576                   test "x$mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter" == "xyes"; then
577                        result=yes
578                        EXTRA_PROGS="$EXTRA_PROGS daemondo"
579                        AC_CONFIG_FILES([src/programs/daemondo/Makefile])
580                fi
581                ;;
582        *)
583        esac
584        AC_MSG_RESULT(${result})
585])
586
587#------------------------------------------------------------------------
588# MP_TCL_PACKAGE_DIR --
589#
590#       Locate the correct directory for Tcl package installation
591#
592# Arguments:
593#       None.
594#
595# Requires:
596#       TCLVERSION must be set
597#       CYGPATH must be set
598#       TCLSH must be set
599#
600# Results:
601#
602#       Adds a --with-tclpackage switch to configure.
603#       Result is cached.
604#
605#       Substs the following vars:
606#               TCL_PACKAGE_DIR
607#------------------------------------------------------------------------
608
609AC_DEFUN(MP_TCL_PACKAGE_DIR, [
610        AC_REQUIRE([MP_CHECK_INSTALLUSER])
611
612    AC_MSG_CHECKING(for Tcl package directory)
613
614    AC_ARG_WITH(tclpackage, [  --with-tclpackage       Tcl package installation directory.], with_tclpackagedir=${withval})
615
616    if test x"${with_tclpackagedir}" != x ; then
617        ac_cv_c_tclpkgd=${with_tclpackagedir}
618    else
619        AC_CACHE_VAL(ac_cv_c_tclpkgd, [
620            # Use the value from --with-tclpackage, if it was given
621
622            if test x"${with_tclpackagedir}" != x ; then
623                echo "tclpackagedir"
624                ac_cv_c_tclpkgd=${with_tclpackagedir}
625            else
626                # On darwin we can do some intelligent guessing
627                case $host_os in
628                    darwin*)
629                        tcl_autopath=`echo 'puts -nonewline \$auto_path' | $TCLSH`
630                        for path in $tcl_autopath; do
631                        if test "$DSTUSR" = "root" ; then
632                            if test "$path" = "/Library/Tcl"; then
633                                ac_cv_c_tclpkgd="$path"
634                                break
635                            fi
636                            if test "$path" = "/System/Library/Tcl"; then
637                                if test -d "$path"; then
638                                    ac_cv_c_tclpkgd="$path"
639                                    break
640                                fi
641                            fi
642                        elif test "$path" = "~/Library/Tcl"; then
643                            ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
644                            break
645                        fi
646                        done
647                    ;;
648                esac
649                if test x"${ac_cv_c_tclpkgd}" = x ; then
650                    # Fudge a path from the first entry in the auto_path
651                    tcl_pkgpath=`echo 'puts -nonewline [[lindex \$auto_path 0]]' | $TCLSH`
652                    if test -d "$tcl_pkgpath"; then
653                        ac_cv_c_tclpkgd="$tcl_pkgpath"
654                    fi
655                    # If the first entry does not exist, do nothing
656                fi
657            fi
658        ])
659    fi
660
661    if test x"${ac_cv_c_tclpkgd}" = x ; then
662        AC_MSG_ERROR(Tcl package directory not found.  Please specify its location with --with-tclpackage)
663    else
664        AC_MSG_RESULT(${ac_cv_c_tclpkgd})
665    fi
666
667    # Convert to a native path and substitute into the output files.
668
669    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
670
671    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
672
673    AC_SUBST(TCL_PACKAGE_DIR)
674])
675
676# MP_PROG_TCLSH
677#---------------------------------------
678AC_DEFUN([MP_PROG_TCLSH],[
679
680
681        case $host_os in
682                freebsd*)
683                        # FreeBSD installs a dummy tclsh (annoying)
684                        # Look for a real versioned tclsh with threads first
685                        # Look for a real versioned tclsh without threads second
686                        AC_PATH_PROG([TCLSH], [tclsh${TCL_VERSION}-threads tclsh${TCL_VERSION} tclsh])
687                        ;;
688                *)
689                        # Otherwise, look for a non-versioned tclsh
690                        AC_PATH_PROG([TCLSH], [tclsh tclsh${TCL_VERSION}])
691                        ;;
692        esac
693        if test "x$TCLSH" = "x" ; then
694                AC_MSG_ERROR([Could not find tclsh])
695        fi
696
697        AC_SUBST(TCLSH)
698])
699
700# MP_TCL_PACKAGE
701#       Determine if a Tcl package is present.
702#
703# Arguments:
704#       Package name (may include the version)
705#
706# Syntax:
707#   MP_TCL_PACKAGE (package, [action-if-found], [action-if-not-found])
708#
709# Requires:
710#       TCLSH must be set
711#
712# Results:
713#       Execute action-if-found or action-if-not-found
714#---------------------------------------
715AC_DEFUN([MP_TCL_PACKAGE],[
716        AC_MSG_CHECKING([for Tcl $1 package])
717        package_present=`echo 'if {[[catch {package require $1}]]} {puts -nonewline 0} else {puts -nonewline 1}' | $TCLSH`
718        AS_IF([test "$package_present" = "1"], [$2], [$3])[]
719])
720
721# MP_TCL_THREAD_SUPPORT
722#       Determine if thread support is available in tclsh.
723#
724# Arguments:
725#       None.
726#
727# Requires:
728#       TCLSH must be set
729#
730# Results:
731#   Fails if thread support isn't available.
732#---------------------------------------
733AC_DEFUN([MP_TCL_THREAD_SUPPORT],[
734        AC_MSG_CHECKING([whether tclsh was compiled with threads])
735        tcl_threadenabled=`echo 'puts -nonewline [[info exists tcl_platform(threaded)]]' | $TCLSH`
736        if test "$tcl_threadenabled" = "1" ; then
737                AC_MSG_RESULT([yes])
738        else
739                AC_MSG_RESULT([no])
740                AC_MSG_ERROR([tcl wasn't compiled with threads enabled])
741        fi
742])
743
744# MP_LIBCURL_FLAGS
745#       Sets the flags to compile with libcurl.
746#
747# Arguments:
748#       None.
749#
750# Requires:
751#   curl-config or user parameters to define the flags.
752#
753# Results:
754#   defines some help strings.
755#   sets CFLAGS_LIBCURL and LDFLAGS_LIBCURL
756#---------------------------------------
757AC_DEFUN([MP_LIBCURL_FLAGS],[
758        AC_ARG_WITH(curlprefix,
759                   [  --with-curlprefix       base directory for the cURL install '/usr', '/usr/local',...],
760                   [  curlprefix=$withval ])
761
762        if test "x$curlprefix" = "x"; then
763                AC_PATH_PROG([CURL_CONFIG], [curl-config])
764        else
765                AC_PATH_PROG([CURL_CONFIG], [curl-config], , [$curlprefix/bin])
766        fi
767
768        if test "x$CURL_CONFIG" = "x"; then
769                AC_MSG_ERROR([cannot find curl-config. Is libcurl installed?])
770        fi
771
772        CFLAGS_LIBCURL=$($CURL_CONFIG --cflags)
773        if test "x$curlprefix" = "x"; then
774                # System curl-config emits absurd output for --libs
775                # See rdar://7244457
776                LDFLAGS_LIBCURL="-lcurl"
777        else
778                # Due to a bug in dist, --arch flags are improperly supplied by curl-config.
779                # Get rid of them.
780                LDFLAGS_LIBCURL=$($CURL_CONFIG --libs | [sed 's/-arch [A-Za-z0-9_]* //g'])
781        fi
782
783        AC_SUBST(CFLAGS_LIBCURL)
784        AC_SUBST(LDFLAGS_LIBCURL)
785])
786
787# MP_SQLITE3_FLAGS
788#       Sets the flags to compile with libsqlite3 and tclsqlite3.
789#
790# Arguments:
791#       None.
792#
793# Requires:
794#   pkgconfig, libsqlite3 in /usr/lib, or user parameters to define the flags.
795#
796# Results:
797#   defines some help strings.
798#   sets CFLAGS_SQLITE3 and LDFLAGS_SQLITE3
799#---------------------------------------
800AC_DEFUN([MP_SQLITE3_FLAGS],[
801    # first sqlite3 itself
802        AC_ARG_WITH(sqlite3prefix,
803                   [  --with-sqlite3prefix       base directory for the sqlite3 install '/usr', '/usr/local',...],
804                   [  sqlite3prefix=$withval ])
805
806        if test "x$sqlite3prefix" = "x"; then
807                AC_PATH_PROG([PKG_CONFIG], [pkg-config])
808                if test "x$PKG_CONFIG" = "x" || ! $PKG_CONFIG --exists sqlite3; then
809                    # assume it's somewhere like /usr that needs no extra flags
810                    AC_CHECK_HEADER(sqlite3.h, [], [AC_MSG_ERROR([cannot find sqlite3 header])])
811            CFLAGS_SQLITE3=""
812                    LDFLAGS_SQLITE3="-lsqlite3"
813        else
814            CFLAGS_SQLITE3=$($PKG_CONFIG --cflags sqlite3)
815            LDFLAGS_SQLITE3=$($PKG_CONFIG --libs sqlite3)
816            # for tclsqlite below
817            mp_sqlite3_dir=$($PKG_CONFIG --variable=prefix sqlite3)
818            if test "x$mp_sqlite3_dir" != "x"; then
819                mp_sqlite3_dir=${mp_sqlite3_dir}/lib/sqlite3
820            fi
821        fi
822        else
823            CFLAGS_SQLITE3="-I${sqlite3prefix}/include"
824                LDFLAGS_SQLITE3="-L${sqlite3prefix}/lib -lsqlite3"
825        fi
826
827    # check if we have sqlite3ext.h, using the appropriate cppflags
828    CPPFLAGS_OLD="${CPPFLAGS}"
829    CPPFLAGS="${CPPFLAGS} ${CFLAGS_SQLITE3}"
830    AC_CHECK_HEADERS(sqlite3ext.h)
831    CPPFLAGS="${CPPFLAGS_OLD}"
832
833        AC_SUBST(CFLAGS_SQLITE3)
834        AC_SUBST(LDFLAGS_SQLITE3)
835
836        # now the sqlite Tcl bindings
837        AC_ARG_WITH(tcl-sqlite3,
838                AS_HELP_STRING([--with-tcl-sqlite3=DIR],
839                        [directory for Tcl sqlite3 (default /usr/lib/sqlite3)]),
840                [mp_sqlite3_dir=$withval])
841
842    if test "x$mp_sqlite3_dir" = "x"; then
843        case $host_os in
844            darwin*)
845                mp_sqlite3_dir="/usr/lib/sqlite3"
846                ;;
847            freebsd*)
848                mp_sqlite3_dir="/usr/local/lib/sqlite"
849                ;;
850            *)
851                mp_sqlite3_dir="/usr/share/tcl${TCL_VERSION}/sqlite3"
852                ;;
853        esac
854    fi
855
856        AC_CACHE_CHECK([for Tcl sqlite3 location], [mp_cv_sqlite3_dir],
857                [mp_cv_sqlite3_dir=
858                test -r "${mp_sqlite3_dir}/pkgIndex.tcl" && mp_cv_sqlite3_dir=$mp_sqlite3_dir
859                ])
860
861        SQLITE3_TCL_DIR=$mp_cv_sqlite3_dir
862        AC_SUBST(SQLITE3_TCL_DIR)
863])
864
865dnl This macro tests if the compiler supports GCC's
866dnl __attribute__ syntax for unused variables/parameters
867AC_DEFUN([MP_COMPILER_ATTRIBUTE_UNUSED], [
868        AC_MSG_CHECKING([how to mark unused variables])
869        AC_COMPILE_IFELSE(
870                [AC_LANG_SOURCE([[int a __attribute__ ((unused));]])],
871                [AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])],
872                [AC_DEFINE(UNUSED, [])])
873
874        AC_MSG_RESULT([])
875       
876])
877
878dnl This macro ensures MP installation prefix bin/sbin paths are NOT in PATH
879dnl for configure to prevent potential problems when base/ code is updated
880dnl and ports are installed that would match needed items.
881AC_DEFUN([MP_PATH_SCAN],[
882        oldprefix=$prefix
883        if test "x$prefix" = "xNONE" ; then
884                prefix=$ac_default_prefix
885        fi
886        oldPATH=$PATH
887        newPATH=
888        as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
889        for as_dir in $oldPATH
890        do
891                IFS=$as_save_IFS
892                if test "x$as_dir" != "x$prefix/bin" &&
893                        test "x$as_dir" != "x$prefix/sbin"; then
894                        if test -z "$newPATH"; then
895                                newPATH=$as_dir
896                        else
897                                newPATH=$newPATH$PATH_SEPARATOR$as_dir
898                        fi
899                fi
900        done
901        PATH=$newPATH; export PATH
902        AC_SUBST(PATH_CLEANED,$newPATH)
903        prefix=$oldprefix
904])
905
906dnl This macro tests for sed support of -E (BSD) or -r (GNU)
907AC_DEFUN([MP_SED_EXTENDED_REGEXP],[
908        AC_PATH_PROG(SED, [sed])
909
910        if test "x$SED" = "x"; then
911                AC_MSG_ERROR([cannot find sed. Is sed installed?])
912        fi
913
914        AC_MSG_CHECKING([which sed flag to use for extended regexp])
915        [any_sed_flag=`echo foo | $SED    -e s/foo+/OK/ 2>&1 | grep OK`]
916        [bsd_sed_flag=`echo foo | $SED -E -e s/foo+/OK/ 2>&1 | grep OK`]
917        [gnu_sed_flag=`echo foo | $SED -r -e s/foo+/OK/ 2>&1 | grep OK`]
918        if test "x$any_sed_flag" = "xOK" ; then
919                AC_MSG_RESULT([none])
920                SED_EXT=
921        elif test "x$bsd_sed_flag" = "xOK" ; then
922                AC_MSG_RESULT([-E (BSD)])
923                SED_EXT=-E
924        elif test "x$gnu_sed_flag" = "xOK" ; then
925                AC_MSG_RESULT([-r (GNU)])
926                SED_EXT=-r
927        else
928                AC_MSG_RESULT([not available])
929                SED_EXT='N/A'
930        fi
931        AC_SUBST(SED_EXT)
932])
933
934dnl This macro tests for tar support of -q (BSD) or not (GNU)
935AC_DEFUN([MP_TAR_FAST_READ],[
936        AC_PATH_PROG(TAR, [tar])
937       
938        AC_MSG_CHECKING([whether tar supports -q])
939        if $TAR -t -q -f - </dev/null 2>/dev/null ; then
940                AC_MSG_RESULT([yes (bsdtar)])
941                TAR_Q='q'
942        else
943                AC_MSG_RESULT([no (gnutar)])
944                TAR_Q=
945        fi
946        AC_SUBST(TAR_Q)
947])
948
949dnl This macro tests for tar support of --no-same-owner
950AC_DEFUN([MP_TAR_NO_SAME_OWNER],[
951        AC_PATH_PROG(TAR, [tar])
952        AC_PATH_PROG(GNUTAR, [gnutar])
953       
954        AC_MSG_CHECKING([for which tar variant to use])
955        AS_IF([test -n "$GNUTAR"], [TAR_CMD=$GNUTAR], [TAR_CMD=$TAR])
956        AC_MSG_RESULT([$TAR_CMD])
957        AC_SUBST(TAR_CMD)
958
959        AC_MSG_CHECKING([for $TAR_CMD --no-same-owner support])
960        [no_same_owner_support=`$TAR_CMD --help 2>&1 | grep no-same-owner`]
961        if test -z "$no_same_owner_support" ; then
962                AC_MSG_RESULT([no])
963        else
964                AC_MSG_RESULT([yes])
965                TAR_CMD="$TAR_CMD --no-same-owner"
966        fi
967])
968
969dnl This macro tests for GNU patch
970AC_DEFUN([MP_PATCH_GNU_VERSION],[
971        AC_PATH_PROG(PATCH, [patch])
972        AC_PATH_PROG(GNUPATCH, [gpatch])
973       
974        AC_MSG_CHECKING([for GNU (FSF) patch])
975        AS_IF([test -n "$GNUPATCH"], [PATCH_CMD=$GNUPATCH], [PATCH_CMD=$PATCH])
976        [fsf_version=`$PATCH_CMD --version 2>&1 | grep "Free Software Foundation"`]
977        if test -z "$fsf_version" ; then
978                AC_MSG_RESULT([none])
979        else
980                AC_MSG_RESULT([$PATCH_CMD])
981                GNUPATCH="$PATCH_CMD"
982        fi
983])
984
985#------------------------------------------------------------------------
986# MP_CHECK_READLINK_IS_P1003_1A --
987#
988#       Check if readlink conforms to POSIX 1003.1a standard, define
989#       READLINK_IS_NOT_P1003_1A if it doesn't.
990#
991# Arguments:
992#       None.
993#
994# Requires:
995#       None.
996#
997# Depends:
998#               AC_LANG_PROGRAM
999#
1000# Results:
1001#       Result is cached.
1002#
1003#       If readlink doesn't conform to POSIX 1003.1a, defines the following variables:
1004#               READLINK_IS_NOT_P1003_1A
1005#
1006#------------------------------------------------------------------------
1007AC_DEFUN(MP_CHECK_READLINK_IS_P1003_1A, [
1008        AC_MSG_CHECKING([if readlink conforms to POSIX 1003.1a])
1009
1010        AC_CACHE_VAL(mp_cv_readlink_is_posix_1003_1a, [
1011                AC_COMPILE_IFELSE([
1012                        AC_LANG_PROGRAM([
1013                                        #include <unistd.h>
1014                                        ssize_t readlink(const char *, char *, size_t);
1015                                ], [
1016                        ])
1017                        ], [
1018                                mp_cv_readlink_is_posix_1003_1a="yes"
1019                        ], [
1020                                mp_cv_readlink_is_posix_1003_1a="no"
1021                        ]
1022                )
1023        ])
1024
1025        AC_MSG_RESULT(${mp_cv_readlink_is_posix_1003_1a})
1026
1027        if test x"${mp_cv_readlink_is_posix_1003_1a}" = "xno"; then
1028                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)])
1029        fi
1030
1031        AC_SUBST(READLINK_IS_NOT_P1003_1A)
1032])
1033
1034#------------------------------------------------------------------------
1035# MP_WERROR --
1036#
1037#       Enable -Werror
1038#
1039# Arguments:
1040#       None.
1041#
1042# Requires:
1043#       none
1044#
1045# Depends:
1046#       none
1047#
1048# Results:
1049#       Substitutes WERROR_CFLAGS variable
1050#------------------------------------------------------------------------
1051AC_DEFUN([MP_WERROR],[
1052        AC_REQUIRE([AC_PROG_CC])
1053        AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],[Add -Werror to CFLAGS. Used for development.]), [enable_werror=${enableval}], [enable_werror=no])
1054        if test x"$enable_werror" != "xno"; then
1055                CFLAGS_WERROR="-Werror"
1056        else
1057                CFLAGS_WERROR=""
1058        fi
1059        AC_SUBST([CFLAGS_WERROR])
1060])
Note: See TracBrowser for help on using the repository browser.