[parted-devel] gnulibify, and auto-modernize (partially), etc.

Jim Meyering jim at meyering.net
Tue Feb 20 19:29:37 CET 2007


Here's the promised change set.
Among lots of other things, now,

  parted --version > /dev/full

reports the write error.  Before, it didn't.

Also, it adds translations for Polish and Kinyarwanda,
but removes Hungarian, since it's not available from the
Translation Project web pages.

Please don't apply the following patch directly.  It's just the
meat of the change, but incomplete.  E.g., it doesn't include
the po/*.po deletions, nor the **/.gitignore additions.
*that* patch weighs in at nearly 2MB:

  http://meyering.net/code/tmp/parted-gnuliberate.patch

P.s., also in the full patch, but not below,
some important documentation:

	Add build-from-checkout instructions.
	* README-hacking: New file.  Mostly copied from coreutils'
	README-cvs.
	* bootstrap: Generate ChangeLog here, if needed/possible,
	before invoking tools that require its presence.
	* autogen.sh: Remove this file.  It's superseded by bootstrap.

--------------------------

>From ed233e1c978f48cf15744c97fa547cadf48d42cf Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim at meyering.net>
Date: Tue, 20 Feb 2007 18:51:37 +0100
Subject: [PATCH] Use gnulib, modernize some uses of autoconf, automake, etc.
* bootstrap, bootstrap.conf: New files.

* libparted/Makefile.am (partedincludedir): Add -I$(top_srcdir)/lib.
* libparted/libparted.c: Include "configmake.h" for LOCALEDIR defn.
* parted/Makefile.am (parted_LDADD): Add lib/libparted.la.
(partedincludedir): Add -I$(top_srcdir)/lib.
* parted/ui.c: Include <config.h>, not "../config.h".

* Makefile.am (SUBDIRS): Add lib.
(EXTRA_DIST): Remove names that are automatically included.
* lib/Makefile.am: New file.

* configure.ac: Modernize.
Require the latest stable releases: autoconf-2.61, automake-1.10.
Require gettext-0.15.
Use more modern form of AC_INIT, etc.
Now that the version string must be hard-coded in the AC_INIT line,
add code to ensure it agrees with the PED_* and LT_* variables.
Use AM_CPPFLAGS, not CFLAGS
Remove obsolete setting of ALL_LINGUAS.
Don't set CFLAGS=-D_GNU_SOURCE=1 explicitly , since that's already
done via AC_GNU_SOURCE, which gnulib pulls in by default,
through gl_EARLY.
Use gl_INIT and gl_EARLY.

* debug/clearfat/clearfat.c (_do_help): Use fputs, not printf.

* parted/parted.c: Include <config.h>, not "../config.h".
Include "closeout.h" for close_stdout.
Include "configmake.h" for LOCALEDIR definition.
Include "version-etc.h" for version_etc prototype.
Declare global, program_name.
(PROGRAM_NAME, AUTHORS): Define.
(_version): Use gnulib's version_etc.
(main): Set program_name.
Use atexit to close stdout carefully upon exit.

Include <config.h> from every .c file:
* libparted/unit.c, libparted/timer.c:
* libparted/cs/natmath.c, libparted/cs/constraint.c:
* libparted/tests/label.c, libparted/tests/common.c:
* libparted/fs/fat/count.c, libparted/fs/fat/bootsector.c:
* libparted/fs/fat/context.c, libparted/fs/fat/fatio.c:
* libparted/fs/fat/fat.c, libparted/fs/fat/clstdup.c:
* libparted/fs/fat/resize.c, libparted/fs/fat/traverse.c:
* libparted/fs/fat/table.c, libparted/fs/fat/calc.c:
* libparted/fs/amiga/amiga.c, libparted/labels/fdasd.c:
* libparted/labels/dvh.c, libparted/labels/efi_crc32.c:
* libparted/labels/vtoc.c, parted/command.c:

* libparted/tests/label.c: Include <config.h>.
Fail if _create_disk returns NULL.
Make global and functions static.
* libparted/tests/common.c: Include <config.h>.
(_create_disk): Handle fopen failure.
Handle fclose failure.

Signed-off-by: Jim Meyering <jim at meyering.net>
---
 Makefile.am                   |   15 +-
 bootstrap                     |  515 +++++++++++++++++++++++++++++++++++++++++
 bootstrap.conf                |   78 ++++++
 configure.ac                  |   40 ++--
 debug/clearfat/clearfat.c     |    2 +-
 lib/Makefile.am               |    1 +
 libparted/Makefile.am         |    4 +-
 libparted/cs/constraint.c     |    1 +
 libparted/cs/natmath.c        |    3 +-
 libparted/fs/amiga/amiga.c    |    1 +
 libparted/fs/fat/bootsector.c |    1 +
 libparted/fs/fat/calc.c       |    1 +
 libparted/fs/fat/clstdup.c    |    1 +
 libparted/fs/fat/context.c    |    3 +-
 libparted/fs/fat/count.c      |    1 +
 libparted/fs/fat/fat.c        |    1 +
 libparted/fs/fat/fatio.c      |    3 +-
 libparted/fs/fat/resize.c     |    1 +
 libparted/fs/fat/table.c      |    1 +
 libparted/fs/fat/traverse.c   |    1 +
 libparted/labels/dvh.c        |    1 +
 libparted/labels/efi_crc32.c  |    1 +
 libparted/labels/fdasd.c      |    1 +
 libparted/labels/vtoc.c       |    1 +
 libparted/libparted.c         |    3 +-
 libparted/tests/common.c      |   23 ++-
 libparted/tests/label.c       |   13 +-
 libparted/timer.c             |    3 +-
 libparted/unit.c              |    1 +
 parted/Makefile.am            |    9 +-
 parted/command.c              |    3 +-
 parted/parted.c               |   22 ++-
 parted/ui.c                   |    2 +-
 33 files changed, 697 insertions(+), 60 deletions(-)
 create mode 100755 bootstrap
 create mode 100644 bootstrap.conf
 create mode 100644 lib/Makefile.am

