--- /desktop/generic-build-script	2005-10-31 00:09:38.359375000 -0500
+++ gettext-0.14.5-1.sh	2005-11-15 03:38:42.000000000 -0500
@@ -43,6 +43,10 @@
 export SHORTPKG=${PKG}-${VER}
 export FULLPKG=${SHORTPKG}-${REL}
 
+PKG2=libintl3
+PKG3=gettext-devel
+PKG4=libgettextpo0
+
 # determine correct decompression option and tarball filename
 export src_orig_pkg_name=
 if [ -e "${src_orig_pkg_name}" ] ; then
@@ -70,20 +74,38 @@
 # determine correct names for generated files
 export src_pkg_name=${FULLPKG}-src.tar.bz2
 export src_patch_name=${FULLPKG}.patch
+export src_patch_name2=${FULLPKG}.patch2
 export bin_pkg_name=${FULLPKG}.tar.bz2
+export bin_pkg_name2=${PKG2}-${VER}-${REL}.tar.bz2
+export bin_pkg_name3=${PKG3}-${VER}-${REL}.tar.bz2
+export bin_pkg_name4=${PKG4}-${VER}-${REL}.tar.bz2
 
 export src_pkg=${topdir}/${src_pkg_name}
 export src_patch=${topdir}/${src_patch_name}
+export src_patch2=${topdir}/${src_patch_name2}
 export bin_pkg=${topdir}/${bin_pkg_name}
+export bin_pkg2=${topdir}/${bin_pkg_name2}
+export bin_pkg3=${topdir}/${bin_pkg_name3}
+export bin_pkg4=${topdir}/${bin_pkg_name4}
 export srcdir=${topdir}/${BASEPKG}
 export objdir=${srcdir}/.build
 export instdir=${srcdir}/.inst
 export srcinstdir=${srcdir}/.sinst
 export checkfile=${topdir}/${FULLPKG}.check
 
-prefix=/usr
-sysconfdir=/etc
-localstatedir=/var
+if [ -f ${objdir}/RELOC ] ; then
+  RELOCDIR=`cat ${objdir}/RELOC`
+else
+  # RELOCDIR=`mktemp -d /tmp/gettext-reloc-XXXXXX`
+  RELOCDIR=
+  echo -n ${RELOCDIR} > ${objdir}/RELOC
+fi
+
+prefix=${RELOCDIR}/usr
+sysconfdir=${RELOCDIR}/etc
+localstatedir=${RELOCDIR}/var
+pnoslash=`echo $prefix | sed -e "s#^${RELOCDIR}##" -e 's#^/##'`
+snoslash=`echo $sysconfdir | sed -e "s#^${RELOCDIR}##" -e 's#^/##'`
 if [ -z "$MY_CFLAGS" ]; then
   MY_CFLAGS="-O2"
 fi
@@ -91,6 +113,8 @@
   MY_LDFLAGS=
 fi
 
+alias_path="${RELOCDIR}/usr/share/locale:${RELOCDIR}/usr/local/share/locale:${RELOCDIR}/usr/X11R6/lib/X11/locale"
+
 export install_docs="\
 	ABOUT-NLS \
 	ANNOUNCE \
@@ -126,6 +150,80 @@
 # Sort in POSIX order.
 export LC_ALL=C
 
