Index: src/Makefile.def
===================================================================
--- src/Makefile.def	(revision 237184)
+++ src/Makefile.def	(working copy)
@@ -25,6 +25,7 @@
 // that recursive target in its Makefile.
 
 build_modules= { module= libiberty; };
+build_modules= { module= gnulib; };
 build_modules= { module= bison; };
 build_modules= { module= flex; };
 build_modules= { module= m4; };
@@ -112,6 +113,8 @@
 host_modules= { module= zlib; no_install=true; no_check=true;
 		bootstrap=true;
 	        extra_configure_flags='@extra_host_zlib_configure_flags@';};
+host_modules= { module= gnulib;
+              bootstrap=true; };
 host_modules= { module= gdb; };
 host_modules= { module= expect; };
 host_modules= { module= guile; };
@@ -342,6 +345,8 @@
 dependencies = { module=all-gcc; on=all-build-fixincludes; };
 dependencies = { module=all-gcc; on=all-build-libcpp; };
 dependencies = { module=all-gcc; on=all-zlib; };
+dependencies=  { module=all-gcc; on=all-gnulib; hard=true; };
+dependencies = { module=all-gcc; on=all-build-gnulib; };
 dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
Index: src/configure.ac
===================================================================
--- src/configure.ac	(revision 237184)
+++ src/configure.ac	(working copy)
@@ -125,7 +125,7 @@
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty build-libcpp"
+build_libs="build-libiberty build-libcpp build-gnulib"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
@@ -132,7 +132,7 @@
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv gnulib"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
Index: src/gcc/Makefile.in
===================================================================
--- src/gcc/Makefile.in	(revision 237184)
+++ src/gcc/Makefile.in	(working copy)
@@ -484,12 +484,14 @@
 
 # Where to find some libiberty headers.
 HASHTAB_H   = $(srcdir)/../include/hashtab.h
-OBSTACK_H   = $(srcdir)/../include/obstack.h
 SPLAY_TREE_H= $(srcdir)/../include/splay-tree.h
 MD5_H	    = $(srcdir)/../include/md5.h
 XREGEX_H    = $(srcdir)/../include/xregex.h
 FNMATCH_H   = $(srcdir)/../include/fnmatch.h
 
+# GNULIB headers
+OBSTACK_H   = $(srcdir)/../gnulib/import/obstack.h
+
 # Linker plugin API headers
 LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 
@@ -1022,18 +1024,23 @@
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
 
+# Where to find the gnulib library
+LIBGNU = ../gnulib/import/libgnu.a
+BUILD_LIBGNU= $(build_libobjdir)/gnulib/import/libgnu.a
+INCGNU = -I$(srcdir)/../gnulib/import
+
 # Dependencies on the intl and portability libraries.
-LIBDEPS= libcommon.a $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
+LIBDEPS= libcommon.a $(CPPLIB) $(LIBGNU) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
 	$(LIBDECNUMBER) $(LIBBACKTRACE)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
+BUILD_LIBDEPS= $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
 LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
