+ cd ${TOP_SRCDIR}/gnulib/build
+ ./configure --host="mingw32" LIBS="-lws2_32 -lpthread"
+ make
+ cd gllib
+
+ # We have to rebuild libgnu.a to get the list of *.o files to build a dll later
+ rm libgnu.a
+ OBJECT_LIST=`make V=1 | grep "ar" | cut -d' ' -f4-`
+ $CC -shared -o libgnu.dll $OBJECT_LIST -lws2_32 -lpthread
+ rm libgnu.a # get rid of it, to use libgnu.dll
+ fi
+ cd "${TOP_SRCDIR}"
+
+ set -x
+ autoreconf --install
+
+ export LDFLAGS="-L${GNULIB_DIR}"
+ export LIBS="-lgnu"
+ export CFLAGS="-Drestrict=__restrict -I${GNULIB_DIR}"
+
+ ./configure \
+ --prefix="${INSTALL_DIR}" \
+ --libdir="${LIBDIR}" \
+ --bindir="${BINDIR}" \
+ --sbindir="${SBINDIR}" \
+ --sysconfdir="${SYSCONFDIR}" \
+ --localstatedir="${LOCALSTATEDIR}" \
+ --datarootdir="${DATAROOTDIR}" \
+ --datarootdir="${DATADIR}" \
+ --disable-all-plugins \
+ --host="mingw32" \
+ --enable-logfile \
+ --enable-match_regex \
+ --enable-target_replace \
+ --enable-target_set
+
+ cp ${GNULIB_DIR}/../config.h src/gnulib_config.h
+ echo "#include <config.h.in>" >> src/gnulib_config.h
+
+ cp libtool libtool_bak
+ sed -i "s%\$LTCC \$LTCFLAGS\(.*cwrapper.*\)%\$LTCC \1%" libtool
+
+ make
+ make install
+
+ cp "${GNULIB_DIR}/libgnu.dll" "${INSTALL_DIR}"
+ cp "${MINGW_ROOT}/bin/zlib1.dll" "${INSTALL_DIR}"
+ cp "${MINGW_ROOT}/bin/libwinpthread-1.dll" "${INSTALL_DIR}"
+ cp "${MINGW_ROOT}/bin/libdl.dll" "${INSTALL_DIR}"
+
+ echo "Done."
+}
+
+os_name="$(uname)"
+if test "${os_name#CYGWIN}" != "$os_name"; then
+ build_cygwin
+else
+ build
+fi