source: trunk/base/aclocal.m4 @ 50395

Last change on this file since 50395 was 48083, checked in by raimue@…, 11 years ago

base/aclocal.m4, base/configure:
Do expansion on ~ when looking for the home directory of a user.

Most ports expect applications_dir to be an absolute path starting with a
slash. If this is not the case, constructs like ${destroot}${applications_dir}
will fail (work/destroot~foo/). This copies files outside the destroot so they
will not get installed.

Thanks to Kevin Reid (kpreid) for the report.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 29.2 KB
Line 
1dnl $Id: aclocal.m4 48083 2009-03-14 05:29:50Z raimue@macports.org $
2builtin(include,m4/tcl.m4)
3builtin(include,m4/objc.m4)
4builtin(include,m4/pthread.m4)
5builtin(include,m4/foundation.m4)
6
7#------------------------------------------------------------------------
8# MP_CHECK_FRAMEWORK_COREFOUNDATION --
9#
10#       Check if CoreFoundation framework is available, define HAVE_FRAMEWORK_COREFOUNDATION if so.
11#
12# Arguments:
13#       None.
14#
15# Requires:
16#       None.
17#
18# Depends:
19#               AC_LANG_PROGRAM
20#
21# Results:
22#       Result is cached.
23#
24#       If CoreFoundation framework is available, defines the following variables:
25#               HAVE_FRAMEWORK_COREFOUNDATION
26#
27#------------------------------------------------------------------------
28AC_DEFUN(MP_CHECK_FRAMEWORK_COREFOUNDATION, [
29        FRAMEWORK_LIBS="-framework CoreFoundation"
30
31        AC_MSG_CHECKING([for CoreFoundation framework])
32
33        AC_CACHE_VAL(mp_cv_have_framework_corefoundation, [
34                ac_save_LIBS="$LIBS"
35                LIBS="$FRAMEWORK_LIBS $LIBS"
36               
37                AC_LINK_IFELSE([
38                        AC_LANG_PROGRAM([
39                                        #include <CoreFoundation/CoreFoundation.h>
40                                ], [
41                                        CFURLRef url = CFURLCreateWithFileSystemPath(NULL, CFSTR("/testing"), kCFURLPOSIXPathStyle, 1);
42                                        CFArrayRef bundles = CFBundleCreateBundlesFromDirectory(NULL, url, CFSTR("pkg"));
43                        ])
44                        ], [
45                                mp_cv_have_framework_corefoundation="yes"
46                        ], [
47                                mp_cv_have_framework_corefoundation="no"
48                        ]
49                )
50
51                LIBS="$ac_save_LIBS"
52        ])
53
54        AC_MSG_RESULT(${mp_cv_have_framework_corefoundation})
55
56        if test x"${mp_cv_have_framework_corefoundation}" = "xyes"; then
57                AC_DEFINE([HAVE_FRAMEWORK_COREFOUNDATION], [], [Define if CoreFoundation framework is available])
58        fi
59
60        AC_SUBST(HAVE_FRAMEWORK_COREFOUNDATION)
61])
62
63
64#------------------------------------------------------------------------
65# MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER --
66#
67#       Check if if the routine CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
68#       is available in CoreFoundation.
69#
70# Arguments:
71#       None.
72#
73# Requires:
74#       None.
75#
76# Depends:
77#               AC_LANG_PROGRAM
78#
79# Results:
80#       Result is cached.
81#
82#       If function CFNotificationCenterGetDarwinNotifyCenter is in the CoreFoundation framework, defines the following variables:
83#               HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
84#
85#------------------------------------------------------------------------
86AC_DEFUN(MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER, [
87        FRAMEWORK_LIBS="-framework CoreFoundation"
88
89        AC_MSG_CHECKING([for CFNotificationCenterGetDarwinNotifyCenter])
90
91        AC_CACHE_VAL(mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter, [
92                ac_save_LIBS="$LIBS"
93                LIBS="$FRAMEWORK_LIBS $LIBS"
94               
95                AC_LINK_IFELSE([
96                        AC_LANG_PROGRAM([
97                                        #include <CoreFoundation/CoreFoundation.h>
98                                ], [
99                                        CFNotificationCenterRef ref = CFNotificationCenterGetDarwinNotifyCenter();
100                        ])
101                        ], [
102                                mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="yes"
103                        ], [
104                                mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="no"
105                        ]
106                )
107
108                LIBS="$ac_save_LIBS"
109        ])
110
111        AC_MSG_RESULT(${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter})
112
113        if test x"${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter}" = "xyes"; then
114                AC_DEFINE([HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER], [], [Define if function CFNotificationCenterGetDarwinNotifyCenter in CoreFoundation framework])
115        fi
116
117        AC_SUBST(HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER)
118])
119
120
121#------------------------------------------------------------------------
122# MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION --
123#
124#       Check if SystemConfiguration framework is available, define HAVE_FRAMEWORK_SYSTEMCONFIGURATION if so.
125#
126# Arguments:
127#       None.
128#
129# Requires:
130#       None.
131#
132# Depends:
133#               AC_LANG_PROGRAM
134#
135# Results:
136#       Result is cached.
137#
138#       If SystemConfiguration framework is available, defines the following variables:
139#               HAVE_FRAMEWORK_SYSTEMCONFIGURATION
140#
141#------------------------------------------------------------------------
142AC_DEFUN(MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION, [
143        FRAMEWORK_LIBS="-framework SystemConfiguration"
144
145        AC_MSG_CHECKING([for SystemConfiguration framework])
146
147        AC_CACHE_VAL(mp_cv_have_framework_systemconfiguration, [
148                ac_save_LIBS="$LIBS"
149                LIBS="$FRAMEWORK_LIBS $LIBS"
150               
151                AC_LINK_IFELSE([
152                        AC_LANG_PROGRAM([
153                                        #include <SystemConfiguration/SystemConfiguration.h>
154                                ], [
155                                        int err = SCError();
156                                        SCDynamicStoreRef dsRef = SCDynamicStoreCreate(NULL, NULL, NULL, NULL);
157                        ])
158                        ], [
159                                mp_cv_have_framework_systemconfiguration="yes"
160                        ], [
161                                mp_cv_have_framework_systemconfiguration="no"
162                        ]
163                )
164
165                LIBS="$ac_save_LIBS"
166        ])
167
168        AC_MSG_RESULT(${mp_cv_have_framework_systemconfiguration})
169
170        if test x"${mp_cv_have_framework_systemconfiguration}" = "xyes"; then
171                AC_DEFINE([HAVE_FRAMEWORK_SYSTEMCONFIGURATION], [], [Define if SystemConfiguration framework is available])
172        fi
173
174        AC_SUBST(HAVE_FRAMEWORK_SYSTEMCONFIGURATION)
175])
176
177
178#------------------------------------------------------------------------
179# MP_CHECK_FRAMEWORK_IOKIT --
180#
181#       Check if IOKit framework is available, define HAVE_FRAMEWORK_IOKIT if so.
182#
183# Arguments:
184#       None.
185#
186# Requires:
187#       None.
188#
189# Depends:
190#               AC_LANG_PROGRAM
191#
192# Results:
193#       Result is cached.
194#
195#       If IOKit framework is available, defines the following variables:
196#               HAVE_FRAMEWORK_IOKIT
197#
198#------------------------------------------------------------------------
199AC_DEFUN(MP_CHECK_FRAMEWORK_IOKIT, [
200        FRAMEWORK_LIBS="-framework IOKit"
201
202        AC_MSG_CHECKING([for IOKit framework])
203
204        AC_CACHE_VAL(mp_cv_have_framework_iokit, [
205                ac_save_LIBS="$LIBS"
206                LIBS="$FRAMEWORK_LIBS $LIBS"
207               
208                AC_LINK_IFELSE([
209                        AC_LANG_PROGRAM([
210                                        #include <IOKit/IOKitLib.h>
211                                ], [
212                                        IOCreateReceivePort(0, NULL);
213                                        IORegisterForSystemPower(0, NULL, NULL, NULL);
214                        ])
215                        ], [
216                                mp_cv_have_framework_iokit="yes"
217                        ], [
218                                mp_cv_have_framework_iokit="no"
219                        ]
220                )
221
222                LIBS="$ac_save_LIBS"
223        ])
224
225        AC_MSG_RESULT(${mp_cv_have_framework_iokit})
226
227        if test x"${mp_cv_have_framework_iokit}" = "xyes"; then
228                AC_DEFINE([HAVE_FRAMEWORK_IOKIT], [], [Define if IOKit framework is available])
229        fi
230
231        AC_SUBST(HAVE_FRAMEWORK_IOKIT)
232])
233
234
235dnl This macro checks if the user specified a ports tree
236dnl explicitly. If not, search for it
237
238# MP_PATH_PORTSDIR(DEFAULT_PORTSDIR)
239#---------------------------------------
240 AC_DEFUN([MP_PATH_PORTSDIR],[
241        dnl For ease of reading, run after gcc has been found/configured
242        AC_REQUIRE([AC_PROG_CC])
243
244        AC_ARG_WITH(ports-dir, [AC_HELP_STRING([--with-ports-dir=DIR], [Specify alternate ports directory])], [ portsdir="$withval" ] )
245
246
247        AC_MSG_CHECKING([for ports tree])
248        if test "x$portsdir" != "x" ; then
249          if test -d "$portsdir" -a -e "$portsdir/PortIndex" ; then
250                :
251          else
252                AC_MSG_ERROR([$portsdir not a valid ports tree])
253          fi
254        else
255                dnl If the user didn't give a path, look for default
256                if test "x$1" != "x" ; then
257                  if test -d "$1" -a -e "$1/PortIndex" ; then
258                        portsdir=$1
259                  fi
260                fi
261        fi
262
263        if test "x$portsdir" != "x" ; then
264                AC_MSG_RESULT($portsdir)
265                PORTSDIR="$portsdir"
266                AC_SUBST(PORTSDIR)
267        else
268                AC_MSG_WARN([No ports tree found])
269        fi
270
271         ])
272
273
274# MP_PATH_MPCONFIGDIR
275#---------------------------------------
276AC_DEFUN([MP_PATH_MPCONFIGDIR],[
277        dnl if the user actually specified --prefix, shift
278        dnl mpconfigdir to $prefix/etc/macports
279        dnl     AC_REQUIRE([MP_PATH_PORTSDIR])
280       
281        AC_MSG_CHECKING([for MacPorts config directory])
282
283        mpconfigdir='${sysconfdir}/macports'
284
285        AC_MSG_RESULT([$mpconfigdir])
286        MPCONFIGDIR="$mpconfigdir"
287        AC_SUBST(MPCONFIGDIR)
288
289        ])
290
291
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, [AC_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, [AC_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, [AC_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, [AC_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, [AC_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, [AC_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,[AC_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,[AC_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
493    AC_ARG_WITH(universal-target,[AC_HELP_STRING([--with-universal-target=MDT], [Universal MACOSX_DEPLOYMENT_TARGET version])], UNIVERSAL_TARGET=${withval})
494    AC_ARG_WITH(universal-sysroot,[AC_HELP_STRING([--with-universal-sysroot=SDK], [Universal SDK sysroot (with complete path)])], UNIVERSAL_SYSROOT=${withval})
495    AC_ARG_WITH(universal-archs,[AC_HELP_STRING([--with-universal-archs="CPU"], [Universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
496
497        MACOSX_MAJOR_VERSION=`$SW_VERS -productVersion | cut -f-2 -d.`
498
499        if test "x$UNIVERSAL_TARGET" = "x"; then
500            UNIVERSAL_TARGET=${MACOSX_MAJOR_VERSION}
501        fi
502
503        if test "x$UNIVERSAL_SYSROOT" = "x"; then
504            if test "${MACOSX_MAJOR_VERSION}" = "10.4"; then
505                UNIVERSAL_SYSROOT=/Developer/SDKs/MacOSX${MACOSX_MAJOR_VERSION}u.sdk
506            else
507                UNIVERSAL_SYSROOT=/Developer/SDKs/MacOSX${MACOSX_MAJOR_VERSION}.sdk
508            fi
509        fi
510
511        if test "x$UNIVERSAL_ARCHS" = "x"; then
512            UNIVERSAL_ARCHS="ppc i386"
513        fi
514   
515    AC_MSG_CHECKING([for Universal MDT version])
516    AC_MSG_RESULT([$UNIVERSAL_TARGET])
517    AC_SUBST(UNIVERSAL_TARGET)
518
519    AC_MSG_CHECKING([for Universal SDK sysroot])
520    AC_MSG_RESULT([$UNIVERSAL_SYSROOT])
521    AC_SUBST(UNIVERSAL_SYSROOT)
522
523    AC_MSG_CHECKING([for Universal CPU architectures])
524    AC_MSG_RESULT([$UNIVERSAL_ARCHS])
525    AC_SUBST(UNIVERSAL_ARCHS)
526])
527
528# MP_LIB_MD5
529#---------------------------------------
530# Check for an md5 implementation
531AC_DEFUN([MP_LIB_MD5],[
532
533        # Check for libmd, which is prefered
534        AC_CHECK_LIB([md], [MD5Update],[
535                AC_CHECK_HEADERS([md5.h], ,[
536                        case $host_os in
537                                darwin*)       
538                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
539                                        ;;
540                                *)     
541                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
542                                        ;;
543                        esac
544                        AC_MSG_ERROR([libmd was found, but md5.h is missing.])
545                ])
546                AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
547                MD5_LIBS="-lmd"]
548        )
549        if test "x$MD5_LIBS" = "x" ; then
550                # If libmd is not found, check for libcrypto from OpenSSL
551                AC_CHECK_LIB([crypto], [MD5_Update],[
552                        AC_CHECK_HEADERS([openssl/md5.h],,[
553                                case $host_os in
554                                        darwin*)       
555                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
556                                                ;;
557                                        *)     
558                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
559                                                ;;
560                                esac
561                                AC_MSG_ERROR([libcrypt was found, but header file openssl/md5.h is missing.])
562                        ])
563                        AC_DEFINE([HAVE_LIBCRYPTO],,[Define if you have the `crypto' library (-lcrypto).])
564                        MD5_LIBS="-lcrypto"
565                ], [
566                        AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
567                ])
568        fi
569        if test "x$MD5_LIBS" = "x"; then
570                AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
571        fi
572        AC_SUBST([MD5_LIBS])
573])
574
575dnl This macro checks for X11 presence. If the libraries are
576dnl present, so must the headers be. If nothing is present,
577dnl print a warning
578
579# MP_CHECK_X11
580# ---------------------
581AC_DEFUN([MP_CHECK_X11], [
582
583        # work around symbolic X11 link in /usr/include by providing explicit defaults
584        case "$host" in
585            *-*-darwin9*)
586                if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
587                    x_includes="/usr/X11/include"
588                    x_libraries="/usr/X11/lib"
589                fi
590                ;;
591            *-*-darwin*)
592                if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
593                    x_includes="/usr/X11R6/include"
594                    x_libraries="/usr/X11R6/lib"
595                fi
596                ;;
597        esac
598
599        AC_PATH_X
600        AC_PATH_XTRA
601
602        # Check for libX11
603        AC_CHECK_LIB([X11], [XOpenDisplay],[
604                has_x_runtime=yes
605                ], [ has_x_runtime=no ], [$X_LIBS])
606
607#       echo "------done---------"
608#       echo "x_includes=${x_includes}"
609#       echo "x_libraries=${x_libraries}"
610#       echo "no_x=${no_x}"
611#       echo "X_CFLAGS=${X_CFLAGS}"
612#       echo "X_LIBS=${X_LIBS}"
613#       echo "X_DISPLAY_MISSING=${X_DISPLAY_MISSING}"
614#       echo "has_x_runtime=${has_x_runtime}"
615#       echo "host_os=${host_os}"
616#       echo "------done---------"
617
618        state=
619
620        case "__${has_x_runtime}__${no_x}__" in
621                "__no__yes__")
622                # either the user said --without-x, or it was not found
623                # at all (runtime or headers)
624                        AC_MSG_WARN([X11 not available. You will not be able to use ports that use X11])
625                        state=0
626                        ;;
627                "__yes__yes__")
628                        state=1
629                        ;;
630                "__yes____")
631                        state=2
632                        ;;
633                *)
634                        state=3
635                        ;;
636        esac
637
638        case $host_os in
639                darwin*)       
640                        case $state in
641                                1)
642                                        cat <<EOF;
643Please install the X11 SDK packages from the
644Xcode Developer Tools CD
645EOF
646                                        AC_MSG_ERROR([Broken X11 install. No X11 headers])
647
648                                        ;;
649                                3)
650                                        cat <<EOF;
651Unknown configuration problem. Please install the X11 runtime
652and/or X11 SDK  packages from the Xcode Developer Tools CD
653EOF
654                                        AC_MSG_ERROR([Broken X11 install])
655                                        ;;
656                        esac
657                        ;;
658                *)     
659                        case $state in
660                                1)
661                                        cat <<EOF;
662Please install the X11 developer headers for your platform
663EOF
664                                        AC_MSG_ERROR([Broken X11 install. No X11 headers])
665
666                                        ;;
667                                3)
668                                        cat <<EOF;
669Unknown configuration problem. Please install the X11
670implementation for your platform
671EOF
672                                        AC_MSG_ERROR([Broken X11 install])
673                                        ;;
674                        esac
675                        ;;
676        esac
677
678])
679
680# MP_PROG_XAR
681#---------------------------------------
682AC_DEFUN([MP_PROG_XAR],[
683
684        AC_PATH_PROG([XAR], [xar], ,  [/usr/bin:/usr/sbin:/bin:/sbin])
685
686        if test "x$XAR" = "x" ; then
687                AC_CONFIG_SUBDIRS([src/programs/xar])
688                XAR='$(TOPSRCDIR)/src/programs/xar/xar'
689                REPLACEMENT_PROGS="$REPLACEMENT_PROGS xar"
690        fi
691
692        AC_SUBST(XAR)
693])
694
695# MP_PROG_DAEMONDO
696#---------------------------------------
697AC_DEFUN([MP_PROG_DAEMONDO],[
698        AC_REQUIRE([MP_CHECK_FRAMEWORK_COREFOUNDATION])
699        AC_REQUIRE([MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION])
700        AC_REQUIRE([MP_CHECK_FRAMEWORK_IOKIT])
701        AC_REQUIRE([MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER])
702       
703    AC_MSG_CHECKING(for whether we will build daemondo)
704    result=no
705        case $host_os in
706        darwin*)
707                if test "x$mp_cv_have_framework_corefoundation" == "xyes" &&
708                   test "x$mp_cv_have_framework_systemconfiguration" == "xyes" &&
709                   test "x$mp_cv_have_framework_iokit" == "xyes" &&
710                   test "x$mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter" == "xyes"; then
711                        result=yes
712                        EXTRA_PROGS="$EXTRA_PROGS daemondo"
713                        AC_CONFIG_FILES([src/programs/daemondo/Makefile])
714                fi
715                ;;
716        *)
717        esac
718        AC_MSG_RESULT(${result})
719])
720
721#------------------------------------------------------------------------
722# MP_TCL_PACKAGE_DIR --
723#
724#       Locate the correct directory for Tcl package installation
725#
726# Arguments:
727#       None.
728#
729# Requires:
730#       TCLVERSION must be set
731#       CYGPATH must be set
732#       TCLSH must be set
733#
734# Results:
735#
736#       Adds a --with-tclpackage switch to configure.
737#       Result is cached.
738#
739#       Substs the following vars:
740#               TCL_PACKAGE_DIR
741#------------------------------------------------------------------------
742
743AC_DEFUN(MP_TCL_PACKAGE_DIR, [
744        AC_REQUIRE([MP_CHECK_INSTALLUSER])
745
746    AC_MSG_CHECKING(for Tcl package directory)
747
748    AC_ARG_WITH(tclpackage, [  --with-tclpackage       Tcl package installation directory.], with_tclpackagedir=${withval})
749
750    if test x"${with_tclpackagedir}" != x ; then
751        ac_cv_c_tclpkgd=${with_tclpackagedir}
752    else
753        AC_CACHE_VAL(ac_cv_c_tclpkgd, [
754            # Use the value from --with-tclpackage, if it was given
755
756            if test x"${with_tclpackagedir}" != x ; then
757                echo "tclpackagedir"
758                ac_cv_c_tclpkgd=${with_tclpackagedir}
759            else
760                # On darwin we can do some intelligent guessing
761                case $host_os in
762                    darwin*)
763                        tcl_autopath=`echo 'puts -nonewline \$auto_path' | $TCLSH`
764                        for path in $tcl_autopath; do
765                        if test "$DSTUSR" = "root" ; then
766                            if test "$path" = "/Library/Tcl"; then
767                                ac_cv_c_tclpkgd="$path"
768                                break
769                            fi
770                            if test "$path" = "/System/Library/Tcl"; then
771                                if test -d "$path"; then
772                                    ac_cv_c_tclpkgd="$path"
773                                    break
774                                fi
775                            fi
776                        elif test "$path" = "~/Library/Tcl"; then
777                            ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
778                            break
779                        fi
780                        done
781                    ;;
782                esac
783                if test x"${ac_cv_c_tclpkgd}" = x ; then
784                    # Fudge a path from the first entry in the auto_path
785                    tcl_pkgpath=`echo 'puts -nonewline [[lindex \$auto_path 0]]' | $TCLSH`
786                    if test -d "$tcl_pkgpath"; then
787                        ac_cv_c_tclpkgd="$tcl_pkgpath"
788                    fi
789                    # If the first entry does not exist, do nothing
790                fi
791            fi
792        ])
793    fi
794
795    if test x"${ac_cv_c_tclpkgd}" = x ; then
796        AC_MSG_ERROR(Tcl package directory not found.  Please specify its location with --with-tclpackage)
797    else
798        AC_MSG_RESULT(${ac_cv_c_tclpkgd})
799    fi
800
801    # Convert to a native path and substitute into the output files.
802
803    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
804
805    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
806
807    AC_SUBST(TCL_PACKAGE_DIR)
808])
809
810# MP_PROG_TCLSH
811#---------------------------------------
812AC_DEFUN([MP_PROG_TCLSH],[
813
814
815        case $host_os in
816                freebsd*)
817                        # FreeBSD installs a dummy tclsh (annoying)
818                        # Look for a real versioned tclsh with threads first
819                        # Look for a real versioned tclsh without threads second
820                        AC_PATH_PROG([TCLSH], [tclsh${TCL_VERSION}-threads tclsh${TCL_VERSION} tclsh])
821                        ;;
822                *)
823                        # Otherwise, look for a non-versioned tclsh
824                        AC_PATH_PROG([TCLSH], [tclsh tclsh${TCL_VERSION}])
825                        ;;
826        esac
827        if test "x$TCLSH" = "x" ; then
828                AC_MSG_ERROR([Could not find tclsh])
829        fi
830
831        AC_SUBST(TCLSH)
832])
833
834# MP_TCL_PACKAGE
835#       Determine if a Tcl package is present.
836#
837# Arguments:
838#       Package name (may include the version)
839#
840# Syntax:
841#   MP_TCL_PACKAGE (package, [action-if-found], [action-if-not-found])
842#
843# Requires:
844#       TCLSH must be set
845#
846# Results:
847#       Execute action-if-found or action-if-not-found
848#---------------------------------------
849AC_DEFUN([MP_TCL_PACKAGE],[
850        AC_MSG_CHECKING([for Tcl $1 package])
851        package_present=`echo 'if {[[catch {package require $1}]]} {puts -nonewline 0} else {puts -nonewline 1}' | $TCLSH`
852        AS_IF([test "$package_present" = "1"], [$2], [$3])[]
853])
854
855# MP_TCL_THREAD_SUPPORT
856#       Determine if thread support is available in tclsh.
857#
858# Arguments:
859#       None.
860#
861# Requires:
862#       TCLSH must be set
863#
864# Results:
865#   Fails if thread support isn't available.
866#---------------------------------------
867AC_DEFUN([MP_TCL_THREAD_SUPPORT],[
868        AC_MSG_CHECKING([whether tclsh was compiled with threads])
869        tcl_threadenabled=`echo 'puts -nonewline [[info exists tcl_platform(threaded)]]' | $TCLSH`
870        if test "$tcl_threadenabled" = "1" ; then
871                AC_MSG_RESULT([yes])
872        else
873                AC_MSG_RESULT([no])
874                AC_MSG_ERROR([tcl wasn't compiled with threads enabled])
875        fi
876])
877
878# MP_LIBCURL_FLAGS
879#       Sets the flags to compile with libcurl.
880#
881# Arguments:
882#       None.
883#
884# Requires:
885#   curl-config or user parameters to define the flags.
886#
887# Results:
888#   defines some help strings.
889#   sets CFLAGS_LIBCURL and LDFLAGS_LIBCURL
890#---------------------------------------
891AC_DEFUN([MP_LIBCURL_FLAGS],[
892        AC_ARG_WITH(curlprefix,
893                   [  --with-curlprefix       base directory for the cURL install '/usr', '/usr/local',...],
894                   [  curlprefix=$withval ])
895
896        if test "x$curlprefix" = "x"; then
897                AC_PATH_PROG([CURL_CONFIG], [curl-config])
898        else
899                AC_PATH_PROG([CURL_CONFIG], [curl-config], , [$curlprefix/bin])
900        fi
901
902        if test "x$CURL_CONFIG" = "x"; then
903                AC_MSG_ERROR([cannot find curl-config. Is libcurl installed?])
904        fi
905
906        CFLAGS_LIBCURL=$($CURL_CONFIG --cflags)
907        # Due to a bug in dist, --arch flags are improperly supplied by curl-config.
908        # Get rid of them.
909        LDFLAGS_LIBCURL=$($CURL_CONFIG --libs | [sed 's/-arch [A-Za-z0-9_]* //g'])
910
911        AC_SUBST(CFLAGS_LIBCURL)
912        AC_SUBST(LDFLAGS_LIBCURL)
913])
914
915# MP_LIBCURL_VERSION
916#       Determine the version of libcurl.
917#
918# Arguments:
919#       None.
920#
921# Requires:
922#       CURL must be set (AC_PATH_PROG(CURL, [curl], []))
923#
924# Results:
925#   sets libcurl_version to "0" or some number
926#---------------------------------------
927AC_DEFUN([MP_LIBCURL_VERSION],[
928        if test "x$CURL" = "x"; then
929                libcurl_version="0"
930        else
931                AC_MSG_CHECKING([libcurl version])
932                libcurl_version=`$CURL -V | sed '2,$d' | awk '{print $ 2}' | sed -e 's/\.//g' -e 's/-.*//g'`
933                AC_MSG_RESULT([$libcurl_version])
934        fi
935])
936
937
938dnl This macro tests if the compiler supports GCC's
939dnl __attribute__ syntax for unused variables/parameters
940AC_DEFUN([MP_COMPILER_ATTRIBUTE_UNUSED], [
941        AC_MSG_CHECKING([how to mark unused variables])
942        AC_COMPILE_IFELSE(
943                [AC_LANG_SOURCE([[int a __attribute__ ((unused));]])],
944                [AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])],
945                [AC_DEFINE(UNUSED, [])])
946
947        AC_MSG_RESULT([])
948       
949])
950
951dnl This macro ensures MP installation prefix bin/sbin paths are NOT in PATH
952dnl for configure to prevent potential problems when base/ code is updated
953dnl and ports are installed that would match needed items.
954AC_DEFUN([MP_PATH_SCAN],[
955        oldprefix=$prefix
956        if test "x$prefix" = "xNONE" ; then
957                prefix=$ac_default_prefix
958        fi
959        oldPATH=$PATH
960        newPATH=
961        as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
962        for as_dir in $oldPATH
963        do
964                IFS=$as_save_IFS
965                if test "x$as_dir" != "x$prefix/bin" &&
966                        test "x$as_dir" != "x$prefix/sbin"; then
967                        if test -z "$newPATH"; then
968                                newPATH=$as_dir
969                        else
970                                newPATH=$newPATH$PATH_SEPARATOR$as_dir
971                        fi
972                fi
973        done
974        PATH=$newPATH; export PATH
975        prefix=$oldprefix
976])
977
978dnl This macro tests for sed support of -E (BSD) or -r (GNU)
979AC_DEFUN([MP_SED_EXTENDED_REGEXP],[
980        AC_PATH_PROG(SED, [sed])
981
982        if test "x$SED" = "x"; then
983                AC_MSG_ERROR([cannot find sed. Is sed installed?])
984        fi
985
986        AC_MSG_CHECKING([which sed flag to use for extended regexp])
987        [any_sed_flag=`echo foo | $SED    -e s/foo+/OK/ 2>&1 | grep OK`]
988        [bsd_sed_flag=`echo foo | $SED -E -e s/foo+/OK/ 2>&1 | grep OK`]
989        [gnu_sed_flag=`echo foo | $SED -r -e s/foo+/OK/ 2>&1 | grep OK`]
990        if test "x$any_sed_flag" = "xOK" ; then
991                AC_MSG_RESULT([none])
992                SED_EXT=
993        elif test "x$bsd_sed_flag" = "xOK" ; then
994                AC_MSG_RESULT([-E (BSD)])
995                SED_EXT=-E
996        elif test "x$gnu_sed_flag" = "xOK" ; then
997                AC_MSG_RESULT([-r (GNU)])
998                SED_EXT=-r
999        else
1000                AC_MSG_RESULT([not available])
1001                SED_EXT='N/A'
1002        fi
1003        AC_SUBST(SED_EXT)
1004])
1005
1006dnl This macro tests for tar support of --no-same-owner
1007AC_DEFUN([MP_TAR_NO_SAME_OWNER],[
1008        AC_PATH_PROG(TAR, [tar])
1009        AC_PATH_PROG(GNUTAR, [gnutar])
1010       
1011        AC_MSG_CHECKING([for which tar variant to use])
1012        AS_IF([test -n "$GNUTAR"], [TAR_CMD=$GNUTAR], [TAR_CMD=$TAR])
1013        AC_MSG_RESULT([$TAR_CMD])
1014        AC_SUBST(TAR_CMD)
1015
1016        AC_MSG_CHECKING([for $TAR_CMD --no-same-owner support])
1017        [no_same_owner_support=`$TAR_CMD --help 2>&1 | grep no-same-owner`]
1018        if test -z "$no_same_owner_support" ; then
1019                AC_MSG_RESULT([no])
1020        else
1021                AC_MSG_RESULT([yes])
1022                TAR_CMD="$TAR_CMD --no-same-owner"
1023        fi
1024])
1025
1026#------------------------------------------------------------------------
1027# MP_CHECK_READLINK_IS_P1003_1A --
1028#
1029#       Check if readlink conforms to POSIX 1003.1a standard, define
1030#       READLINK_IS_NOT_P1003_1A if it doesn't.
1031#
1032# Arguments:
1033#       None.
1034#
1035# Requires:
1036#       None.
1037#
1038# Depends:
1039#               AC_LANG_PROGRAM
1040#
1041# Results:
1042#       Result is cached.
1043#
1044#       If readlink doesn't conform to POSIX 1003.1a, defines the following variables:
1045#               READLINK_IS_NOT_P1003_1A
1046#
1047#------------------------------------------------------------------------
1048AC_DEFUN(MP_CHECK_READLINK_IS_P1003_1A, [
1049        AC_MSG_CHECKING([if readlink conforms to POSIX 1003.1a])
1050
1051        AC_CACHE_VAL(mp_cv_readlink_is_posix_1003_1a, [
1052                AC_COMPILE_IFELSE([
1053                        AC_LANG_PROGRAM([
1054                                        #include <unistd.h>
1055                                        ssize_t readlink(const char *, char *, size_t);
1056                                ], [
1057                        ])
1058                        ], [
1059                                mp_cv_readlink_is_posix_1003_1a="yes"
1060                        ], [
1061                                mp_cv_readlink_is_posix_1003_1a="no"
1062                        ]
1063                )
1064        ])
1065
1066        AC_MSG_RESULT(${mp_cv_readlink_is_posix_1003_1a})
1067
1068        if test x"${mp_cv_readlink_is_posix_1003_1a}" = "xno"; then
1069                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)])
1070        fi
1071
1072        AC_SUBST(READLINK_IS_NOT_P1003_1A)
1073])
1074
1075#------------------------------------------------------------------------
1076# MP_WERROR --
1077#
1078#       Enable -Werror
1079#
1080# Arguments:
1081#       None.
1082#
1083# Requires:
1084#       none
1085#
1086# Depends:
1087#       none
1088#
1089# Results:
1090#       Substitutes WERROR_CFLAGS variable
1091#------------------------------------------------------------------------
1092AC_DEFUN([MP_WERROR],[
1093        AC_REQUIRE([AC_PROG_CC])
1094        AC_ARG_ENABLE(werror, AC_HELP_STRING([--enable-werror], [Add -Werror to CFLAGS. Used for development.]), [enable_werror=${enableval}], [enable_werror=no])
1095        if test x"$enable_werror" != "xno"; then
1096                CFLAGS_WERROR="-Werror"
1097        else
1098                CFLAGS_WERROR=""
1099        fi
1100        AC_SUBST([CFLAGS_WERROR])
1101])
Note: See TracBrowser for help on using the repository browser.