+PKG1_LIST="\
+  ${pnoslash}/share/doc/Cygwin/${PKG}-${VER}.README \
+  ${pnoslash}/share/doc/${PKG}-${VER}/* \
+  ${pnoslash}/share/gettext/ABOUT-NLS \
+  ${pnoslash}/bin/gettext.*exe \
+  ${pnoslash}/bin/ngettext.*exe \
+  ${pnoslash}/bin/envsubst.*exe \
+  ${pnoslash}/bin/gettext.sh \
+  ${pnoslash}/share/man/man1/gettext.* \
+  ${pnoslash}/share/man/man1/ngettext.* \
+  ${pnoslash}/share/man/man1/envsubst.* \
+  ${pnoslash}/share/doc/gettext/gettext.1.html \
+  ${pnoslash}/share/doc/gettext/ngettext.1.html \
+  ${pnoslash}/share/doc/gettext/envsubst.1.html \
+  ${pnoslash}/share/locale/*/LC_MESSAGES/gettext-runtime.mo \
+  ${pnoslash}/lib/libintl.* \
+  ${pnoslash}/lib/charset.alias \
+  ${pnoslash}/share/locale/locale.alias \
+  ${pnoslash}/include/libintl.h \
+  ${pnoslash}/share/man/man3/* \
+  ${pnoslash}/share/doc/gettext/*.3.html \
+  ${pnoslash}/share/doc/gettext/javadoc1/* \
+  ${pnoslash}/share/doc/gettext/javadoc2/* \
+  ${pnoslash}/share/doc/gettext/csharpdoc/* \
+  ${pnoslash}/lib/libasprintf.* \
+  ${pnoslash}/include/autosprintf.h \
+  ${pnoslash}/share/doc/libasprintf/autosprintf.html \
+  ${pnoslash}/share/info/autosprintf.info* \
+"
+PKG2_LIST="\
+  ${pnoslash}/bin/cygintl-*.dll \
+"
+PKG4_LIST="\
+  ${pnoslash}/bin/cyggettextpo-*.dll \
+  ${pnoslash}/bin/cyggettextlib-*.dll \
+  ${pnoslash}/bin/cyggettextsrc-*.dll \
+"
+PKG3_LIST="\
+  ${pnoslash}/share/doc/Cygwin/${PKG3}-${VER}.README \
+  ${pnoslash}/bin/msg*.*exe \
+  ${pnoslash}/bin/xgettext.*exe \
+  ${pnoslash}/bin/gettextize \
+  ${pnoslash}/bin/autopoint \
+  ${pnoslash}/share/man/man1/msg*.* \
+  ${pnoslash}/share/man/man1/xgettext.* \
+  ${pnoslash}/share/man/man1/gettextize.* \
+  ${pnoslash}/share/man/man1/autopoint.* \
+  ${pnoslash}/share/doc/gettext/msg*.1.html \
+  ${pnoslash}/share/doc/gettext/xgettext.1.html \
+  ${pnoslash}/share/doc/gettext/gettextize.1.html \
+  ${pnoslash}/share/doc/gettext/autopoint.1.html \
+  ${pnoslash}/share/doc/gettext/gettext_*.html \
+  ${pnoslash}/share/doc/gettext/tutorial.html \
+  ${pnoslash}/share/doc/gettext/FAQ.html \
+  ${pnoslash}/share/doc/gettext/examples/* \
+  ${pnoslash}/share/info/gettext.info* \
+  ${pnoslash}/include/gettext-po.h \
+  ${pnoslash}/lib/libgettextlib* \
+  ${pnoslash}/lib/libgettextsrc* \
+  ${pnoslash}/lib/libgettextpo* \
+  ${pnoslash}/lib/gettext/* \
+  ${pnoslash}/share/locale/*/LC_MESSAGES/gettext-tools.mo \
+  ${pnoslash}/share/gettext/config.rpath \
+  ${pnoslash}/share/gettext/mkinstalldirs \
+  ${pnoslash}/share/gettext/intl/* \
+  ${pnoslash}/share/gettext/po/* \
+  ${pnoslash}/share/gettext/projects/* \
+  ${pnoslash}/share/gettext/gettext.h \
+  ${pnoslash}/share/gettext/msgunfmt.tcl \
+  ${pnoslash}/share/gettext/archive.tar.gz \
+  ${pnoslash}/share/aclocal/* \
+  ${pnoslash}/share/emacs/site-lisp/* \
+"
+
 # helper functions
 
 # Provide help.
@@ -142,6 +240,9 @@
     reconf		Rerun configure
     build, make		Build the package (make)
     check, test		Run the testsuite (make ${test_rule})
+    check-rpath         Run the rpath subset of make check
+    check-runtime       Run the runtime subset of make check
+    check-tools         Run the tools subset of make check
     clean		Remove built files (make clean)
     install		Install package to staging area (make install)
     list		List package contents
@@ -179,17 +280,35 @@
   mkdir -p ${instdir} && \
   mkdir -p ${srcinstdir} )
 }