diff --git a/Makefile.am b/Makefile.am
index 1ab5f13..9dbbd09 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,13 +1,8 @@
 ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = po libparted parted partprobe include doc debug
+SUBDIRS = po lib libparted parted partprobe include doc debug
 
-EXTRA_DIST = config.rpath                          \
-             ABOUT-NLS                             \
-             AUTHORS                               \
+EXTRA_DIST = \
              BUGS                                  \
-             COPYING                               \
-             THANKS                                \
-             TODO                                  \
 	     libparted.pc.in			   \
              parted.spec.in                        \
              parted.m4                             \
@@ -28,7 +23,7 @@ dist-hook: parted.spec
 baseline_file = ${top_srcdir}/scripts/data/abi/baseline_symbols.txt
 extract_symvers = $(top_srcdir)/scripts/extract_symvers
 
-current_symbols.txt: ${extract_symvers} 
+current_symbols.txt: ${extract_symvers}
 	  -@(sh ${extract_symvers} libparted/.libs/libparted.so current_symbols.txt)
 
 baseline_symbols:
@@ -58,6 +53,8 @@ check-abi: baseline_symbols current_symbols.txt
          && (echo "ABI has changed. Please, update you ABI package version."; exit 1) \
          || exit 0
 
+MOSTLYCLEANDIRS = m4
+
 MAINTAINERCLEANFILES = ABOUT-NLS     \
                        ChangeLog     \
                        INSTALL       \
@@ -73,4 +70,4 @@ MAINTAINERCLEANFILES = ABOUT-NLS     \
                        install-sh    \
                        ltmain.sh     \
                        missing       \
