[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] gnulib-tool --import
From: |
Simon Josefsson |
Subject: |
[Bug-gnulib] gnulib-tool --import |
Date: |
Sat, 07 Aug 2004 16:57:15 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
This isn't finished, but I reckoned since I'm now using it
successfully for Shishi, it can't be that bad. I'll start using it in
other packages too, and then resubmit any changes.
Some issues:
* I'm assuming automake 1.8, so no Makefile.am for *.m4.
* The user need to put gl_EARLY, gl_INIT, and AC_OUTPUT($gl/Makefile)
in configure.ac, and add SUBDIRS = $gl to some Makefile.
* I want to make it possible for the generated Makefile.am to really
be called 'gnulib.mk', so the application to use 'include
gnulib.mk' in his Makefile.am, to add some local changes. This
need some automake changes, see bug-automake list. This would not
be the default, I think, but enabled via --makefile=gnulib.mk.
* LTALLOCA doesn't work?!
* Multiple AM_GNU_GETTEXT causes m4 to infloop.
* libfoo.a is now known as libgnu.a. :-)
Here's how I use it for Shishi:
address@hidden:~/src/shishi$ ../gnulib/gnulib-tool --import --source-base=gl
--m4-base=gl/m4 --libtool error getopt realloc setenv strcase strchrnul strnlen
strdup strndup xstrndup vasprintf vasnprintf xalloc getdate timegm gethostname
xgethostname xgetdomainname getline xreadlink progname getsubopt
Thoughts, comments and suggestions appreciated.
Index: gnulib-tool
===================================================================
RCS file: /cvsroot/gnulib/gnulib/gnulib-tool,v
retrieving revision 1.13
diff -u -p -u -w -r1.13 gnulib-tool
--- gnulib-tool 17 Sep 2003 18:30:23 -0000 1.13
+++ gnulib-tool 7 Aug 2004 14:49:59 -0000
@@ -1,6 +1,6 @@
#! /bin/sh
#
-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -80,6 +80,12 @@ Operation modes:
Options:
--dir=DIRECTORY specify the target directory
--lib=LIBRARY specify the library name
+ --source-base=DIRECTORY
+ directory relative --dir where source code is
+ placed (default \"lib\"), for --import.
+ --m4-base=DIRECTORY directory relative --dir where *.m4 macros are
+ placed (default \"m4\"), for --import.
+ --libtool use libtool rules, for --import.
--no-changelog don't update or create ChangeLog files
Report bugs to <address@hidden>."
@@ -110,11 +116,17 @@ func_fatal_error ()
# - mode list or import or create-testdir or create-megatestdir
# - destdir from --dir
# - libname from --lib
+# - sourcebase from --source-base
+# - m4base from --m4-base
+# - libtool true if --libtool was given, blank otherwise
# - do_changelog false if --no-changelog was given, : otherwise
{
mode=
destdir=
- libname=libfoo
+ libname=libgnu
+ sourcebase=lib
+ m4base=m4
+ libtool=
do_changelog=:
while test $# -gt 0; do
@@ -160,6 +172,29 @@ func_fatal_error ()
--lib=* )
libname=`echo "X$1" | sed -e 's/^X--lib=//'`
shift ;;
+ --source-base )
+ shift
+ if test $# = 0; then
+ func_fatal_error "missing argument for --source-base"
+ fi
+ sourcebase=$1
+ shift ;;
+ --source-base=* )
+ sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
+ shift ;;
+ --m4-base )
+ shift
+ if test $# = 0; then
+ func_fatal_error "missing argument for --m4-base"
+ fi
+ m4base=$1
+ shift ;;
+ --m4-base=* )
+ m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
+ shift ;;
+ --libtool )
+ libtool=true
+ shift ;;
--no-changelog | --no-changelo | --no-changel | --no-change | --no-chang
| --no-chan | --no-cha | --no-ch | --no-c )
do_changelog=false
shift ;;
@@ -534,7 +569,131 @@ case $mode in
;;
import )
- func_fatal_error "NYI" ;;
+ if test -z "$destdir"; then
+ destdir=.
+ fi
+ test -d "$destdir" \
+ || func_fatal_error "destination directory does not exist: $destdir"
+ test -d "$destdir/$sourcebase" || \
+ mkdir "$destdir/$sourcebase" || \
+ func_fatal_error "could not create source base directory:
$destdir/$sourcebase"
+ test -d "$destdir/$m4base" || \
+ mkdir "$destdir/$m4base" || \
+ func_fatal_error "could not create m4 base directory:
$destdir/$m4base"
+ supplied_modules="$*"
+ modules=`for m in $supplied_modules; do echo $m; done | sort | uniq`
+
+ # Determine final module list.
+ while true; do
+ xmodules=
+ for module in $modules; do
+ func_verify_module
+ if test -n "$module"; then
+ # Duplicate dependenies are harmless, but Jim wants a
warning.
+ duplicated_deps=`func_get_dependencies $module | sort |
uniq -d`
+ if test -n "$duplicated_deps"; then
+ echo "warning: module $module has duplicated
dependencies: "`echo $duplicated_deps` 1>&2
+ fi
+ xmodules="$xmodules $module "`func_get_dependencies $module`
+ fi
+ done
+ xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
+ if test "$xmodules" = "$modules"; then
+ break
+ fi
+ modules="$xmodules"
+ done
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+
+ # Determine final file list.
+ files=
+ for module in $modules; do
+ func_verify_module
+ if test -n "$module"; then
+ files="$files "`func_get_filelist $module`
+ fi
+ done
+ files=`for f in $files; do echo $f; done | sort | uniq`
+ echo "File list:"
+ echo "$files" | sed -e 's/^/ /'
+
+ # Copy files.
+ for f in $files; do
+ case "$f" in
+ config/*) g=`echo "$f" | sed -e 's,^config/,,'` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ *) g="$f" ;;
+ esac
+ cp -p "$gnulib_dir/$f" "$destdir/$g"
+ done
+
+ # Create lib/Makefile.am.
+ if test -n "$libtool"; then
+ libext=la
+ perhapsLT=LT
+ else
+ libext=a
+ perhapsLT=
+ fi
+ (echo "## Process this file with automake to produce Makefile.in."
+ echo
+ echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
+ echo
+ echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
+ echo
+ echo "${libname}_${libext}_SOURCES ="
+ echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
+ echo "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
+ echo "MOSTLYCLEANFILES ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ for module in $modules; do
+ func_verify_module
+ if test -n "$module"; then
+ func_get_automake_snippet "$module" | sed -e
"s,lib_SOURCES,${libname}_${libext}_SOURCES,g" -e
"s,lib_OBJECTS,${libname}_${libext}_OBJECTS,g"
+ if test "$module" = 'alloca'; then
+ echo "${libname}_${libext}_LIBADD += @ALLOCA@"
+ fi
+ fi
+ done
+ ) > "$destdir/$sourcebase/Makefile.am"
+
+ # Create gnulib.m4.
+ (echo "# Generated by gnulib-tool."
+ echo "#"
+ echo "# gnulib-tool --import --dir=$destdir \\"
+ echo "# --source-base=$sourcebase --m4-base=$m4base \\"
+ if test -n "$libtool"; then
+ echo "# --libtool \\"
+ fi
+ echo "# $supplied_modules"
+ echo
+ echo "AC_DEFUN([gl_EARLY],"
+ echo "["
+ if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
+ echo " AC_GNU_SOURCE"
+ fi
+ if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >
/dev/null; then
+ echo " gl_USE_SYSTEM_EXTENSIONS"
+ fi
+ echo "])"
+ echo
+ echo "AC_DEFUN([gl_INIT],"
+ echo "["
+ for module in $modules; do
+ func_verify_module
+ if test -n "$module"; then
+ func_get_autoconf_snippet "$module" | sed -e '/^$/d;' -e
's/^/ /' -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add
AM_GNU_GETTEXT([external]) or similar to configure.ac./'
+ fi
+ done
+ echo "])"
+ ) > "$destdir/$m4base/gnulib.m4"
+ ;;
create-testdir )
if test -z "$destdir"; then
- [Bug-gnulib] gnulib-tool --import,
Simon Josefsson <=
- Re: [Bug-gnulib] gnulib-tool --import, Gary V . Vaughan, 2004/08/07
- [Bug-gnulib] Re: gnulib-tool --import, Simon Josefsson, 2004/08/07
- [Bug-gnulib] Re: gnulib-tool --import, Paul Eggert, 2004/08/12
- [Bug-gnulib] Re: gnulib-tool --import, Simon Josefsson, 2004/08/12
- Re: [Bug-gnulib] Re: gnulib-tool --import, Gary V. Vaughan, 2004/08/16
- [Bug-gnulib] Re: gnulib-tool --import, Simon Josefsson, 2004/08/16
- Re: [Bug-gnulib] Re: gnulib-tool --import, Paul Eggert, 2004/08/17