comparison gnulib-tool @ 5198:9317c9ebe82c

Add --source-base, --m4-base, --libtool options. Change default library name from libfoo to libgnu.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 12 Aug 2004 20:47:12 +0000
parents ed7cd4050365
children 64446bf39961
comparison
equal deleted inserted replaced
5197:53db84a8853e 5198:9317c9ebe82c
1 #! /bin/sh 1 #! /bin/sh
2 # 2 #
3 # Copyright (C) 2002, 2003 Free Software Foundation, Inc. 3 # Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option) 7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version. 8 # any later version.
20 # This program is meant for authors or maintainers which want to import 20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages. 21 # modules from gnulib into their packages.
22 22
23 progname=$0 23 progname=$0
24 package=gnulib 24 package=gnulib
25 cvsdatestamp='$Date: 2003-09-17 18:30:23 $' 25 cvsdatestamp='$Date: 2004-08-12 20:47:12 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` 26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` 27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
28 28
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH. 29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
30 AUTOCONFPATH= 30 AUTOCONFPATH=
44 # outputs to stdout the --help usage message. 44 # outputs to stdout the --help usage message.
45 func_usage () 45 func_usage ()
46 { 46 {
47 echo "\ 47 echo "\
48 Usage: gnulib-tool --list 48 Usage: gnulib-tool --list
49 gnulib-tool --import module1 ... moduleN 49 gnulib-tool --import [MODULE...]
50 gnulib-tool --create-testdir --dir=directory module1 ... moduleN 50 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
51 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN] 51 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
52 gnulib-tool --test --dir=directory module1 ... moduleN 52 gnulib-tool --test --dir=directory module1 ... moduleN
53 gnulib-tool --megatest --dir=directory [module1 ... moduleN] 53 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
54 gnulib-tool --extract-description module 54 gnulib-tool --extract-description module
77 --extract-include-directive extract the #include directive 77 --extract-include-directive extract the #include directive
78 --extract-maintainer report the maintainer(s) inside gnulib 78 --extract-maintainer report the maintainer(s) inside gnulib
79 79
80 Options: 80 Options:
81 --dir=DIRECTORY specify the target directory 81 --dir=DIRECTORY specify the target directory
82 --lib=LIBRARY specify the library name 82 For --import, this specify where your
83 configure.ac can be found. Defaults to current
84 directory.
85 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
86 --source-base=DIRECTORY
87 Directory relative --dir where source code is
88 placed (default \"lib\"), for --import.
89 --m4-base=DIRECTORY Directory relative --dir where *.m4 macros are
90 placed (default \"m4\"), for --import.
91 --libtool Use libtool rules, for --import.
83 --no-changelog don't update or create ChangeLog files 92 --no-changelog don't update or create ChangeLog files
84 93
85 Report bugs to <bug-gnulib@gnu.org>." 94 Report bugs to <bug-gnulib@gnu.org>."
86 } 95 }
87 96
108 # Command-line option processing. 117 # Command-line option processing.
109 # Removes the OPTIONS from the arguments. Sets the variables: 118 # Removes the OPTIONS from the arguments. Sets the variables:
110 # - mode list or import or create-testdir or create-megatestdir 119 # - mode list or import or create-testdir or create-megatestdir
111 # - destdir from --dir 120 # - destdir from --dir
112 # - libname from --lib 121 # - libname from --lib
122 # - sourcebase from --source-base
123 # - m4base from --m4-base
124 # - libtool true if --libtool was given, blank otherwise
113 # - do_changelog false if --no-changelog was given, : otherwise 125 # - do_changelog false if --no-changelog was given, : otherwise
114 { 126 {
115 mode= 127 mode=
116 destdir= 128 destdir=
117 libname=libfoo 129 libname=libgnu
130 sourcebase=lib
131 m4base=m4
132 libtool=
118 do_changelog=: 133 do_changelog=:
119 134
120 while test $# -gt 0; do 135 while test $# -gt 0; do
121 case "$1" in 136 case "$1" in
122 --list | --lis ) 137 --list | --lis )
157 fi 172 fi
158 libname=$1 173 libname=$1
159 shift ;; 174 shift ;;
160 --lib=* ) 175 --lib=* )
161 libname=`echo "X$1" | sed -e 's/^X--lib=//'` 176 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
177 shift ;;
178 --source-base )
179 shift
180 if test $# = 0; then
181 func_fatal_error "missing argument for --source-base"
182 fi
183 sourcebase=$1
184 shift ;;
185 --source-base=* )
186 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
187 shift ;;
188 --m4-base )
189 shift
190 if test $# = 0; then
191 func_fatal_error "missing argument for --m4-base"
192 fi
193 m4base=$1
194 shift ;;
195 --m4-base=* )
196 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
197 shift ;;
198 --libtool )
199 libtool=true
162 shift ;; 200 shift ;;
163 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c ) 201 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
164 do_changelog=false 202 do_changelog=false
165 shift ;; 203 shift ;;
166 --help | --hel | --he | --h ) 204 --help | --hel | --he | --h )
532 list ) 570 list )
533 func_all_modules 571 func_all_modules
534 ;; 572 ;;
535 573
536 import ) 574 import )
537 func_fatal_error "NYI" ;; 575 if test -z "$destdir"; then
576 destdir=.
577 fi
578 test -d "$destdir" \
579 || func_fatal_error "destination directory does not exist: $destdir"
580 sourcebase=`cd $destdir; $AUTOCONF --trace=gl_SOURCE_BASE | sed 's,^.*:,,g'`
581 test -d "$destdir/$sourcebase" || \
582 mkdir "$destdir/$sourcebase" || \
583 func_fatal_error \
584 "could not create source base directory: $destdir/$sourcebase"
585 m4base=`cd $destdir; $AUTOCONF --trace=gl_M4_BASE | sed 's,^.*:,,g'`
586 test -d "$destdir/$m4base" || \
587 mkdir "$destdir/$m4base" || \
588 func_fatal_error \
589 "could not create m4 base directory: $destdir/$m4base"
590 supplied_modules="$*"
591 modules=`for m in $supplied_modules; do echo $m; done | sort | uniq`
592 if test -z "$modules"; then
593 modules=`cd $destdir; $AUTOCONF --trace=gl_MODULES | sed 's,^.*:,,g'`
594 fi
595 if test x`cd $destdir; $AUTOCONF --trace=AC_PROG_LIBTOOL` != x; then
596 libtool=true
597 fi
598
599 # Determine final module list.
600 while true; do
601 xmodules=
602 for module in $modules; do
603 func_verify_module
604 if test -n "$module"; then
605 # Duplicate dependenies are harmless, but Jim wants a warning.
606 duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
607 if test -n "$duplicated_deps"; then
608 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
609 fi
610 xmodules="$xmodules $module "`func_get_dependencies $module`
611 fi
612 done
613 xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
614 if test "$xmodules" = "$modules"; then
615 break
616 fi
617 modules="$xmodules"
618 done
619 echo "Module list with included dependencies:"
620 echo "$modules" | sed -e 's/^/ /'
621
622 # Determine final file list.
623 files=
624 for module in $modules; do
625 func_verify_module
626 if test -n "$module"; then
627 files="$files "`func_get_filelist $module`
628 fi
629 done
630 files=`for f in $files; do echo $f; done | sort | uniq`
631 echo "File list:"
632 echo "$files" | sed -e 's/^/ /'
633
634 # Copy files.
635 for f in $files; do
636 case "$f" in
637 config/*) g=`echo "$f" | sed -e 's,^config/,,'` ;;
638 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
639 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
640 *) g="$f" ;;
641 esac
642 cp -p "$gnulib_dir/$f" "$destdir/$g"
643 done
644
645 # Create lib/Makefile.am.
646 if test -n "$libtool"; then
647 libext=la
648 perhapsLT=LT
649 else
650 libext=a
651 perhapsLT=
652 fi
653 (echo "## Process this file with automake to produce Makefile.in."
654 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
655 echo "#"
656 echo "# This file is free software, distributed under the terms of the GNU"
657 echo "# General Public License. As a special exception to the GNU General"
658 echo "# Public License, this file may be distributed as part of a program"
659 echo "# that contains a configuration script generated by Automake, under"
660 echo "# the same distribution terms as the rest of that program."
661 echo "#"
662 echo "# Generated by gnulib-tool."
663 echo "#"
664 opt_libtool=
665 if test -n "$libtool"; then
666 opt_libtool="--libtool"
667 fi
668 echo "# gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base $opt_libtool $supplied_modules"
669 echo
670 echo "AUTOMAKE_OPTIONS = 1.8 gnits"
671 echo
672 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
673 echo
674 echo "${libname}_${libext}_SOURCES ="
675 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
676 echo "EXTRA_DIST ="
677 echo "BUILT_SOURCES ="
678 echo "SUFFIXES ="
679 echo "MOSTLYCLEANFILES ="
680 echo "CLEANFILES ="
681 echo "DISTCLEANFILES ="
682 echo "MAINTAINERCLEANFILES ="
683 for module in $modules; do
684 func_verify_module
685 if test -n "$module"; then
686 func_get_automake_snippet "$module" | sed -e "s,lib_SOURCES,${libname}_${libext}_SOURCES,g" -e "s,lib_OBJECTS,${libname}_${libext}_OBJECTS,g"
687 if test "$module" = 'alloca'; then
688 echo "${libname}_${libext}_LIBADD += @ALLOCA@"
689 fi
690 fi
691 done
692 ) > "$destdir/$sourcebase/Makefile.am"
693
694 # Create gnulib.m4.
695 (echo "# Copyright (C) 2004 Free Software Foundation, Inc."
696 echo "# This file is free software, distributed under the terms of the GNU"
697 echo "# General Public License. As a special exception to the GNU General"
698 echo "# Public License, this file may be distributed as part of a program"
699 echo "# that contains a configuration script generated by Autoconf, under"
700 echo "# the same distribution terms as the rest of that program."
701 echo "#"
702 echo "# Generated by gnulib-tool."
703 echo "#"
704 opt_libtool=
705 if test -n "$libtool"; then
706 opt_libtool="--libtool"
707 fi
708 echo "# gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base $opt_libtool $supplied_modules"
709 echo
710 echo "AC_DEFUN([gl_EARLY],"
711 echo "["
712 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
713 echo " AC_GNU_SOURCE"
714 fi
715 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
716 echo " gl_USE_SYSTEM_EXTENSIONS"
717 fi
718 echo "])"
719 echo
720 echo "AC_DEFUN([gl_INIT],"
721 echo "["
722 for module in $modules; do
723 func_verify_module
724 if test -n "$module"; then
725 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./'
726 fi
727 done
728 echo "])"
729 echo
730 echo "dnl Usage: gl_MODULES(module1 module2 ...)"
731 echo "AC_DEFUN([gl_MODULES], [])"
732 echo
733 echo "dnl Usage: gl_SOURCE_BASE(DIR)"
734 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
735 echo
736 echo "dnl Usage: gl_M4_BASE(DIR)"
737 echo "AC_DEFUN([gl_M4_BASE], [])"
738 ) > "$destdir/$m4base/gnulib.m4"
739 ;;
538 740
539 create-testdir ) 741 create-testdir )
540 if test -z "$destdir"; then 742 if test -z "$destdir"; then
541 func_fatal_error "please specify --dir option" 743 func_fatal_error "please specify --dir option"
542 fi 744 fi