+patchit() {
+  thedir=$1
+  (cd ${thedir} && \
+  if [ -f ${src_patch} ] ; then \
+    patch -Z -p1 < ${src_patch} ;\
+  fi )
+}
+fixup() {
+  thedir=$1
+  (cd ${thedir} && \
+  ./autogen.sh )
+}  
 prep() {
   (cd ${topdir} && \
   unpack ${src_orig_pkg} && \
   cd ${topdir} && \
-  if [ -f ${src_patch} ] ; then \
-    patch -Z -p0 < ${src_patch} ;\
-  fi && \
-  mkdirs )
+  patchit ${srcdir}
+  fixup ${srcdir}
+  if [ -f ${src_patch2} ] ; then \
+    patch -Z -p0 < ${src_patch2} ;\
+  fi
+  mkdirs && \
+  cd ${srcdir} && \
+  chmod +x gettext-tools/misc/gettextize.in && \
+  chmod +x gettext-tools/misc/autopoint.in )
 }
 conf() {
   (cd ${objdir} && \
+  export PATH=/usr/X11R6/bin:/usr/bin:/bin
   CFLAGS="${MY_CFLAGS}" LDFLAGS="${MY_LDFLAGS}" \
   ${srcdir}/configure \
   --srcdir=${srcdir} --prefix="${prefix}" \
@@ -197,7 +316,10 @@
   --libdir='${prefix}/lib' --includedir='${prefix}/include' \
   --mandir='${prefix}/share/man' --infodir='${prefix}/share/info' \
   --libexecdir='${sbindir}' --localstatedir="${localstatedir}" \
-  --datadir='${prefix}/share' )
+  --datadir='${prefix}/share' \
+  --with-included-gettext --disable-rpath && \
+  chmod +x gettext-tools/misc/gettextize && \
+  chmod +x gettext-tools/misc/autopoint )
 }
 reconf() {
   (cd ${topdir} && \
@@ -207,11 +329,27 @@
 }
 build() {
   (cd ${objdir} && \
-  make CFLAGS="${MY_CFLAGS}" )
+  make CFLAGS="${MY_CFLAGS}" aliaspath=${alias_path} EMACS=no )
 }
