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. |
---|
10 | AC_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 "\[$]@" |
---|
23 | EOF |
---|
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. |
---|
32 | AC_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 |
---|
48 | AC_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 | |
---|
89 | dnl |
---|
90 | dnl SVN_CONFIG_SCRIPT(path) |
---|
91 | dnl |
---|
92 | dnl Make AC_OUTPUT create an executable file. |
---|
93 | dnl Accumulate filenames in $SVN_CONFIG_SCRIPT_FILES for AC_SUBSTing to |
---|
94 | dnl use in, for example, Makefile distclean rules. |
---|
95 | dnl |
---|
96 | AC_DEFUN(SVN_CONFIG_SCRIPT, [ |
---|
97 | SVN_CONFIG_SCRIPT_FILES="$SVN_CONFIG_SCRIPT_FILES $1" |
---|
98 | AC_CONFIG_FILES([$1], [chmod +x $1])]) |
---|
99 | |
---|
100 | dnl Iteratively interpolate the contents of the second argument |
---|
101 | dnl until interpolation offers no new result. Then assign the |
---|
102 | dnl final result to $1. |
---|
103 | dnl |
---|
104 | dnl Based on APR_EXPAND_VAR macro |
---|
105 | dnl |
---|
106 | dnl Example: |
---|
107 | dnl |
---|
108 | dnl foo=1 |
---|
109 | dnl bar='${foo}/2' |
---|
110 | dnl baz='${bar}/3' |
---|
111 | dnl SVN_EXPAND_VAR(fraz, $baz) |
---|
112 | dnl $fraz is now "1/2/3" |
---|
113 | dnl |
---|
114 | AC_DEFUN(SVN_EXPAND_VAR,[ |
---|
115 | svn_last= |
---|
116 | svn_cur="$2" |
---|
117 | while test "x${svn_cur}" != "x${svn_last}"; |
---|
118 | do |
---|
119 | svn_last="${svn_cur}" |
---|
120 | svn_cur=`eval "echo ${svn_cur}"` |
---|
121 | done |
---|
122 | $1="${svn_cur}" |
---|
123 | ]) |
---|
124 | |
---|
125 | dnl SVN_MAYBE_ADD_TO_CFLAGS(option) |
---|
126 | dnl |
---|
127 | dnl Attempt to compile a trivial C program to test if the option passed |
---|
128 | dnl is valid. If it is, then add it to CFLAGS. with the passed in option |
---|
129 | dnl and see if it was successfully compiled. |
---|
130 | dnl |
---|
131 | dnl This macro is usually used for stricter syntax checking flags. |
---|
132 | dnl Therefore we include certain headers which may in turn include system |
---|
133 | dnl headers, as system headers on some platforms may fail strictness checks |
---|
134 | dnl we wish to use on other platforms. |
---|
135 | |
---|
136 | AC_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 | ]) |
---|