source: valtobtest/subversion-1.6.2/build/ac-macros/svn-macros.m4 @ 3

Last change on this file since 3 was 3, checked in by valtob, 15 years ago

subversion source 1.6.2 as test

File size: 4.6 KB
Line 
1# Miscellaneous additional macros for Subversion's own use.
2
3# SVN_CONFIG_NICE(FILENAME)
4# Write a shell script to FILENAME (typically 'config.nice') which reinvokes
5# configure with all of the arguments.  Reserves use of the filename
6# FILENAME.old for its own use.
7# This is different from 'config.status --recheck' in that it does add implicit
8# --no-create --no-recursion options, and stores _just_ the configure
9# invocation, instead of the entire configured state.
10AC_DEFUN([SVN_CONFIG_NICE], [
11  AC_MSG_NOTICE([creating $1])
12  # This little dance satisfies Cygwin, which cannot overwrite in-use files.
13  if test -f "$1"; then
14    mv "$1" "$1.old"
15  fi
16
17  cat >"$1" <<EOF
18#! /bin/sh
19#
20# Created by configure
21
22'[$]0' $ac_configure_args "\[$]@"
23EOF
24
25  chmod +x "$1"
26  rm -f "$1.old"
27])
28
29
30# SVN_EXTERNAL_PROJECT_SETUP()
31# Internal helper for SVN_EXTERNAL_PROJECT.
32AC_DEFUN([SVN_EXTERNAL_PROJECT_SETUP], [
33  do_subdir_config="yes"
34  AC_ARG_ENABLE([subdir-config],
35    AS_HELP_STRING([--disable-subdir-config],
36                   [do not reconfigure packages in subdirectories]),
37    [if test "$enableval" = "no"; then do_subdir_config="no"; fi])
38  AC_SUBST([SVN_EXTERNAL_PROJECT_SUBDIRS], [""])
39])
40
41# SVN_EXTERNAL_PROJECT(SUBDIR [, ADDITIONAL-CONFIGURE-ARGS])
42# Setup SUBDIR as an external project. This means:
43# - Execute the configure script immediately at the point of macro invocation.
44# - Add SUBDIR to the substitution variable SVN_EXTERNAL_PROJECT_SUBDIRS,
45#   for the Makefile.in to arrange to execute make in the subdir.
46#
47# Derived from APR_SUBDIR_CONFIG
48AC_DEFUN([SVN_EXTERNAL_PROJECT], [
49  AC_REQUIRE([SVN_EXTERNAL_PROJECT_SETUP])
50  SVN_EXTERNAL_PROJECT_SUBDIRS="$SVN_EXTERNAL_PROJECT_SUBDIRS $1"
51  if test "$do_subdir_config" = "yes" ; then
52    # save our work to this point; this allows the sub-package to use it
53    AC_CACHE_SAVE
54
55    AC_MSG_NOTICE([configuring package in $1 now])
56    ac_popdir=`pwd`
57    ac_abs_srcdir=`(cd $srcdir/$1 && pwd)`
58    apr_config_subdirs="$1"
59    test -d $1 || $MKDIR $1
60    cd $1
61
62    # A "../" for each directory in /$config_subdirs.
63    ac_dots=[`echo $apr_config_subdirs|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`]
64
65    # Make the cache file name correct relative to the subdirectory.
66    case "$cache_file" in
67    /*) ac_sub_cache_file=$cache_file ;;
68    *) # Relative path.
69      ac_sub_cache_file="$ac_dots$cache_file" ;;
70    esac
71
72    # The eval makes quoting arguments work.
73    if eval $SHELL $ac_abs_srcdir/configure $ac_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_abs_srcdir $2
74    then :
75      echo "$1 configured properly"
76    else
77      echo "configure failed for $1"
78      exit 1
79    fi
80    cd $ac_popdir
81
82    # grab any updates from the sub-package
83    AC_CACHE_LOAD
84  else
85    AC_MSG_WARN([not running configure in $1])
86  fi
87])
88
89dnl
90dnl SVN_CONFIG_SCRIPT(path)
91dnl
92dnl Make AC_OUTPUT create an executable file.
93dnl Accumulate filenames in $SVN_CONFIG_SCRIPT_FILES for AC_SUBSTing to
94dnl use in, for example, Makefile distclean rules.
95dnl
96AC_DEFUN(SVN_CONFIG_SCRIPT, [
97  SVN_CONFIG_SCRIPT_FILES="$SVN_CONFIG_SCRIPT_FILES $1"
98  AC_CONFIG_FILES([$1], [chmod +x $1])])
99
100dnl Iteratively interpolate the contents of the second argument
101dnl until interpolation offers no new result. Then assign the
102dnl final result to $1.
103dnl
104dnl Based on APR_EXPAND_VAR macro
105dnl
106dnl Example:
107dnl
108dnl foo=1
109dnl bar='${foo}/2'
110dnl baz='${bar}/3'
111dnl SVN_EXPAND_VAR(fraz, $baz)
112dnl   $fraz is now "1/2/3"
113dnl
114AC_DEFUN(SVN_EXPAND_VAR,[
115svn_last=
116svn_cur="$2"
117while test "x${svn_cur}" != "x${svn_last}";
118do
119  svn_last="${svn_cur}"
120  svn_cur=`eval "echo ${svn_cur}"`
121done
122$1="${svn_cur}"
123])
124
125dnl SVN_MAYBE_ADD_TO_CFLAGS(option)
126dnl
127dnl Attempt to compile a trivial C program to test if the option passed
128dnl is valid. If it is, then add it to CFLAGS. with the passed in option
129dnl and see if it was successfully compiled.
130dnl
131dnl This macro is usually used for stricter syntax checking flags.
132dnl Therefore we include certain headers which may in turn include system
133dnl headers, as system headers on some platforms may fail strictness checks
134dnl we wish to use on other platforms.
135
136AC_DEFUN(SVN_MAYBE_ADD_TO_CFLAGS,
137[
138  option="$1"
139  svn_maybe_add_to_cflags_saved_flags="$CFLAGS"
140  CFLAGS="$CFLAGS $option"
141  AC_MSG_CHECKING([if $CC accepts $option])
142  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
143    [[#include <apr_portable.h>]],
144    [[]])],
145    [svn_maybe_add_to_cflags_ok="yes"],
146    [svn_maybe_add_to_cflags_ok="no"]
147  )
148  if test "$svn_maybe_add_to_cflags_ok" = "yes"; then
149    AC_MSG_RESULT([yes, will use it])
150  else
151    AC_MSG_RESULT([no])
152    CFLAGS="$svn_maybe_add_to_cflags_saved_flags"
153  fi
154])
Note: See TracBrowser for help on using the repository browser.