-                       mkinstalldirs
\ No newline at end of file
+                       mkinstalldirs
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..488145c
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,515 @@
+#! /bin/sh
+
+# Bootstrap this package from CVS.
+
+# Copyright (C) 2003, 2004, 2005, 2006, 2007 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Written by Paul Eggert.
+
+nl='
+'
+
+# Ensure file names are sorted consistently across platforms.
+# Also, ensure diagnostics are in English, e.g., "wget --help" below.
+LC_ALL=C
+export LC_ALL
+
+# Temporary directory names.
+bt='._bootmp'
+bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
+bt2=${bt}2
+
+usage() {
+  echo >&2 "\
+Usage: $0 [OPTION]...
+Bootstrap this package from the checked-out sources.
+
+Options:
+ --gnulib-srcdir=DIRNAME  Specify the local directory where gnulib
+                          sources reside.  Use this if you already
+                          have gnulib sources on your machine, and
+                          do not want to waste your bandwidth downloading
+                          them again.
+ --copy                   Copy files instead of creating symbolic links.
+ --force                  Attempt to bootstrap even if the sources seem
+                          not to have been checked out.
+ --skip-po                Do not download po files.
+ --cvs-user=USERNAME      Set the CVS username to be used when accessing
+                          the gnulib repository.
+
+If the file .bootstrap.conf exists in the current working directory, its
+contents are read as shell variables to configure the bootstrap.
+
+Running without arguments will suffice in most cases.
+"
+}
+
+# Configuration.
+
+# List of gnulib modules needed.
+gnulib_modules=
+
+# Any gnulib files needed that are not in modules.
+gnulib_files=
+
+# Translation Project URL, for the registry of all projects
+# and for the translation-team master directory.
+TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
+TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/'
+
+extract_package_name='
+  /^AC_INIT(/{
+     /.*,.*,.*,/{
+       s///
+       s/[][]//g
+       p
+       q
+     }
+     s/AC_INIT(\[*//
+     s/]*,.*//
+     s/^GNU //
+     y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+     s/[^A-Za-z0-9_]/-/g
+     p
+  }
+'
+package=`sed -n "$extract_package_name" configure.ac` || exit
+
+# Extra files from gnulib, which override files from other sources.
+gnulib_extra_files='
+	build-aux/install-sh
+	build-aux/missing
+	build-aux/mdate-sh
+	build-aux/texinfo.tex
+	build-aux/depcomp
+	build-aux/config.guess
+	build-aux/config.sub
+	doc/INSTALL
+'
+
+# Other locale categories that need message catalogs.
+EXTRA_LOCALE_CATEGORIES=
+
+# Additional xgettext options to use.  Use "\\\newline" to break lines.
+XGETTEXT_OPTIONS='\\\
+ --flag=_:1:pass-c-format\\\
+ --flag=N_:1:pass-c-format\\\
+ --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
+'
+
+# Files we don't want to import.
+excluded_files=
+
+# File that should exist in the top directory of a checked out hierarchy,
+# but not in a distribution tarball.
+CVS_only_file=bootstrap
+
+# Whether to use copies instead of symlinks.
+copy=false
+
+# Override the default configuration, if necessary.
+test -r bootstrap.conf && . ./bootstrap.conf
+
+# Translate configuration into internal form.
+
+# Parse options.
+
+for option
+do
+  case $option in
+  --help)
+    usage
+    exit;;
+  --gnulib-srcdir=*)
+    GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
+  --cvs-user=*)
+    CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
+  --skip-po)
+    SKIP_PO=t;;
+  --force)
+    CVS_only_file=;;
+  --copy)
+    copy=true;;
+  *)
+    echo >&2 "$0: $option: unknown option"
+    exit 1;;
+  esac
+done
+
+if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
+  echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
+  exit 1
+fi
+
+echo "$0: Bootstrapping CVS $package..."
+
+cleanup_gnulib() {
+  status=$?
+  rm -fr gnulib
+  exit $status
+}
+
+# Get gnulib files.
+
+case ${GNULIB_SRCDIR--} in
+-)
+  if [ ! -d gnulib ]; then
+    echo "$0: getting gnulib files..."
+
+    case ${CVS_AUTH-pserver} in
+    pserver)
+      CVS_PREFIX=':pserver:anonymous@';;
+    ssh)
+      CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
+    *)
+      echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
+      exit 1;;
+    esac
+
+    case $CVS_RSH in
+    '') CVS_RSH=ssh; export CVS_RSH;;
+    esac
+
+    trap cleanup_gnulib 1 2 13 15
+
+    cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib ||
+      cleanup_gnulib
+
+    trap - 1 2 13 15
+  fi
+  GNULIB_SRCDIR=gnulib
+esac
+
+gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
+<$gnulib_tool || exit
+
+# Get translations.
+
+get_translations() {
+  subdir=$1
+  domain=$2
+
+  case $WGET_COMMAND in
+  '')
+    echo "$0: wget not available; skipping translations";;
+  ?*)
+    echo "$0: getting translations into $subdir for $domain..." &&
+
+    (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) &&
+    $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
+
+    sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
+    sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
+    awk -F. '
+      { if (lang && $1 != lang) print lang, ver }
+      { lang = $1; ver = substr($0, index($0, ".") + 1) }
+      END { if (lang) print lang, ver }
+    ' | awk -v domain="$domain" -v subdir="$subdir" '
+      {
+	lang = $1
+	ver = $2
+	urlfmt = ""
+	printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang
+	printf "  msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
+	printf "    echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
+	printf "    rm -f %s/%s.po; }; } &&\n", subdir, lang
+      }
+      END { print ":" }
+    ' | WGET_COMMAND="$WGET_COMMAND" sh;;
+  esac &&
+  ls "$subdir"/*.po 2>/dev/null |
+    sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
+  rm -f "$subdir/$domain.html"
+}
+
+case $SKIP_PO in
+'')
+  case `wget --help` in
+  *'--no-cache'*)
+    WGET_COMMAND='wget -nv --no-cache';;
+  *'--cache=on/off'*)
+    WGET_COMMAND='wget -nv --cache=off';;
+  *'--non-verbose'*)
+    WGET_COMMAND='wget -nv';;
+  *)
+    WGET_COMMAND='';;
+  esac
+
+  get_translations po $package || exit
+
+  if test -d runtime-po; then
+    get_translations runtime-po $package-runtime || exit
+  fi;;
+esac
+
+symlink_to_gnulib()
+{
+  src=$GNULIB_SRCDIR/$1
+  dst=${2-$1}
+
+  test -f "$src" && {
+    if $copy; then
+      {
+	test ! -h "$dst" || {
+	  echo "$0: rm -f $dst" &&
+	  rm -f "$dst"
+	}
+      } &&
+      test -f "$dst" &&
+      cmp -s "$src" "$dst" || {
+	echo "$0: cp -fp $src $dst" &&
+	cp -fp "$src" "$dst"
+      }
+    else
+      test -h "$dst" &&
+      src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
+      dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
+      test "$src_i" = "$dst_i" || {
+	dot_dots=
+	case $src in
+	/*) ;;
+	*)
+	  case /$dst/ in
+	  *//* | */../* | */./* | /*/*/*/*/*/)
+	     echo >&2 "$0: invalid symlink calculation: $src -> $dst"
+	     exit 1;;
+	  /*/*/*/*/)	dot_dots=../../../;;
+	  /*/*/*/)	dot_dots=../../;;
+	  /*/*/)	dot_dots=../;;
+	  esac;;
+	esac
+
+	echo "$0: ln -fs $dot_dots$src $dst" &&
+	ln -fs "$dot_dots$src" "$dst"
+      }
+    fi
+  }
+}
+
+cp_mark_as_generated()
+{
+  cp_src=$1
+  cp_dst=$2
+
+  if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
+    symlink_to_gnulib "$cp_dst"
+  else
+    case $cp_dst in
+      *.[ch])             c1='/* '; c2=' */';;
+      *.texi)             c1='@c '; c2=     ;;
+      *.m4|*/Make*|Make*) c1='# ' ; c2=     ;;
+      *)                  c1=     ; c2=     ;;
+    esac
+
+    if test -z "$c1"; then
+      cmp -s "$cp_src" "$cp_dst" || {
+	echo "$0: cp -f $cp_src $cp_dst" &&
+	rm -f "$cp_dst" &&
+	sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
+      }
+    else
+      # Copy the file first to get proper permissions if it
+      # doesn't already exist.  Then overwrite the copy.
+      cp "$cp_src" "$cp_dst-t" &&
+      (
+	echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
+	echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
+	sed "s!$bt_regex/!!g" "$cp_src"
+      ) > $cp_dst-t &&
+      if cmp -s "$cp_dst-t" "$cp_dst"; then
+	rm -f "$cp_dst-t"
+      else
+	echo "$0: cp $cp_src $cp_dst # with edits" &&
+	mv -f "$cp_dst-t" "$cp_dst"
+      fi
+    fi
+  fi
+}
+
+version_controlled_file() {
+  dir=$1
+  file=$2
+  found=no
+  if test -d CVS; then
+    grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
+	     grep '^/[^/]*/[0-9]' > /dev/null && found=yes
+  elif test -d .git; then
+    git-rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
+  else
+    echo "$0: no version control for $dir/$file?" >&2
+  fi
+  test $found = yes
+}
+
+# If $STR is not already on a line by itself in $FILE, insert it,
+# sorting the new contents of the file and replacing $FILE with the result.
+insert_sorted_if_absent() {
+  file=$1
+  str=$2
+  echo "$str" | sort -u - $file | cmp -s - $file \
+    || echo "$str" | sort -u - $file -o $file \
+    || exit
+}
+
+slurp() {
+  for dir in . `(cd $1 && find * -type d -print)`; do
+    copied=
+    sep=
+    for file in `ls $1/$dir`; do
+      test -d $1/$dir/$file && continue
+      for excluded_file in $excluded_files; do
+	test "$dir/$file" = "$excluded_file" && continue 2
+      done
+      if test $file = Makefile.am; then
+        copied=$copied${sep}gnulib.mk; sep=$nl
+	remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
+        sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
+	  echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
+	  rm -f $dir/gnulib.mk &&
+	  sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
+	}
+      elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
+	   version_controlled_file $dir $file; then
+	echo "$0: $dir/$file overrides $1/$dir/$file"
+      else
+	copied=$copied$sep$file; sep=$nl
+	if test $file = gettext.m4; then
+	  echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
+	  rm -f $dir/$file
+	  sed '
+	    /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
+	      AC_DEFUN([AM_INTL_SUBDIR], [
+	    /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
+	      AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
+	    $a\
+	      AC_DEFUN([gl_LOCK_EARLY], [])
+	  ' $1/$dir/$file >$dir/$file
+	else
+	  cp_mark_as_generated $1/$dir/$file $dir/$file
+	fi
+      fi || exit
+    done
+
+    for dot_ig in .cvsignore .gitignore; do
+      ig=$dir/$dot_ig
+      if test -n "$copied" && test -f $ig; then
+	insert_sorted_if_absent $ig "$copied"
+	# If an ignored file name ends with _.h, then also add
+	# the name with just ".h".  Many gnulib headers are generated,
+	# e.g., stdint_.h -> stdint.h, dirent_.h ->..., etc.
+	f=`echo "$copied"|sed 's/_\.h$/.h/'`
+	insert_sorted_if_absent $ig "$f"
+      fi
+    done
+  done
+}
+
+
+# Create boot temporary directories to import from gnulib and gettext.
+rm -fr $bt $bt2 &&
+mkdir $bt $bt2 || exit
+
+# Import from gnulib.
+
+gnulib_tool_options="\
+ --import\
+ --no-changelog\
+ --aux-dir $bt/build-aux\
+ --doc-base $bt/doc\
+ --lib lib$package\
+ --m4-base $bt/m4/\
+ --source-base $bt/lib/\
+ --tests-base $bt/tests\
+ --local-dir gl\
+"
+echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
+$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
+slurp $bt || exit
+
+for file in $gnulib_files; do
+  symlink_to_gnulib $file || exit
+done
+
+
+# Import from gettext.
+
+echo "$0: (cd $bt2; autopoint) ..."
+cp configure.ac $bt2 &&
+(cd $bt2 && autopoint && rm configure.ac) &&
+slurp $bt2 $bt || exit
+
+rm -fr $bt $bt2 || exit
+
+
+# Reconfigure, getting other files.
+
+for command in \
+  'libtoolize -c -f' \
+  'aclocal --force -I m4' \
+  'autoconf --force' \
+  'autoheader --force' \
+  'automake --add-missing --copy --force-missing';
+do
+  echo "$0: $command ..."
+  $command || exit
+done
+
+
+# Get some extra files from gnulib, overriding existing files.
+
+for file in $gnulib_extra_files; do
+  case $file in
+  */INSTALL) dst=INSTALL;;
+  *) dst=$file;;
+  esac
+  symlink_to_gnulib $file $dst || exit
+done
+
+
+# Create gettext configuration.
+echo "$0: Creating po/Makevars from po/Makevars.template ..."
+rm -f po/Makevars
+sed '
+  /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
+  /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
+  /^XGETTEXT_OPTIONS *=/{
+    s/$/ \\/
+    a\
+	'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
+  }
+' po/Makevars.template >po/Makevars
+
+if test -d runtime-po; then
+  # Similarly for runtime-po/Makevars, but not quite the same.
+  rm -f runtime-po/Makevars
+  sed '
+    /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
+    /^subdir *=.*/s/=.*/= runtime-po/
+    /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
+    /^XGETTEXT_OPTIONS *=/{
+      s/$/ \\/
+      a\
+	  '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
+    }
+  ' <po/Makevars.template >runtime-po/Makevars
+
+  # Copy identical files from po to runtime-po.
+  (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
+fi
+
+echo "$0: done.  Now you can run './configure'."
diff --git a/bootstrap.conf b/bootstrap.conf
new file mode 100644
index 0000000..b874d93
--- /dev/null
+++ b/bootstrap.conf
@@ -0,0 +1,78 @@
+# Bootstrap configuration.
+
+# Copyright (C) 2006, 2007 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+
+# We don't need these modules, even though gnulib-tool mistakenly
+# includes them because of gettext and fchdir dependencies.
+avoided_gnulib_modules='
+	--avoid=lock
+	--avoid=size_max
+	--avoid=xsize
+	--avoid=canonicalize-lgpl
+'
+
+# These modules are obsolete and can probably be removed soon,
+# but leave them in for now to minimize changes.
+obsolete_gnulib_modules='
+	atexit free memchr memcmp memcpy memmove memset rename
+	strcspn strtod strtol utime
+'
+
+# gnulib modules used by this package.
+gnulib_modules="
+	$avoided_gnulib_modules
+	$obsolete_gnulib_modules
+	alloca announce-gen assert
+	calloc config-h configmake
+	closeout
+	fdl
+	gettext
+	gnupload
+	inttypes
+	lib-ignore
+	malloc
+	realloc
+	rpmatch
+	safe-read
+	stdbool
+	version-etc-fsf
+"
+
+# Additional xgettext options to use.  Use "\\\newline" to break lines.
+XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
+ --from-code=UTF-8\\\
+ --flag=asprintf:2:c-format --flag=vasprintf:2:c-format\\\
+ --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\
+ --flag=wrapf:1:c-format\\\
+'
+
+# Gettext supplies these files, but we don't need them since
+# we don't have an intl subdirectory.
+excluded_files='
+    m4/glibc2.m4
+    m4/intdiv0.m4
+    m4/lcmessage.m4
+    m4/lock.m4
+    m4/printf-posix.m4
+    m4/size_max.m4
+    m4/uintmax_t.m4
+    m4/ulonglong.m4
+    m4/visibility.m4
+    m4/xsize.m4
+'
diff --git a/configure.ac b/configure.ac
index 38b17f6..5d65ead 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,9 +4,13 @@ dnl Free Software Foundation, Inc.
 dnl
 dnl This file may be modified and/or distributed without restriction.
 
-AC_PREREQ(2.50)
+AC_PREREQ(2.61)
+AC_INIT([GNU parted],[1.9.9],[bug-parted at gnu.org])
 
-AC_INIT(include/parted/parted.h)
+AC_CONFIG_SRCDIR(include/parted/parted.h)
+
+AC_CONFIG_HEADERS([lib/config.h:lib/config.h.in])
+AC_CONFIG_AUX_DIR(build-aux)
 
 dnl Versioning
 dnl Shamelessly pulled straight from glib's configure.in ...
@@ -30,18 +34,17 @@ LT_RELEASE=$PED_MAJOR_VERSION.$PED_MINOR_VERSION
 LT_CURRENT=`expr $PED_MICRO_VERSION - $PED_INTERFACE_AGE`
 LT_REVISION=$PED_INTERFACE_AGE
 LT_AGE=`expr $PED_BINARY_AGE - $PED_INTERFACE_AGE`
-
 AC_SUBST(LT_RELEASE)
 AC_SUBST(LT_CURRENT)
 AC_SUBST(LT_REVISION)
 AC_SUBST(LT_AGE)
 
-PACKAGE=parted
-VERSION=$PED_VERSION
-
-AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+# Ensure that the PED_*-specified version is the same as the literal
+# in the AC_INIT line, above.
+test $PACKAGE_VERSION = $PED_VERSION ||
+  AC_MSG_ERROR(configure.ac: version mismatch: $PACKAGE_VERSION != $PED_VERSION)
 
-AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE([1.10 dist-bzip2])
 
 AC_CANONICAL_HOST
 case "$host_os" in
@@ -159,21 +162,23 @@ fi
 
 dnl make libc threadsafe (not required for us, but useful other users of
 dnl libparted)
-CFLAGS="$CFLAGS -D_REENTRANT"
+AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
 
 dnl Check for programs.
 AC_ISC_POSIX
 AC_PROG_CC
 AC_PROG_GCC_TRADITIONAL
 AM_PROG_CC_C_O
-AC_GNU_SOURCE
+
+gl_EARLY
 
 dnl This test must come as early as possible after the compiler configuration
 dnl tests, because the choice of the file model can (in principle) affect
 dnl whether functions and headers are available, whether they work, etc.
 AC_SYS_LARGEFILE
 
-CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=${ac_cv_sys_file_offset_bits}"
+gl_INIT
+
 AC_CHECK_SIZEOF(off_t, 64, [
 	#include <stdio.h>
 	#include <sys/types.h>
@@ -193,11 +198,8 @@ libraries.)
 fi
 AM_PROG_LIBTOOL
 
-dnl Initialize i18n:
-ALL_LINGUAS="ca cs da de es fr gl id it ja nl nn hu pl pt pt_BR ru sv tr uk vi zh_CN zh_TW"
-AM_GNU_GETTEXT_VERSION([0.12.1])
+AM_GNU_GETTEXT_VERSION([0.15])
 AM_GNU_GETTEXT([external])
-CFLAGS="$CFLAGS -DLOCALEDIR=\"\\\"$datadir/locale\\\"\""
 if test "$USE_INCLUDED_LIBINTL" = "yes"; then
 	AC_MSG_ERROR(
 GNU Parted requires gettext to be installed for compilation -
@@ -328,8 +330,6 @@ dnl Check for OS specific libraries
 
 dnl GNU/Hurd:
 if test "$OS" = gnu; then
-	CFLAGS="$CFLAGS -D_GNU_SOURCE=1"
-
 dnl libshouldbeinlibc
 	AC_CHECK_LIB(shouldbeinlibc, vm_deallocate,
 		OS_LIBS="$OS_LIBS -lshouldbeinlibc",
@@ -460,12 +460,9 @@ if test "$with_readline" = yes; then
 	LIBS="$OLD_LIBS"
 fi
 
-OLD_CFLAGS="$CFLAGS"
-CFLAGS=-D_GNU_SOURCE=1
 AC_CHECK_FUNCS(canonicalize_file_name)
-CFLAGS="$OLD_CFLAGS"
 
-CFLAGS="$CFLAGS -W -Wall -Wno-unused -Wno-switch -Wno-format"
+# CFLAGS="$CFLAGS -W -Wall -Wno-unused -Wno-switch -Wno-format"
 
 if test "$enable_Werror" = yes; then
 	CFLAGS="$CFLAGS -Werror"
@@ -479,6 +476,7 @@ AC_SUBST(BUILDINFO)
 
 AC_OUTPUT([
 Makefile
+lib/Makefile
 include/Makefile
 include/parted/Makefile
 libparted/Makefile
diff --git a/debug/clearfat/clearfat.c b/debug/clearfat/clearfat.c
index 896747d..e27c32d 100644
--- a/debug/clearfat/clearfat.c
+++ b/debug/clearfat/clearfat.c
@@ -40,7 +40,7 @@ static char buffer [CLEAR_BUFFER_SIZE];
 static int
 _do_help ()
 {
-	printf (help_msg);
+	fputs (help_msg, stdout);
 	exit (1);
 }
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..6635f70
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1 @@
+include gnulib.mk
diff --git a/libparted/Makefile.am b/libparted/Makefile.am
index ce912ba..4892c8d 100644
--- a/libparted/Makefile.am
+++ b/libparted/Makefile.am
@@ -1,5 +1,5 @@
 # This file is part of GNU Parted
-# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
 #
 # This file may be modified and/or distributed without restriction.
 
@@ -13,7 +13,7 @@ SUBDIRS       = labels fs . $(SUBDIRS_CHECK)
 
 LIBS = @INTLLIBS@ @LIBS@
 
-partedincludedir      =	-I$(top_srcdir)/include
+partedincludedir      = -I$(top_srcdir)/lib -I$(top_srcdir)/include
 lib_LTLIBRARIES	      =	libparted.la
 libparted_la_LDFLAGS  = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
 						-release $(LT_RELEASE)
diff --git a/libparted/cs/constraint.c b/libparted/cs/constraint.c
index b21e9af..6ba941a 100644
--- a/libparted/cs/constraint.c
+++ b/libparted/cs/constraint.c
@@ -44,6 +44,7 @@
  * @{
  */
 
+#include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 
diff --git a/libparted/cs/natmath.c b/libparted/cs/natmath.c
index a774d8f..f725cbb 100644
--- a/libparted/cs/natmath.c
+++ b/libparted/cs/natmath.c
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 2000 Free Software Foundation, Inc.
+    Copyright (C) 2000, 2007 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
@@ -31,6 +31,7 @@
  * @{
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
diff --git a/libparted/fs/amiga/amiga.c b/libparted/fs/amiga/amiga.c
index 8d06c88..9fa2025 100644
--- a/libparted/fs/amiga/amiga.c
+++ b/libparted/fs/amiga/amiga.c
@@ -19,6 +19,7 @@
     Contributor:  Sven Luther <luther at debian.org>
 */
 
+#include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 #include <parted/endian.h>
diff --git a/libparted/fs/fat/bootsector.c b/libparted/fs/fat/bootsector.c
index 53ff50b..c8826c8 100644
--- a/libparted/fs/fat/bootsector.c
+++ b/libparted/fs/fat/bootsector.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include "fat.h"
 
 #include <stdio.h>
diff --git a/libparted/fs/fat/calc.c b/libparted/fs/fat/calc.c
index 615ce0b..5f8a898 100644
--- a/libparted/fs/fat/calc.c
+++ b/libparted/fs/fat/calc.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include "fat.h" 
 
 #ifndef DISCOVER_ONLY
diff --git a/libparted/fs/fat/clstdup.c b/libparted/fs/fat/clstdup.c
index a964a57..a4795b3 100644
--- a/libparted/fs/fat/clstdup.c
+++ b/libparted/fs/fat/clstdup.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include <string.h>
 
 #include "fat.h"
diff --git a/libparted/fs/fat/context.c b/libparted/fs/fat/context.c
index 9cb3366..bf0df16 100644
--- a/libparted/fs/fat/context.c
+++ b/libparted/fs/fat/context.c
@@ -1,6 +1,6 @@
 /*
     libparted
-    Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+    Copyright (C) 1998, 1999, 2000, 2007 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
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include <string.h>
 
 #include "fat.h"
diff --git a/libparted/fs/fat/count.c b/libparted/fs/fat/count.c
index dba0edb..7390948 100644
--- a/libparted/fs/fat/count.c
+++ b/libparted/fs/fat/count.c
@@ -25,6 +25,7 @@
 
 */
 
+#include <config.h>
 #include "fat.h"
 #include "traverse.h"
 
diff --git a/libparted/fs/fat/fat.c b/libparted/fs/fat/fat.c
index b5d6d96..ebf023d 100644
--- a/libparted/fs/fat/fat.c
+++ b/libparted/fs/fat/fat.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include <string.h>
 #include <uuid/uuid.h>
 
diff --git a/libparted/fs/fat/fatio.c b/libparted/fs/fat/fatio.c
index e88f85d..98006dc 100644
--- a/libparted/fs/fat/fatio.c
+++ b/libparted/fs/fat/fatio.c
@@ -1,6 +1,6 @@
 /*
     libparted
-    Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+    Copyright (C) 1998, 1999, 2000, 2007 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
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include "fat.h"
 #include "fatio.h"
 
diff --git a/libparted/fs/fat/resize.c b/libparted/fs/fat/resize.c
index 0facf3f..1fb1c8c 100644
--- a/libparted/fs/fat/resize.c
+++ b/libparted/fs/fat/resize.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include "fat.h"
 #include "traverse.h"
 #include "count.h"
diff --git a/libparted/fs/fat/table.c b/libparted/fs/fat/table.c
index d67e42c..3db6127 100644
--- a/libparted/fs/fat/table.c
+++ b/libparted/fs/fat/table.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include <parted/endian.h>
 #include "fat.h"
 
diff --git a/libparted/fs/fat/traverse.c b/libparted/fs/fat/traverse.c
index aadb83d..da63964 100644
--- a/libparted/fs/fat/traverse.c
+++ b/libparted/fs/fat/traverse.c
@@ -25,6 +25,7 @@
 
 */
 
+#include <config.h>
 #include "fat.h"
 #include "traverse.h"
 
diff --git a/libparted/labels/dvh.c b/libparted/labels/dvh.c
index 4f6cd21..77122d3 100644
--- a/libparted/labels/dvh.c
+++ b/libparted/labels/dvh.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 #include <parted/endian.h>
diff --git a/libparted/labels/efi_crc32.c b/libparted/labels/efi_crc32.c
index a44f262..01cdff7 100644
--- a/libparted/labels/efi_crc32.c
+++ b/libparted/labels/efi_crc32.c
@@ -48,6 +48,7 @@
   /*                                                                        */
   /*  --------------------------------------------------------------------  */
 
+#include <config.h>
 #include <stdint.h>
 
 static uint32_t crc32_tab[] = {
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index acdd6a0..198bce2 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -16,6 +16,7 @@
  *           
  */
 
+#include <config.h>
 #include <parted/vtoc.h>
 #include <parted/fdasd.h>
 
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index ad25bbe..028f8b0 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -1,3 +1,4 @@
+#include <config.h>
 #include <parted/vtoc.h>
 
 #ifdef DEBUG_DASD
diff --git a/libparted/libparted.c b/libparted/libparted.c
index cec6172..e8bc886 100644
--- a/libparted/libparted.c
+++ b/libparted/libparted.c
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2000, 2001, 2007 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
@@ -18,6 +18,7 @@
 */
 
 #include "config.h"
+#include "configmake.h"
 
 #include <parted/parted.h>
 #include <parted/debug.h>
diff --git a/libparted/tests/common.c b/libparted/tests/common.c
index 9a4aeb5..af5b983 100644
--- a/libparted/tests/common.c
+++ b/libparted/tests/common.c
@@ -1,3 +1,4 @@
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -5,18 +6,22 @@
 
 #include "common.h"
 
-
-char *_create_disk(const off_t size)
+char *_create_disk (const off_t size)
 {
 		char filename[] = "parted-test-XXXXXX";
-		mktemp(filename);
+		mktemp (filename);
 
-		FILE *disk = fopen(filename, "w");
-		off_t total_size = size * 1024 * 1024; /* Mb */
+		FILE *disk = fopen (filename, "w");
+		if (disk == NULL)
+			/* FIXME: give a diagnostic? */
+			return NULL;
+		off_t total_size = size * 1024 * 1024;	/* Mb */
 
-		fseek(disk, total_size, SEEK_SET);
-		fwrite("", sizeof(char), sizeof(char), disk);
-		fclose(disk);
+		fseek (disk, total_size, SEEK_SET);
+		fwrite ("", sizeof (char), 1, disk);
+		if (fclose (disk) != 0)
+		      /* FIXME: give a diagnostic? */
+		      return NULL;
 
-		return strdup(filename);
+		return strdup (filename);
 }
diff --git a/libparted/tests/label.c b/libparted/tests/label.c
index 4b4fdb8..f12e4c8 100644
--- a/libparted/tests/label.c
+++ b/libparted/tests/label.c
@@ -1,3 +1,4 @@
+#include <config.h>
 #include <unistd.h>
 
 #include <check.h>
@@ -6,14 +7,16 @@
 
 #include "common.h"
 
-char *temporary_disk;
+static char *temporary_disk;
 
-void create_disk(void)
+static void create_disk(void)
 {
 		temporary_disk = _create_disk(20);
+		fail_if(temporary_disk == NULL,
+                        "Failed to create temporary disk");
 }
 
-void destroy_disk(void)
+static void destroy_disk(void)
 {
 		unlink(temporary_disk);
 		free(temporary_disk);
@@ -38,7 +41,7 @@ START_TEST (test_create_label)
 						 type->name);
 		}
 }
-END_TEST		
+END_TEST
 
 int main(void)
 {
@@ -55,6 +58,6 @@ int main(void)
 
 		number_failed = srunner_ntests_failed(srunner);
 		srunner_free(srunner);
-		
+
 		return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/libparted/timer.c b/libparted/timer.c
index ac403ba..e315273 100644
--- a/libparted/timer.c
+++ b/libparted/timer.c
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 2001 Free Software Foundation, Inc.
+    Copyright (C) 2001, 2007 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
@@ -43,6 +43,7 @@
  */
 
 
+#include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 
diff --git a/libparted/unit.c b/libparted/unit.c
index 13641a6..930276a 100644
--- a/libparted/unit.c
+++ b/libparted/unit.c
@@ -50,6 +50,7 @@
 
 
 
+#include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 
diff --git a/parted/Makefile.am b/parted/Makefile.am
index dacb5bc..b94e075 100644
--- a/parted/Makefile.am
+++ b/parted/Makefile.am
@@ -1,6 +1,6 @@
 sbin_PROGRAMS = parted
 
-partedincludedir      = -I$(top_srcdir)/include
+partedincludedir      = -I$(top_srcdir)/lib -I$(top_srcdir)/include
 
 parted_SOURCES = command.c	\
 		 command.h	\
@@ -15,8 +15,11 @@ parted_SOURCES = command.c	\
 #parted_CFLAGS = -DBUILDINFO='"\"'@BUILDINFO@'\""'
 parted_CFLAGS = -DBUILDINFO=
 
-parted_LDADD = @INTLLIBS@ @LIBS@ $(top_builddir)/libparted/libparted.la \
-	       @PARTED_LIBS@ 
+parted_LDADD = \
+  $(top_builddir)/lib/libparted.la \
+  $(top_builddir)/libparted/libparted.la \
+  $(INTLLIBS) $(LIBS) \
+  $(PARTED_LIBS)
 
 parted_LDFLAGS = @PARTEDLDFLAGS@
 
diff --git a/parted/command.c b/parted/command.c
index 2f78e5c..c3c897f 100644
--- a/parted/command.c
+++ b/parted/command.c
@@ -1,6 +1,6 @@
 /*
     parted - a frontend to libparted
-    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2000, 2007 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
@@ -17,6 +17,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
+#include <config.h>
 #include "command.h"
 #include "ui.h"
 
diff --git a/parted/parted.c b/parted/parted.c
index 4a55e27..03ae2d4 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -18,11 +18,21 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
-#include "../config.h"
+#include <config.h>
+
+#include "closeout.h"
+#include "configmake.h"
+#include "version-etc.h"
 #include "command.h"
 #include "ui.h"
 #include "table.h"
 
+#define AUTHORS \
+  "<http://parted.alioth.debian.org/cgi-bin/trac.cgi/browser/AUTHORS>"
+
+/* The official name of this program (e.g., no `g' prefix).  */
+#define PROGRAM_NAME "parted"
+
 #define N_(String) String
 #if ENABLE_NLS
 #  include <libintl.h>
@@ -82,6 +92,8 @@ static char*    options_help [][2] = {
         {NULL,          NULL}
 };
 
+char *program_name;
+
 int     opt_script_mode = 0;
 int     opt_machine_mode = 0;
 int     is_toggle_mode = 0;
@@ -2239,8 +2251,9 @@ textdomain(PACKAGE);
 void
 _version ()
 {
-printf (prog_name);
-exit (0);
+  version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, VERSION, AUTHORS,
+               (char *) NULL);
+  exit (EXIT_SUCCESS);
 }
 
 static int
@@ -2381,6 +2394,9 @@ main (int argc, char** argv)
         PedDevice*      dev;
         int             status;
 
+        program_name = argv[0];
+        atexit (close_stdout);
+
         dev = _init (&argc, &argv);
         if (!dev)
                 return 1;
diff --git a/parted/ui.c b/parted/ui.c
index 447fb56..d302e27 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -27,7 +27,7 @@
 #include <unistd.h>
 #include <setjmp.h>
 
-#include "../config.h"
+#include <config.h>
 #include "command.h"
 #include "strlist.h"
 #include "ui.h"
-- 
1.5.0.33.gaf997




More information about the parted-devel mailing list