+check_rpath() {
+  (cd ${objdir}/autoconf-lib-link && \
+  CFLAGS="${MY_CFLAGS}" LDFLAGS="${MY_LDFLAGS}" \
+  make aliaspath=${alias_path} EMACS=no check | tee ${checkfile}-rpath 2>&1
+)}
+check_runtime() {
+  (cd ${objdir}/gettext-runtime && \
+  CFLAGS="${MY_CFLAGS}" LDFLAGS="${MY_LDFLAGS}" \
+  make aliaspath=${alias_path} EMACS=no check | tee ${checkfile}-runtime 2>&1
+)}
+check_tools() {
+  (cd ${objdir}/gettext-tools && \
+  CFLAGS="${MY_CFLAGS}" LDFLAGS="${MY_LDFLAGS}" \
+  make aliaspath=${alias_path} EMACS=no check | tee ${checkfile}-tools 2>&1
+)}
 check() {
-  (cd ${objdir} && \
-  make ${test_rule} | tee ${checkfile} 2>&1 )
+  check_rpath
+  check_runtime
+  check_tools
 }
 clean() {
   (cd ${objdir} && \
@@ -220,17 +358,21 @@
 install() {
   (cd ${objdir} && \
   rm -fr ${instdir}/* && \
-  make install DESTDIR=${instdir} && \
+  make install DESTDIR=${instdir} alias_path=${alias_path} EMACS=no && \
+  (cd ${instdir}${prefix}/bin ; chmod +x *.dll ) && \
   for f in ${prefix}/share/info/dir ${prefix}/info/dir ; do \
     if [ -f ${instdir}${f} ] ; then \
       rm -f ${instdir}${f} ; \
     fi ;\
   done &&\
-  for d in ${prefix}/share/doc/${SHORTPKG} ${prefix}/share/doc/Cygwin ; do \
+  for d in ${prefix}/share/doc/${SHORTPKG} ${prefix}/share/doc/Cygwin \
+           ${prefix}/share/emacs/site-lisp ; do \
     if [ ! -d ${instdir}${d} ] ; then \
       mkdir -p ${instdir}${d} ;\
     fi ;\
   done &&\
+  /usr/bin/install -m 644 ${srcdir}/gettext-tools/misc/*.el \
+     ${instdir}${prefix}/share/emacs/site-lisp/ && \
   if [ -d ${instdir}${prefix}/share/info ] ; then \
     find ${instdir}${prefix}/share/info -name "*.info" | xargs -r gzip -q ; \
   fi && \
@@ -254,6 +396,12 @@
     /usr/bin/install -m 644 $templist \
 	 ${instdir}${prefix}/share/doc/${SHORTPKG} ; \
   fi && \
+  cat ${srcdir}/CYGWIN-PATCHES/${PKG}.frag \
+    ${srcdir}/CYGWIN-PATCHES/README.frag > \
+         ${instdir}${prefix}/share/doc/Cygwin/${PKG}-${VER}.README && \
+  cat ${srcdir}/CYGWIN-PATCHES/${PKG3}.frag \
+    ${srcdir}/CYGWIN-PATCHES/README.frag > \
+         ${instdir}${prefix}/share/doc/Cygwin/${PKG3}-${VER}.README && \
   if [ -f ${srcdir}/CYGWIN-PATCHES/${PKG}.README ]; then \
     /usr/bin/install -m 644 ${srcdir}/CYGWIN-PATCHES/${PKG}.README \
       ${instdir}${prefix}/share/doc/Cygwin/${SHORTPKG}.README ; \
@@ -290,6 +438,8 @@
   fi )
 }
 strip() {
+  # maybe: only strip cygintl.  The other dlls are fragile.
+  #   find . -name "cygintl*.dll" | xargs strip > /dev/null 2>&1
   (cd ${instdir} && \
   find . -name "*.dll" -or -name "*.exe" | xargs -r strip 2>&1 ; \
   true )
@@ -307,18 +457,26 @@
   true )
 }
 pkg() {
-  (cd ${instdir} && \
-  tar cvjf ${bin_pkg} * )
+  (cd ${instdir}${RELOCDIR} && \
+  tar cvjf ${bin_pkg} ${PKG1_LIST}   && \
+  tar cvjf ${bin_pkg2} ${PKG2_LIST}  && \
+  tar cvjf ${bin_pkg3} ${PKG3_LIST}  && \
+  tar cvjf ${bin_pkg4} ${PKG4_LIST}  )
 }
 mkpatch() {
   (cd ${srcdir} && \
   find . -name "autom4te.cache" | xargs -r rm -rf ; \
   unpack ${src_orig_pkg} && \
   mv ${BASEPKG} ../${BASEPKG}-orig && \
+  temp=`(cd ../${PKG}-${VER}-orig ; pwd)` && \
+  patchit $temp
+  fixup $temp
+  cd $temp
+  find . -name "autom4te.cache" | xargs -r rm -rf ; \
   cd ${topdir} && \
-  diff -urN -x '.build' -x '.inst' -x '.sinst' \
+  diff -urN -x '.build' -x '.inst' -x '.sinst' -x '*~' \
     ${BASEPKG}-orig ${BASEPKG} > \
-    ${srcinstdir}/${src_patch_name} ; \
+    ${srcinstdir}/${src_patch_name2} ; \
   rm -rf ${BASEPKG}-orig )
 }
 # Note: maintainer-only functionality
@@ -327,9 +485,13 @@
 }
 spkg() {
   (mkpatch && \
+  cp ${src_patch} ${srcinstdir}
   if [ "${SIG}" -eq 1 ] ; then \
     name=${srcinstdir}/${src_patch_name} text="PATCH" sigfile ; \
   fi && \
+  if [ -e ${srcinstdir}/${src_patch_name2} -a "${SIG}" -eq 1 ] ; then \
+    name=${srcinstdir}/${src_patch_name2} text="PATCH2" sigfile ; \
+  fi && \
   cp ${src_orig_pkg} ${srcinstdir}/${src_orig_pkg_name} && \
   if [ -e ${src_orig_pkg}.sig ] ; then \
     cp ${src_orig_pkg}.sig ${srcinstdir}/ ; \
@@ -376,6 +538,12 @@
     else \
       echo "PATCH signature missing."; \
     fi; \
+    if [ -e ${src_patch2}.sig ]; then \
+      echo "PATCH2 signature follows:"; \
+      /usr/bin/gpg --verify ${src_patch2}.sig ${src_patch2}; \
+    else \
+      echo "PATCH2 signature missing."; \
+    fi; \
   else
     echo "You need the gnupg package installed in order to check signatures." ; \
   fi
@@ -392,6 +560,9 @@
     build)		build ; STATUS=$? ;;
     make)		build ; STATUS=$? ;;
     check)		check ; STATUS=$? ;;
+    check-rpath)        check_rpath ; STATUS=$? ;;
+    check-runtime)      check_runtime ; STATUS=$? ;;
+    check-tools)        check_tools ; STATUS=$? ;;
     test)		check ; STATUS=$? ;;
     clean)		clean ; STATUS=$? ;;
     install)		install ; STATUS=$? ;;
