tce-load -w -i curl compiletc autoconf autoget autogen coreutils squashfs-tools
cd /tmp
mkdir package
mkdir src_package
DESTDIR='/tmp/package'
curl -O https://www.privoxy.org/sf-download-mirror/Sources/3.0.26%20%28stable%29/privoxy-3.0.26-stable-src.tar.gz
tar xzvf privoxy-3.0.26-stable-src.tar.gz -C ./src_package
cd ./src_package/privoxy-3.0.26-stable/
export CFLAGS="-mtune=generic -Os -pipe"
export CXXFLAGS="-mtune=generic -Os -pipe"
export LDFLAGS="-Wl,-O1"
autoheader
autoconf
./configure --prefix=/usr/local
make
make DESTDIR=/tmp/package install-strip

# Create package directory
. /etc/init.d/tc-functions
PKGDIR=/tmp/`getMajorVer`.x/`getBuild`
mkdir -p $PKGDIR/tar.gz $PKGDIR/tcz

# Create privoxy-doc.tcz package
cd $DESTDIR
rm -fr var
mkdir doc
for i in usr/local/share/man usr/local/share/doc; do
  tar cpf - $i | (cd doc && tar xvpf - )
  rm -rf $i
done
rm -fr usr/local/share
cd doc
tar -czf $PKGDIR/tar.gz/privoxy-doc.tcz.tar.gz *
mksquashfs $DESTDIR/doc $PKGDIR/tcz/privoxy-doc.tcz -all-root -info
find $DESTDIR/doc -not -type d | sed -e "s#^${DESTDIR}/doc##" > $PKGDIR/tcz/privoxy-doc.tcz.list
cd .. && rm -rf doc
cd $PKGDIR/tcz
md5sum privoxy-doc.tcz > privoxy-doc.tcz.md5.txt

# Create privoxy.tcz package
cd $DESTDIR
strip --strip-all usr/local/sbin/*
tar -czf $PKGDIR/tar.gz/privoxy.tcz.tar.gz *
mksquashfs $DESTDIR $PKGDIR/tcz/privoxy.tcz -all-root -info
find $DESTDIR -not -type d | sed -e "s#^${DESTDIR}##" > $PKGDIR/tcz/privoxy.tcz.list
cd $PKGDIR/tcz
md5sum privoxy.tcz > privoxy.tcz.md5.txt
echo -e "ncurses.tcz\npcre.tcz" > privoxy.tcz.dep

# Cleanup
cd /tmp
rm -rf $DESTDIR
rm -rf /tmp/src_package/
rm -fr /tmp/download