-	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
+	$(LIBGNU) $(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
 BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 	$(ZLIB)
 # Any system libraries needed just for GNAT.
@@ -1048,7 +1055,7 @@
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBS = $(BUILD_LIBIBERTY)
+BUILD_LIBS = $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
 	    build/vec.o build/min-insn-modes.o build/gensupport.o \
@@ -1066,7 +1073,7 @@
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
-	   $(ISLINC)
+	   $(ISLINC) $(INCGNU)
 
 COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
 ifeq ($(CXXDEPMODE),depmode=gcc3)
Index: src/gcc/mkconfig.sh
===================================================================
--- src/gcc/mkconfig.sh	(revision 237184)
+++ src/gcc/mkconfig.sh	(working copy)
@@ -43,6 +43,7 @@
 # A special test to ensure that build-time files don't blindly use
 # config.h.
 if test x"$output" = x"config.h"; then
+  echo '#include "../gnulib/config.h"' >> ${output}T
   echo "#ifdef GENERATOR_FILE" >> ${output}T
   echo "#error config.h is for the host, not build, machine." >> ${output}T
   echo "#endif" >> ${output}T
Index: src/gnulib/Makefile.in
===================================================================
--- src/gnulib/Makefile.in	(nonexistent)
+++ src/gnulib/Makefile.in	(working copy)
@@ -0,0 +1,290 @@
+# Copyright (C) 1989-2016 Free Software Foundation, Inc.
+
+# This file is part of GCC.
+
+# 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datadir = @datadir@
+localedir = @localedir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+htmldir = @htmldir@
+pdfdir = @pdfdir@
+includedir = @includedir@
+
+SHELL = @SHELL@
+EXEEXT = @EXEEXT@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+DESTDIR =
+
+AR = @AR@
+AR_FLAGS = qv
+RANLIB = @RANLIB@
+DLLTOOL = @DLLTOOL@
+
+SUBDIRS = import
+CLEANDIRS = $(SUBDIRS)
+REQUIRED_SUBDIRS = $(SUBDIRS)
+
+# If you are compiling with GCC, make sure that either 1) You have the
+# fixed include files where GCC can reach them, or 2) You use the
+# -traditional flag.  Otherwise the ioctl calls in inflow.c
+# will be incorrectly compiled.  The "fixincludes" script in the gcc
+# distribution will fix your include files up.
+CC=@CC@
+
+# Directory containing source files.
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC_LD=$(CC)
+
+# CFLAGS is specifically reserved for setting from the command line
+# when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
+# LDFLAGS is specifically reserved for setting from the command line
+# when running make.
+LDFLAGS = @LDFLAGS@
+
+FLAGS_TO_PASS = \
+	"prefix=$(prefix)" \
+	"exec_prefix=$(exec_prefix)" \
+	"infodir=$(infodir)" \
+	"datarootdir=$(datarootdir)" \
+	"docdir=$(docdir)" \
+	"htmldir=$(htmldir)" \
+	"pdfdir=$(pdfdir)" \
+	"libdir=$(libdir)" \
+	"mandir=$(mandir)" \
+	"datadir=$(datadir)" \
+	"includedir=$(includedir)" \
+	"against=$(against)" \
+	"DESTDIR=$(DESTDIR)" \
+	"AR=$(AR)" \
+	"AR_FLAGS=$(AR_FLAGS)" \
+	"CC=$(CC)" \
+	"CFLAGS=$(CFLAGS)" \
+	"CXX=$(CXX)" \
+	"CXXFLAGS=$(CXXFLAGS)" \
+	"DLLTOOL=$(DLLTOOL)" \
+	"LDFLAGS=$(LDFLAGS)" \
+	"RANLIB=$(RANLIB)" \
+	"MAKEINFO=$(MAKEINFO)" \
+	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
+	"MAKEINFO_EXTRA_FLAGS=$(MAKEINFO_EXTRA_FLAGS)" \
+	"MAKEHTML=$(MAKEHTML)" \
+	"MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \
+	"INSTALL=$(INSTALL)" \
+	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+	"INSTALL_DATA=$(INSTALL_DATA)" \
+	"RUNTEST=$(RUNTEST)" \
+	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
+
+all installcheck check info install-info clean-info dvi pdf install-pdf html install-html: force
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+
+# Traditionally "install" depends on "all".  But it may be useful
+# not to; for example, if the user has made some trivial change to a
+# source file and doesn't care about rebuilding or just wants to save the
+# time it takes for make to check that all is up to date.
+# install-only is intended to address that need.
+install: all
+	@$(MAKE) $(FLAGS_TO_PASS) install-only
+
+install-only: $(CONFIG_INSTALL)
+	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+uninstall: force $(CONFIG_UNINSTALL)
+	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+# Convenience rule to handle recursion.
+$(LIBGNU) $(GNULIB_H): all-lib
+all-lib: import/Makefile
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=import subdir_do
+.PHONY: all-lib
+
+clean mostlyclean: $(CONFIG_CLEAN)
+	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
+
+distclean: clean
+	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
+	rm -f config.status config.h stamp-h
+	rm -f config.log config.cache
+	rm -f Makefile
+	rm -rf $(DEPDIR)
+
+maintainer-clean: local-maintainer-clean do-maintainer-clean distclean
+realclean: maintainer-clean
+
+local-maintainer-clean:
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+	rm -f config.status
+
+do-maintainer-clean:
+	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \
+		subdir_do
+
+subdir_do: force
+	@for i in $(DODIRS); do \
+		case $$i in \
+		$(REQUIRED_SUBDIRS)) \
+			if [ ! -f ./$$i/Makefile ] ; then \
+				echo "Missing $$i/Makefile" >&2 ; \
+				exit 1 ; \
+			fi ;; \
+		esac ; \
+		if [ -f ./$$i/Makefile ] ; then \
+			if (cd ./$$i; \
+				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
+			else exit 1 ; fi ; \
+		else true ; fi ; \
+	done
+
+Makefile: Makefile.in config.status
+	# Regenerate the Makefile.
+	CONFIG_FILES="Makefile" \
+	  CONFIG_COMMANDS= \
+	  CONFIG_HEADERS= \
+	  $(SHELL) config.status
+
+gnulib/Makefile: gnulib/Makefile.in config.status
+	CONFIG_FILES="gnulib/Makefile" \
+	  CONFIG_COMMANDS="depfiles" \
+	  CONFIG_HEADERS= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.h: stamp-h ; @true
+stamp-h: $(srcdir)/config.in config.status
+	CONFIG_HEADERS=config.h:config.in \
+	  CONFIG_COMMANDS="default depdir" \
+	  CONFIG_FILES= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.status: $(srcdir)/configure
+	$(SHELL) config.status --recheck
+
+ACLOCAL = aclocal
+ACLOCAL_AMFLAGS = -I import/m4 -I ../../config
+aclocal_m4_deps = \
+	configure.ac \
+	import/m4/00gnulib.m4 \
+	import/m4/alloca.m4 \
+	import/m4/codeset.m4 \
+	import/m4/configmake.m4 \
+	import/m4/extensions.m4 \
+	import/m4/fcntl-o.m4 \
+	import/m4/fnmatch.m4 \
+	import/m4/glibc21.m4 \
+	import/m4/gnulib-cache.m4 \
+	import/m4/gnulib-common.m4 \
+	import/m4/gnulib-comp.m4 \
+	import/m4/gnulib-tool.m4 \
+	import/m4/include_next.m4 \
+	import/m4/inttypes-pri.m4 \
+	import/m4/inttypes.m4 \
+	import/m4/localcharset.m4 \
+	import/m4/locale-fr.m4 \
+	import/m4/locale-ja.m4 \
+	import/m4/locale-zh.m4 \
+	import/m4/longlong.m4 \
+	import/m4/mbrtowc.m4 \
+	import/m4/mbsinit.m4 \
+	import/m4/mbsrtowcs.m4 \
+	import/m4/mbstate_t.m4 \
+	import/m4/memchr.m4 \
+	import/m4/memmem.m4 \
+	import/m4/mmap-anon.m4 \
+	import/m4/multiarch.m4 \
+	import/m4/off_t.m4 \
+	import/m4/pathmax.m4 \
+	import/m4/ssize_t.m4 \
+	import/m4/stdbool.m4 \
+	import/m4/stddef_h.m4 \
+	import/m4/stdint.m4 \
+	import/m4/obstack.m4 \
+	import/m4/strtok_r.m4 \
+	import/m4/sys_types_h.m4 \
+	import/m4/unistd_h.m4 \
+	import/m4/warn-on-use.m4 \
+	import/m4/wchar_h.m4 \
+	import/m4/wchar_t.m4 \
+	import/m4/wctype_h.m4 \
+	import/m4/wint_t.m4
+
+$(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+AUTOCONF = autoconf
+configure_deps = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+
+AUTOHEADER = autoheader
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOHEADER)
+	rm -f stamp-h
+	touch $@
+
+# automatic rebuilding in automake-generated Makefiles requires
+# this rule in the toplevel Makefile, which, with GNU make, causes
+# the desired updates through the implicit regeneration of the Makefile
+# and all of its prerequisites.
+am--refresh:
+	@:
+
+force:
+
+force_update:
+
+# GNU Make has an annoying habit of putting *all* the Makefile variables
+# into the environment, unless you include this target as a circumvention.
+# Rumor is that this will be fixed (and this target can be removed)
+# in GNU Make 4.0.
+.NOEXPORT:
+
+# GNU Make 3.63 has a different problem: it keeps tacking command line
+# overrides onto the definition of $(MAKE).  This variable setting
+# will remove them.
+MAKEOVERRIDES=
+
+### end of the libgnu Makefile.in.
Index: src/gnulib/configure.ac
===================================================================
--- src/gnulib/configure.ac	(nonexistent)
+++ src/gnulib/configure.ac	(working copy)
@@ -0,0 +1,60 @@
+dnl Autoconf configure script for GCC.
+dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.64)dnl
+AC_INIT()
+AC_CONFIG_HEADER(config.h:config.in)
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
+gl_EARLY
+AM_PROG_CC_STDC
+
+AC_CONFIG_AUX_DIR(..)
+AC_CANONICAL_SYSTEM
+
+gl_INIT
+
+# Gnulib uses automake.  This line lets gcc generate
+# its Makefile.in.
+AM_INIT_AUTOMAKE(libgnu, UNUSED-VERSION, [no-define])
+
+# --------------------- #
+# Checks for programs.  #
+# --------------------- #
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+
+AC_CHECK_TOOL(AR, ar)
+
+# ---------------------- #
+# Checks for libraries.  #
+# ---------------------- #
+
+AC_OUTPUT(Makefile import/Makefile,
+[
+case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
+])
+
+exit 0
Index: src/gnulib/update-gnulib.sh
===================================================================
--- src/gnulib/update-gnulib.sh	(nonexistent)
+++ src/gnulib/update-gnulib.sh	(working copy)
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Copyright (C) 2011-2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
+
+# Usage: update-gnulib.sh <path-to-gnulib-repository>
+# Update our import of gnulib in the GCC source tree.
+#
+# This script assumes that it is being called from the gcc/gnulib
+# subdirectory.
+#
+# This script will also make a number of other verifications:
+#   . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
+#   . The correct versions of the auto-tools that are used to
+#     regenerate the various scripts and Makefiles are on the PATH.
+
+# The list of gnulib modules we are importing in GCC.
+IMPORTED_GNULIB_MODULES="\
+    obstack \
+"
+
+# The gnulib commit ID to use for the update.
+GNULIB_COMMIT_SHA1="1029a8112290f6eee9d7878a391c49db42c999bd"
+
+# The expected version number for the various auto tools we will
+# use after the import.
+AUTOCONF_VERSION="2.69"
+AUTOMAKE_VERSION="1.15"
+ACLOCAL_VERSION="$AUTOMAKE_VERSION"
+
+if [ $# -ne 1 ]; then
+   echo "Error: Path to gnulib repository missing. Aborting."
+   echo "Usage: update-gnulib.sh <path-to-gnulib-repository>"
+   exit 1
+fi
+gnulib_prefix=$1
+
+gnulib_tool="$gnulib_prefix/gnulib-tool"
+
+# Verify that the gnulib directory does exist...
+if [ ! -f "$gnulib_tool" ]; then
+   echo "Error: Invalid gnulib directory. Cannot find gnulib tool"
+   echo "       ($gnulib_tool)."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the right version of gnulib...
+gnulib_head_sha1=`cd $gnulib_prefix && git rev-parse HEAD`
+if [ "$gnulib_head_sha1" != "$GNULIB_COMMIT_SHA1" ]; then
+   echo "Error: Wrong version of gnulib: $gnulib_head_sha1"
+   echo "       (we expected it to be $GNULIB_COMMIT_SHA1)"
+   echo "Aborting."
+   exit 1
+fi
+
+ver=`autoconf --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOCONF_VERSION" ]; then
+   echo "Error: Wrong autoconf version: $ver. Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of automake.
+ver=`automake --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
+   echo "Error: Wrong automake version ($ver), we need $AUTOMAKE_VERSION."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of aclocal.
+#
+# The grep below is needed because Perl >= 5.16 dumps a "called too
+# early to check prototype" warning when running aclocal 1.11.1.  This
+# causes trouble below, because the warning is the first line output
+# by aclocal, resulting in:
+#
+# $ sh ./update-gnulib.sh ~/src/gnulib/src/
+# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
+#
+# Some distros carry an automake patch for that:
+#  https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
+#
+# But since we prefer pristine FSF versions of autotools, work around
+# the issue here.  This can be removed later when we bump the required
+# automake version.
+#
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$ACLOCAL_VERSION" ]; then
+   echo "Error: Wrong aclocal version: $ver. Aborting."
+   exit 1
+fi
+
+# Update our gnulib import.
+$gnulib_prefix/gnulib-tool --import --dir=. --lib=libgnu \
+  --source-base=import --m4-base=import/m4 --doc-base=doc \
+  --tests-base=tests --aux-dir=import/extra \
+  --no-conditional-dependencies --no-libtool --macro-prefix=gl \
+  --no-vc-files \
+  $IMPORTED_GNULIB_MODULES
+if [ $? -ne 0 ]; then
+   echo "Error: gnulib import failed.  Aborting."
+   exit 1
+fi
+
+# Regenerate all necessary files...
+aclocal -Iimport/m4 &&
+autoconf &&
+autoheader &&
+automake
+if [ $? -ne 0 ]; then
+   echo "Error: Failed to regenerate Makefiles and configure scripts."
+   exit 1
+fi
+

Property changes on: src/gnulib/update-gnulib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/gcc/doc/sourcebuild.texi
===================================================================
--- src/gcc/doc/sourcebuild.texi	(revision 237184)
+++ src/gcc/doc/sourcebuild.texi	(working copy)
@@ -97,6 +97,22 @@
 Introduction, libiberty, @sc{gnu} libiberty}, for more information
 about this library.
 
+@item libgnu
+Gnulib - The GNU portability library
+To facilitate the update/import of gnulib, a script called update-gnulib.sh (resides inside path/to/gcc-src/gcc/gnulib) has been created to automate the process.
+Usage: update-gnulib.sh <path-to-gnulib-repository>
+
+The script maintains the two key pieces of information from which the import is created as constants defined inside the script:
+@itemize @bullet
+@item
+GNULIB_COMMIT_SHA1 - which commit from the gnulib respository is to be used for the import; So in order to update gnulib, replace this value with that of the newer version and run the script.
+
+@item
+IMPORTED_GNULIB_MODULES - which modules to import from gnulib. Add a new module to this list in order to import it to gcc and run the script. 
+
+@end itemize
+When updating the import, please only modify one element at a time. For instance, if you want to import a new module only defined in a later version of gnulib, please first update the import to use the newer commit as a first patch, and then update the import to include the new module as a second patch.
+
 @item libitm
 The runtime support library for transactional memory.
 
