@cindex initial import
Gnulib assumes that your project uses Autoconf. When using Gnulib, you
-will need to have Autoconf and Automake among your build tools. Note that
-while the use of Automake in your project's top level directory is an
-easy way to fulfil the Makefile conventions of the GNU coding standards,
-Gnulib does not require it. But when you use Gnulib, Automake will be
-used at least in a subdirectory of your project.
+will need to have Autoconf among your build tools.
+
+Unless you use @command{gnulib-tool}'s @option{--gnu-make} option,
+Gnulib also assumes that your project uses Automake at least in a
+subdirectory of your project. While the use of Automake in your
+project's top level directory is an easy way to fulfil the Makefile
+conventions of the GNU coding standards, Gnulib does not require it.
Invoking @samp{gnulib-tool --import} will copy source files, create a
@file{Makefile.am} to build them, generate a file @file{gnulib-comp.m4} with
@code{gl_INIT} will in turn call the macros related with the
gnulib functions, be it specific gnulib macros, like @code{gl_FUNC_ALLOCA}
-or autoconf or automake macros like @code{AC_FUNC_ALLOCA} or
+or Autoconf or Automake macros like @code{AC_FUNC_ALLOCA} or
@code{AM_FUNC_GETLINE}. So there is no need to call those macros yourself
when you use the corresponding gnulib modules.
@cindex autopoint, caveat
The programs @code{gettextize} and @code{autopoint}, part of
GNU @code{gettext}, import or update the internationalization infrastructure.
-Some of this infrastructure, namely ca.@: 20 autoconf macro files and the
+Some of this infrastructure, namely ca.@: 20 Autoconf macro files and the
@file{config.rpath} file, is also contained in Gnulib and may be imported
by @code{gnulib-tool}. The use of @code{gettextize} or @code{autopoint}
will therefore overwrite some of the files that @code{gnulib-tool} has
If you get an error message like
@code{*** error: gettext infrastructure mismatch:
using a Makefile.in.in from gettext version ...
-but the autoconf macros are from gettext version ...},
-it means that a new GNU gettext release was made, and its autoconf macros
+but the Autoconf macros are from gettext version ...},
+it means that a new GNU gettext release was made, and its Autoconf macros
were integrated into Gnulib and now mismatch the @file{po/} infrastructure.
In this case, fetch and install the new GNU gettext release and run
@code{gettextize} followed by @code{gnulib-tool}.
@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
+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
+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.
Here, the @code{TESTS_ENVIRONMENT} variable can be used to pass values
determined by @code{configure} or by the @code{Makefile} to the shell
-script, as environment variables. The values of @code{EXEEXT} and of
-@code{srcdir}, from Autoconf and Automake, are already provided as
-environment variables, through an initial value of @code{TESTS_ENVIRONMENT}
-that @code{gnulib-tool} puts in place.
+script, as environment variables. The Autoconf values @code{EXEEXT}
+and @code{srcdir} are already provided as environment variables,
+through an initial value of @code{TESTS_ENVIRONMENT} that
+@code{gnulib-tool} puts in place.
Regardless of the specific form of the unit test, the following guidelines
should be respected:
@item Create gnulib directory
-On a machine with recent automake, autoconf, m4 installed and with a
-gnulib git checkout (typically a Linux machine), use
+On a machine with GNU development tools installed and with a gnulib
+git checkout, use
@example
gnulib-tool --create-megatestdir --with-tests --dir=...
placed (default \"tests\").
--aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
tools are placed (default comes from configure.ac).
+ --gnu-make Output for GNU Make instead of for the default
+ Automake
--lgpl[=2|=3orGPLv2|=3]
Abort if modules aren't available under the LGPL.
Also modify license template from GPL to LGPL.
The version number of the LGPL can be specified;
the default is currently LGPLv3.
- --makefile-name=NAME Name of makefile in automake syntax in the
- source-base and tests-base directories
- (default \"Makefile.am\").
+ --makefile-name=NAME Name of makefile in the source-base and tests-base
+ directories (default \"Makefile.am\", or
+ \"Makefile.in\" if --gnu-make).
--macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
'gl_INIT'. Default is 'gl'.
--po-domain=NAME Specify the prefix of the i18n domain. Usually use
# - 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
+# - gnu_make true if --gnu-make was given, false otherwise
# - makefile_name from --makefile-name
# - libtool true if --libtool was given, false if --no-libtool was
# given, blank otherwise
avoidlist=
cond_dependencies=
lgpl=
+ gnu_make=false
makefile_name=
libtool=
macro_prefix=
esac
lgpl=$arg
shift ;;
+ --gnu-make )
+ gnu_make=true
+ shift ;;
--makefile-name )
shift
if test $# = 0; then
# func_modules_transitive_closure
# Input:
# - local_gnulib_path from --local-dir
+# - gnu_make true if --gnu-make was given, false otherwise
# - modcache true or false, from --cache-modules/--no-cache-modules
# - modules list of specified modules
# - inctests true if tests should be included, false otherwise
if func_acceptable $module; then
func_append outmodules " $module"
if test "$cond_dependencies" = true; then
- if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
+ if ! $gnu_make \
+ && 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
# would get an error
# - libname library name
# - pobase directory relative to destdir where to place *.po files
# - auxdir directory relative to destdir where to place build aux files
+# - gnu_make true if --gnu-make was given, false otherwise
# - makefile_name from --makefile-name
# - libtool true if libtool will be used, false or blank otherwise
# - macro_prefix prefix of gl_LIBOBJS macros to use
# - uses_subdirs nonempty if object files in subdirs exist
func_emit_lib_Makefile_am ()
{
- # When creating an includable Makefile.am snippet, augment variables with
- # += instead of assigning them.
- if test -n "$makefile_name"; then
+
+ # When using GNU make, or when creating an includable Makefile.am snippet,
+ # augment variables with += instead of assigning them.
+ if $gnu_make || test -n "$makefile_name"; then
assign='+='
else
assign='='
# Skip the contents if it's entirely empty.
if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
echo "## begin gnulib module $module"
+ if $gnu_make; then
+ echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
+ convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
+ else
+ convert_to_gnu_make=
+ fi
echo
if test "$cond_dependencies" = true; then
if func_cond_module_p "$module"; then
func_module_conditional_name "$module"
- echo "if $conditional"
+ if $gnu_make; then
+ echo "ifneq (,\$($conditional))"
+ else
+ echo "if $conditional"
+ fi
fi
fi
- cat "$tmp"/amsnippet1
+ sed "$convert_to_gnu_make" "$tmp"/amsnippet1
if test "$cond_dependencies" = true; then
if func_cond_module_p "$module"; then
echo "endif"
fi
fi
- cat "$tmp"/amsnippet2
+ sed "$convert_to_gnu_make" "$tmp"/amsnippet2
+ if $gnu_make; then
+ echo "endif"
+ fi
echo "## end gnulib module $module"
echo
fi
echo "DISTCLEANFILES ="
echo "MAINTAINERCLEANFILES ="
fi
+ if $gnu_make; then
+ echo "# Start of GNU Make output."
+ echo 'gl_EARLY;gl_INIT' \
+ | ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
+ | LC_ALL=C sort -u
+ echo "# End of GNU Make output."
+ else
+ echo "# No GNU Make output."
+ fi
# Execute edits that apply to the Makefile.am being generated.
edit=0
while test $edit != $makefile_am_edits; do
fi
cat "$tmp"/allsnippets \
| sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
+ # Determine variables the automake snippet mentions.
+ if false && $gnu_make; then
+ sed_get_makefile_vars='
+ :again
+ /@/!d
+ s/^[^@]*@//
+ h
+ /^[a-zA-Z_][a-zA-Z_0-9]*@/{
+ s/@.*//p
+ g
+ s/^[^@]*@//
+ h
+ }
+ g
+ b again
+ '
+ substs=`func_get_automake_snippet "$module" \
+ | LC_ALL=C sed -e "$sed_get_makefile_vars"`
+ fi
echo
echo "mostlyclean-local: mostlyclean-generic"
echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
# - modules list of modules, including dependencies
# - libname library name
# - auxdir directory relative to destdir where to place build aux files
+# - gnu_make true if --gnu-make was given, false otherwise
# - makefile_name from --makefile-name
# - libtool true if libtool will be used, false or blank otherwise
# - sourcebase relative directory containing lib source code
fi
done
{ echo "## begin gnulib module $module"
+ if $gnu_make; then
+ echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
+ fi
echo
cat "$tmp"/amsnippet
+ if $gnu_make; then
+ echo "endif"
+ fi
echo "## end gnulib module $module"
echo
} >&$ofd
func_emit_pre_early_macros : ' ' "$final_modules"
- if test -n "$uses_subdirs"; then
+ if ! $gnu_make && test -n "$uses_subdirs"; then
echo " AC_REQUIRE([AM_PROG_CC_C_O])"
fi
for module in $final_modules; do