* Localization:: Handling Gnulib's own message translations.
* VCS Issues:: Integration with Version Control Systems.
* Unit tests:: Bundling the unit tests of the Gnulib modules.
+* Conditional dependencies:: Avoiding unnecessary checks and compilations.
@end menu
in the scope of the same @code{configure.ac}, you cannot use
@samp{--with-tests}. You will have to use a separate @code{configure.ac}
in this case.
+
+
+@node Conditional dependencies
+@section Avoiding unnecessary checks and compilations
+
+@cindex conditional dependencies
+In some cases, a module is needed by another module only on specific
+platforms. But when a module is present, its autoconf checks are always
+executed, and its @code{Makefile.am} additions are always enabled. So
+it can happen that some autoconf checks are executed and some source files
+are compiled, although no other module needs them on this particular
+platform, just @emph{in case} some other module would need them.
+
+The option @samp{--conditional-dependencies} enables an optimization of
+configure checks and @code{Makefile.am} snippets that avoids this. With
+this option, whether a module is considered ``present'' is no longer decided
+when @code{gnulib-tool} is invoked, but later, when @code{configure} is run.
+This applies to modules that were added as dependencies while
+@code{gnulib-tool} was run; modules that were passed on the command line
+explicitly are always ``present''.
+
+For example, the @code{timegm} module needs, on platforms
+where the system's @code{timegm} function is missing or buggy, a replacement
+that is based on a function @code{mktime_internal}. The module
+@code{mktime-internal} that provides this function provides it on all
+platforms. So, by default, the file @file{mktime-internal.c} will be
+compiled on all platforms --- even on glibc and BSD systems which have a
+working @code{timegm} function. When the option
+@samp{--conditional-dependencies} is given, on the other hand, and if
+@code{mktime-internal} was not explicitly required on the command line,
+the file @file{mktime-internal.c} will only be compiled on the platforms
+where the @code{timegm} needs them.
+
+Conditional dependencies are specified in the module description by putting
+the condition on the same line as the dependent module, enclosed in brackets.
+The condition is a boolean shell expression that can assume that the
+@code{configure.ac} snippet from the module description has already been
+executed. In the example above, the dependency from @code{timegm} to
+@code{mktime-internal} is written like this:
+
+@smallexample
+Depends-on:
+...
+mktime-internal [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1]
+...
+@end smallexample
+
+Note: The option @samp{--conditional-dependencies} cannot be used together
+with the option @samp{--with-tests}. It also cannot be used when a package
+uses @code{gnulib-tool} for several subdirectories, with different values
+of @samp{--source-base}, in the scope of a single @code{configure.ac} file.
have code that provides equivalent functionality.
This option can be repeated.
--conditional-dependencies
- Support conditional dependencies (experimental,
- may save configure time and object code, not
- compatible with --with-tests).
+ Support conditional dependencies (may save configure
+ time and object code).
+ --no-conditional-dependencies
+ Don't use conditional dependencies.
--libtool Use libtool rules.
--no-libtool Don't use libtool rules.
# - excl_unportable_tests true if --without-unportable-tests was given, blank
# otherwise
# - avoidlist list of modules to avoid, from --avoid
-# - cond_dependencies true if --conditional-dependencies was given, blank
-# otherwise
+# - cond_dependencies true if --conditional-dependencies was given, false if
+# --no-conditional-dependencies was given, blank otherwise
# - lgpl yes or a number if --lgpl was given, blank otherwise
# - makefile_name from --makefile-name
# - libtool true if --libtool was given, false if --no-libtool was
--conditional-dependencies | --conditional-dependencie | --conditional-dependenci | --conditional-dependenc | --conditional-dependen | --conditional-depende | --conditional-depend | --conditional-depen | --conditional-depe | --conditional-dep | --conditional-de | --conditional-d | --conditional- | --conditional | --conditiona | --condition | --conditio | --conditi | --condit | --condi | --cond | --con)
cond_dependencies=true
shift ;;
+ --no-conditional-dependencies | --no-conditional-dependencie | --no-conditional-dependenci | --no-conditional-dependenc | --no-conditional-dependen | --no-conditional-depende | --no-conditional-depend | --no-conditional-depen | --no-conditional-depe | --no-conditional-dep | --no-conditional-de | --no-conditional-d | --no-conditional- | --no-conditional | --no-conditiona | --no-condition | --no-conditio | --no-conditi | --no-condit | --no-condi | --no-cond | --no-con | --no-co)
+ cond_dependencies=false
+ shift ;;
--lgpl )
lgpl=yes
shift ;;
if test -z "$pobase" && test -n "$po_domain"; then
func_warning "--po-domain has no effect without a --po-base option"
fi
- if test -n "$cond_dependencies" && test -n "$inctests"; then
+ if test "$cond_dependencies" = true && test -n "$inctests"; then
echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
func_exit 1
fi
inmodules="$modules"
outmodules=
fmtc_inc_all_tests="$inc_all_direct_tests"
- if test -n "$cond_dependencies"; then
+ if test "$cond_dependencies" = true; then
for module in $inmodules; do
func_verify_module
if test -n "$module"; then
if test -n "$module"; then
if func_acceptable $module; then
func_append outmodules " $module"
- if test -n "$cond_dependencies"; then
+ if test "$cond_dependencies" = true; then
if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
# A module whose Makefile.am snippet contains a reference to an
# automake conditional. If we were to use it conditionally, we
done
if $inc; then
func_append inmodules " $dep"
- if test -n "$cond_dependencies"; then
+ if test "$cond_dependencies" = true; then
escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
s/^.*$/true/p
if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
echo "## begin gnulib module $module"
echo
- if test -n "$cond_dependencies"; then
+ if test "$cond_dependencies" = true; then
if func_cond_module_p "$module"; then
func_module_conditional_name "$module"
echo "if $conditional"
fi
fi
cat "$tmp"/amsnippet1
- if test -n "$cond_dependencies"; then
+ if test "$cond_dependencies" = true; then
if func_cond_module_p "$module"; then
echo "endif"
fi
toplevel="$3"
disable_libtool="$4"
disable_gettext="$5"
- if test -n "$cond_dependencies"; then
+ if test "$cond_dependencies" = true; then
# Emit the autoconf code for the unconditional modules.
for module in $1; do
eval $verifier
# otherwise
# - inc_all_tests true if --with-all-tests was given, blank otherwise
# - avoidlist list of modules to avoid, from --avoid
-# - cond_dependencies true if conditional dependencies shall be supported,
-# blank otherwise
+# - cond_dependencies true if --conditional-dependencies was given, false if
+# --no-conditional-dependencies was given, blank otherwise
# - lgpl yes or a number if library's license shall be LGPL,
# blank otherwise
# - makefile_name from --makefile-name
cached_libname=
cached_lgpl=
cached_makefile_name=
+ cached_cond_dependencies=
cached_libtool=
cached_macro_prefix=
cached_po_domain=
/gl_MAKEFILE_NAME(/ {
s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
}
+ /gl_CONDITIONAL_DEPENDENCIES/ {
+ s,^.*$,cached_cond_dependencies=true,p
+ }
/gl_LIBTOOL/ {
s,^.*$,cached_libtool=true,p
}
if test -z "$makefile_name"; then
makefile_name="$cached_makefile_name"
fi
+ # Use conditional dependencies if specified either way.
+ if test -z "$cond_dependencies"; then
+ cond_dependencies="$cached_cond_dependencies"
+ fi
# Use libtool if specified either way, or if guessed.
if test -z "$libtool"; then
if test -n "$cached_m4base"; then
if test -z "$vc_files"; then
vc_files="$cached_vc_files"
fi
+ # Ensure constraints.
+ if test "$cond_dependencies" = true && test -n "$inctests"; then
+ echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
+ func_exit 1
+ fi
fi
# --without-*-tests options are not supported here.
excl_cxx_tests=
if test -n "$makefile_name"; then
func_append actioncmd " --makefile-name=$makefile_name"
fi
+ if test "$cond_dependencies" = true; then
+ func_append actioncmd " --conditional-dependencies"
+ else
+ func_append actioncmd " --no-conditional-dependencies"
+ fi
if test "$libtool" = true; then
func_append actioncmd " --libtool"
else
fi
fi
echo "gl_MAKEFILE_NAME([$makefile_name])"
+ if test "$cond_dependencies" = true; then
+ echo "gl_CONDITIONAL_DEPENDENCIES"
+ fi
if test "$libtool" = true; then
echo "gl_LIBTOOL"
fi
# - excl_unportable_tests true if tests that fail on some platforms should be
# excluded, blank otherwise
# - avoidlist list of modules to avoid
-# - cond_dependencies true if conditional dependencies shall be supported,
-# blank otherwise
+# - cond_dependencies true if --conditional-dependencies was given, false if
+# --no-conditional-dependencies was given, blank otherwise
# - libtool true if --libtool was given, false if --no-libtool was
# given, blank otherwise
# - symbolic true if files should be symlinked, copied otherwise