source: trunk/base/aclocal.m4 @ 13459

Last change on this file since 13459 was 13459, checked in by pguyot (Paul Guyot), 15 years ago

Completely get rid of curl in favor in libcurl.

  • Property svn:eol-style set to native
File size: 13.5 KB
Line 
1builtin(include,tcl.m4)
2
3dnl This macro checks if the user specified a dports tree
4dnl explicitly. If not, search for it
5
6# OD_PATH_DPORTSDIR(DEFAULT_DPORTSDIR)
7#---------------------------------------
8 AC_DEFUN([OD_PATH_DPORTSDIR],[
9        dnl For ease of reading, run after gcc has been found/configured
10        AC_REQUIRE([AC_PROG_CC])
11
12        AC_ARG_WITH(dports-dir, [AC_HELP_STRING([--with-dports-dir=DIR], [Specify alternate dports directory])], [ dportsdir="$withval" ] )
13
14
15        AC_MSG_CHECKING([for dports tree])
16        if test "x$dportsdir" != "x" ; then
17          if test -d "$dportsdir" -a -e "$dportsdir/PortIndex" ; then
18                :
19          else
20                AC_MSG_ERROR([$dportsdir not a valid dports tree])
21          fi
22        else
23                dnl If the user didn't give a path, look for default
24                if test "x$1" != "x" ; then
25                  if test -d "$1" -a -e "$1/PortIndex" ; then
26                        dportsdir=$1
27                  fi
28                fi
29        fi
30
31        if test "x$dportsdir" != "x" ; then
32                AC_MSG_RESULT($dportsdir)
33                DPORTSDIR="$dportsdir"
34                AC_SUBST(DPORTSDIR)
35        else
36                AC_MSG_WARN([No dports tree found])
37        fi
38
39         ])
40
41
42# OD_PATH_PORTCONFIGDIR
43#---------------------------------------
44AC_DEFUN([OD_PATH_PORTCONFIGDIR],[
45        dnl if the user actually specified --prefix, shift
46        dnl portconfigdir to $prefix/etc/ports
47        dnl     AC_REQUIRE([OD_PATH_DPORTSDIR])
48       
49        AC_MSG_CHECKING([for ports config directory])
50
51        portconfigdir='${sysconfdir}/ports'
52
53        AC_MSG_RESULT([$portconfigdir])
54        PORTCONFIGDIR="$portconfigdir"
55        AC_SUBST(PORTCONFIGDIR)
56
57        ])
58
59# OD_CHECK_INSTALLUSER
60#-------------------------------------------------
61AC_DEFUN([OD_CHECK_INSTALLUSER],[
62        dnl if with user specifies --with-install-user,
63        dnl use it. otherwise default to platform defaults
64        AC_REQUIRE([OD_PATH_PORTCONFIGDIR])
65
66        AC_ARG_WITH(install-user, [AC_HELP_STRING([--with-install-user=USER], [Specify user ownership of installed files])], [ DSTUSR=$withval ] )
67       
68        AC_MSG_CHECKING([for install user])
69        if test "x$DSTUSR" = "x" ; then
70           DSTUSR=root
71        fi
72
73        AC_MSG_RESULT([$DSTUSR])
74        AC_SUBST(DSTUSR)
75])
76
77# OD_CHECK_INSTALLGROUP
78#-------------------------------------------------
79AC_DEFUN([OD_CHECK_INSTALLGROUP],[
80        dnl if with user specifies --with-install-group,
81        dnl use it. otherwise default to platform defaults
82        AC_REQUIRE([OD_CHECK_INSTALLUSER])
83
84        AC_ARG_WITH(install-group, [AC_HELP_STRING([--with-install-group=GROUP], [Specify group ownership of installed files])], [ DSTGRP=$withval ] )
85
86        AC_MSG_CHECKING([for install group])
87        if test "x$DSTGRP" = "x" ; then
88           
89           case $host_os in
90           darwin*)
91                DSTGRP="admin"
92                ;;
93           *)
94                DSTGRP="wheel"
95                ;;
96           esac
97        fi
98
99        AC_MSG_RESULT([$DSTGRP])
100        AC_SUBST(DSTGRP)
101])
102
103# OD_DIRECTORY_MODE
104#-------------------------------------------------
105AC_DEFUN([OD_DIRECTORY_MODE],[
106        dnl if with user specifies --with-directory-mode,
107        dnl use the specified permissions for ${prefix} directories
108        dnl otherwise use 0775
109        AC_REQUIRE([OD_PATH_PORTCONFIGDIR])
110
111        AC_ARG_WITH(directory-mode, [AC_HELP_STRING([--with-directory-mode=MODE], [Specify directory mode of installed directories])], [ DSTMODE=$withval ] )
112       
113        AC_MSG_CHECKING([what permissions to use for installation directories])
114        if test "x$DSTMODE" = "x" ; then
115           DSTMODE=0775
116        fi
117
118        AC_MSG_RESULT([$DSTMODE])
119        AC_SUBST(DSTMODE)
120])
121
122# OD_LIB_MD5
123#---------------------------------------
124# Check for an md5 implementation
125AC_DEFUN([OD_LIB_MD5],[
126
127        # Check for libmd, which is prefered
128        AC_CHECK_LIB([md], [MD5Update],[
129                AC_CHECK_HEADERS([md5.h], ,[
130                        case $host_os in
131                                darwin*)       
132                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
133                                        ;;
134                                *)     
135                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
136                                        ;;
137                        esac
138                        AC_MSG_ERROR([libmd was found, but md5.h is missing.])
139                ])
140                AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
141                MD5_LIBS="-lmd"]
142        )
143        if test "x$MD5_LIBS" = "x" ; then
144                # If libmd is not found, check for libcrypto from OpenSSL
145                AC_CHECK_LIB([crypto], [MD5_Update],[
146                        AC_CHECK_HEADERS([openssl/md5.h],,[
147                                case $host_os in
148                                        darwin*)       
149                                        AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
150                                                ;;
151                                        *)     
152                                        AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
153                                                ;;
154                                esac
155                                AC_MSG_ERROR([libcrypt was found, but header file openssl/md5.h is missing.])
156                        ])
157                        AC_DEFINE([HAVE_LIBCRYPTO],,[Define if you have the `crypto' library (-lcrypto).])
158                        MD5_LIBS="-lcrypto"
159                ], [
160                        AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
161                ])
162        fi
163        if test "x$MD5_LIBS" = "x"; then
164                AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
165        fi
166        AC_SUBST([MD5_LIBS])
167])
168
169dnl This macro checks for X11 presence. If the libraries are
170dnl present, so must the headers be. If nothing is present,
171dnl print a warning
172
173# OD_CHECK_X11
174# ---------------------
175AC_DEFUN([OD_CHECK_X11], [
176
177        AC_PATH_XTRA
178
179        # Check for libX11
180        AC_CHECK_LIB([X11], [XOpenDisplay],[
181                has_x_runtime=yes
182                ], [ has_x_runtime=no ], [-L/usr/X11R6/lib $X_LIBS])
183
184#       echo "------done---------"
185#       echo "x_includes=${x_includes}"
186#       echo "x_libraries=${x_libraries}"
187#       echo "no_x=${no_x}"
188#       echo "X_CFLAGS=${X_CFLAGS}"
189#       echo "X_LIBS=${X_LIBS}"
190#       echo "X_DISPLAY_MISSING=${X_DISPLAY_MISSING}"
191#       echo "has_x_runtime=${has_x_runtime}"
192#       echo "host_os=${host_os}"
193#       echo "------done---------"
194
195        state=
196
197        case "__${has_x_runtime}__${no_x}__" in
198                "__no__yes__")
199                # either the user said --without-x, or it was not found
200                # at all (runtime or headers)
201                        AC_MSG_WARN([X11 not available. You will not be able to use dports that use X11])
202                        state=0
203                        ;;
204                "__yes__yes__")
205                        state=1
206                        ;;
207                "__yes____")
208                        state=2
209                        ;;
210                *)
211                        state=3
212                        ;;
213        esac
214
215        case $host_os in
216                darwin*)       
217                        case $state in
218                                1)
219                                        cat <<EOF;
220Please install the X11 SDK packages from the
221Xcode Developer Tools CD
222EOF
223                                        AC_MSG_ERROR([Broken X11 install. No X11 headers])
224
225                                        ;;
226                                3)
227                                        cat <<EOF;
228Unknown configuration problem. Please install the X11 runtime
229and/or X11 SDK  packages from the Xcode Developer Tools CD
230EOF
231                                        AC_MSG_ERROR([Broken X11 install])
232                                        ;;
233                        esac
234                        ;;
235                *)     
236                        case $state in
237                                1)
238                                        cat <<EOF;
239Please install the X11 developer headers for your platform
240EOF
241                                        AC_MSG_ERROR([Broken X11 install. No X11 headers])
242
243                                        ;;
244                                3)
245                                        cat <<EOF;
246Unknown configuration problem. Please install the X11
247implementation for your platform
248EOF
249                                        AC_MSG_ERROR([Broken X11 install])
250                                        ;;
251                        esac
252                        ;;
253        esac
254
255])
256
257# OD_PROG_MTREE
258#---------------------------------------
259AC_DEFUN([OD_PROG_MTREE],[
260
261        AC_PATH_PROG([MTREE], [mtree], ,  [/usr/bin:/usr/sbin:/bin:/sbin])
262
263        if test "x$MTREE" = "x" ; then
264                AC_CONFIG_SUBDIRS([src/programs/mtree])
265                MTREE='$(TOPSRCDIR)/src/programs/mtree/mtree'
266#               MTREE='${prefix}/bin/mtree'
267                REPLACEMENT_PROGS="$REPLACEMENT_PROGS mtree"
268        fi
269
270        AC_SUBST(MTREE)
271])
272
273#------------------------------------------------------------------------
274# OD_TCL_PACKAGE_DIR --
275#
276#       Locate the correct directory for Tcl package installation
277#
278# Arguments:
279#       None.
280#
281# Requires:
282#       TCLVERSION must be set
283#       CYGPATH must be set
284#       TCLSH must be set
285#
286# Results:
287#
288#       Adds a --with-tclpackage switch to configure.
289#       Result is cached.
290#
291#       Substs the following vars:
292#               TCL_PACKAGE_DIR
293#------------------------------------------------------------------------
294
295AC_DEFUN(OD_TCL_PACKAGE_DIR, [
296    AC_MSG_CHECKING(for Tcl package directory)
297
298    AC_ARG_WITH(tclpackage, [  --with-tclpackage       Tcl package installation directory.], with_tclpackagedir=${withval})
299
300    if test x"${with_tclpackagedir}" != x ; then
301        ac_cv_c_tclpkgd=${with_tclpackagedir}
302    else
303        AC_CACHE_VAL(ac_cv_c_tclpkgd, [
304            # Use the value from --with-tclpackagedir, if it was given
305
306            if test x"${with_tclpackagedir}" != x ; then
307                ac_cv_c_tclpkgd=${with_tclpackagedir}
308            else
309                # On darwin we can do some intelligent guessing
310                case $host_os in
311                    darwin*)
312                        tcl_autopath=`echo 'puts -nonewline \$auto_path' | $TCLSH`
313                        for path in $tcl_autopath; do
314                            if test "$path" = "/Library/Tcl"; then
315                                ac_cv_c_tclpkgd="$path"
316                                break
317                            fi
318                            if test "$path" = "/System/Library/Tcl"; then
319                                if test -d "$path"; then
320                                    ac_cv_c_tclpkgd="$path"
321                                    break
322                                fi
323                            fi
324                        done
325                    ;;
326                esac
327                if test x"${ac_cv_c_tclpkgd}" = x ; then
328                    # Fudge a path from the first entry in the auto_path
329                    tcl_pkgpath=`echo 'puts -nonewline [[lindex \$auto_path 0]]' | $TCLSH`
330                    if test -d "$tcl_pkgpath"; then
331                        ac_cv_c_tclpkgd="$tcl_pkgpath"
332                    fi
333                    # If the first entry does not exist, do nothing
334                fi
335            fi
336        ])
337    fi
338
339    if test x"${ac_cv_c_tclpkgd}" = x ; then
340        AC_MSG_ERROR(Tcl package directory not found.  Please specify its location with --with-tclpackagedir)
341    else
342        AC_MSG_RESULT(${ac_cv_c_tclpkgd})
343    fi
344
345    # Convert to a native path and substitute into the output files.
346
347    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
348
349    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
350
351    AC_SUBST(TCL_PACKAGE_DIR)
352])
353
354# OD_PROG_TCLSH
355#---------------------------------------
356AC_DEFUN([OD_PROG_TCLSH],[
357
358
359        case $host_os in
360                freebsd*)
361                        # FreeBSD installs a dummy tclsh (annoying)
362                        # Look for a real versioned tclsh first
363                        AC_PATH_PROG([TCLSH], [tclsh${TCL_VERSION} tclsh])
364                        ;;
365                *)
366                        # Otherwise, look for a non-versioned tclsh
367                        AC_PATH_PROG([TCLSH], [tclsh tclsh${TCL_VERSION}])
368                        ;;
369        esac
370        if test "x$TCLSH" = "x" ; then
371                AC_MSG_ERROR([Could not find tclsh])
372        fi
373
374        AC_SUBST(TCLSH)
375])
376
377# OD_TCL_PACKAGE
378#       Determine if a Tcl package is present.
379#
380# Arguments:
381#       Package name (may include the version)
382#
383# Syntax:
384#   OD_TCL_PACKAGE (package, [action-if-found], [action-if-not-found])
385#
386# Requires:
387#       TCLSH must be set
388#
389# Results:
390#       Execute action-if-found or action-if-not-found
391#---------------------------------------
392AC_DEFUN([OD_TCL_PACKAGE],[
393        AC_MSG_CHECKING([for Tcl $1 package])
394        package_present=`echo 'if {[[catch {package require $1}]]} {puts -nonewline 0} else {puts -nonewline 1}' | $TCLSH`
395        AS_IF([test "$package_present" = "1"], [$2], [$3])[]
396])
397
398# OD_TCL_THREAD_SUPPORT
399#       Determine if thread support is available in tclsh.
400#
401# Arguments:
402#       None.
403#
404# Requires:
405#       TCLSH must be set
406#
407# Results:
408#   Fails if thread support isn't available.
409#---------------------------------------
410AC_DEFUN([OD_TCL_THREAD_SUPPORT],[
411        AC_MSG_CHECKING([whether tclsh was compiled with threads])
412        tcl_threadenabled=`echo 'puts -nonewline [[info exists tcl_platform(threaded)]]' | $TCLSH`
413        if test "$tcl_threadenabled" = "1" ; then
414                AC_MSG_RESULT([yes])
415        else
416                AC_MSG_RESULT([no])
417                AC_MSG_ERROR([tcl wasn't compiled with threads enabled])
418        fi
419])
420
421# OD_LIBCURL_FLAGS
422#       Sets the flags to compile with libcurl.
423#
424# Arguments:
425#       None.
426#
427# Requires:
428#   curl-config or user parameters to define the flags.
429#
430# Results:
431#   defines some help strings.
432#   sets CFLAGS_LIBCURL and LDFLAGS_LIBCURL
433#---------------------------------------
434AC_DEFUN([OD_LIBCURL_FLAGS],[
435        AC_ARG_WITH(curlprefix,
436                   [  --with-curlprefix       base directory for the cURL install '/usr', '/usr/local',...],
437                   [  curlprefix=$withval ])
438
439        if test "x$curlprefix" = "x"; then
440                AC_PATH_PROG([CURL_CONFIG], [curl-config])
441        else
442                AC_PATH_PROG([CURL_CONFIG], [curl-config], , [$curlprefix/bin])
443        fi
444
445        if test "x$CURL_CONFIG" = "x"; then
446                AC_MSG_ERROR([cannot find curl-config. Is libcurl installed?])
447        fi
448
449        CFLAGS_LIBCURL=`$CURL_CONFIG --cflags`
450        LDFLAGS_LIBCURL=`$CURL_CONFIG --libs`
451
452        AC_SUBST(CFLAGS_LIBCURL)
453        AC_SUBST(LDFLAGS_LIBCURL)
454])
455
456# OD_LIBCURL_VERSION
457#       Determine the version of libcurl.
458#
459# Arguments:
460#       None.
461#
462# Requires:
463#       CURL must be set (AC_PATH_PROG(CURL, [curl], []))
464#
465# Results:
466#   sets libcurl_version to "0" or some number
467#---------------------------------------
468AC_DEFUN([OD_LIBCURL_VERSION],[
469        if test "x$CURL" = "x"; then
470                libcurl_version="0"
471        else
472                AC_MSG_CHECKING([libcurl version])
473                libcurl_version=`$CURL -V | sed '2,$d' | awk '{print $ 2}' | sed -e 's/\.//g' -e 's/-.*//g'`
474                AC_MSG_RESULT([$libcurl_version])
475        fi
476])
477
478dnl This macro tests if the compiler supports GCC's
479dnl __attribute__ syntax for unused variables/parameters
480AC_DEFUN([OD_COMPILER_ATTRIBUTE_UNUSED], [
481        AC_MSG_CHECKING([how to mark unused variables])
482        AC_COMPILE_IFELSE(
483                [AC_LANG_SOURCE([[int a __attribute__ ((unused));]])],
484                [AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])],
485                [AC_DEFINE(UNUSED, [])])
486
487        AC_MSG_RESULT([])
488       
489])
490
491dnl This macro ensures DP installation prefix bin/sbin paths are NOT in PATH
492dnl for configure to prevent potential problems when base/ code is updated
493dnl and ports are installed that would match needed items.
494AC_DEFUN([OD_PATH_SCAN],[
495        oldprefix=$prefix
496        if test "x$prefix" = "xNONE" ; then
497                prefix=$ac_default_prefix
498        fi
499        oldPATH=$PATH
500        newPATH=
501        as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
502        for as_dir in $oldPATH
503        do
504                IFS=$as_save_IFS
505                if test "x$as_dir" != "x$prefix/bin" &&
506                        test "x$as_dir" != "x$prefix/sbin"; then
507                        if test -z "$newPATH"; then
508                                newPATH=$as_dir
509                        else
510                                newPATH=$newPATH$PATH_SEPARATOR$as_dir
511                        fi
512                fi
513        done
514        PATH=$newPATH; export PATH
515        prefix=$oldprefix
516])
517
518dnl This macro tests for tar support of --no-same-owner
519AC_DEFUN([OD_TAR_NO_SAME_OWNER],[
520        AC_PATH_PROG(TAR, [tar])
521        AC_PATH_PROG(GNUTAR, [gnutar])
522       
523        AC_MSG_CHECKING([for which tar variant to use])
524        AS_IF([test -n "$GNUTAR"], [TAR_CMD=$GNUTAR], [TAR_CMD=$TAR])
525        AC_MSG_RESULT([$TAR_CMD])
526        AC_SUBST(TAR_CMD)
527
528        AC_MSG_CHECKING([for $TAR_CMD --no-same-owner support])
529        [no_same_owner_support=`$TAR_CMD --help 2>&1 | grep no-same-owner`]
530        if test -z "$no_same_owner_support" ; then
531                AC_MSG_RESULT([no])
532        else
533                AC_MSG_RESULT([yes])
534                TAR_CMD="$TAR_CMD --no-same-owner"
535        fi
536])
537
Note: See TracBrowser for help on using the repository browser.