# packages/pcre/auxbuild
#

# download and unpack tarball
TARVERSION="7.6"
TARDIR="${BUILD_PACKAGE}-${TARVERSION}"
TARBALL="${TARDIR}.tar.bz2"
build_download "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${TARBALL}"
build_unpack "${TARBALL}"

export CC_FOR_BUILD="gcc"

# invoke configure (directory, prefix, extra arguments)
build_autoconf "${TARDIR}" "" "--disable-cpp --disable-static"

# fix libtool to never use rpath, and to not do -L /usr/lib or -L /usr/lib
sed -e 's/^hardcode_libdir_flag_spec=.*$/hardcode_libdir_flag_spec="-L \$libdir"/' -i "Distn/${TARDIR}/libtool" 
patch -p0 -d "Distn/${TARDIR}" << EOF
--- libtool.old	2008-02-09 16:27:25.000000000 +0000
+++ libtool	2008-02-09 16:27:58.000000000 +0000
@@ -4560,6 +4560,7 @@
 	for cmd in \$cmds; do
 	  IFS="\$save_ifs"
 	  eval cmd=\"\$cmd\"
+	  cmd="\$(echo "\$cmd" | sed -e 's,-L *\/lib,,g' -e 's,-L *\/usr\/lib,,g')"
 	  \$show "\$cmd"
 	  \$run eval "\$cmd" || {
 	    lt_exit=\$?
EOF

# run make, make install (directory, extra arguments)
build_make "${TARDIR}"
build_make "${TARDIR}" "install"

true
# vim: ts=4:sw=4:expandtab:syntax=sh
