source: branches/gsoc08-privileges/base/aclocal.m4 @ 65055

Last change on this file since 65055 was 37888, checked in by pmagrath@…, 12 years ago

Move macportsuser variable (user to drop privileges to during fetch, configure, build, etc) to macports.conf. Allow setting of macportsuser variable with configure switch --with-macports-user=USER.

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