#!/bin/sh
CWD=`pwd`
VERSION=2.1.5

# Step one is to remove existing freetype2 cruft:
rm -rf /usr/include/freetype2 \
       /usr/X11R6/include/freetype2 \
       /usr/lib/libfreetype.* \
       /usr/X11R6/lib/libfreetype.*
# It seems prudent to move this into /usr rather than /usr/X11R6, as *many* source bits
# won't find ft2build.h in /usr/X11R6/include without some patching.
# Therefore, --prefix=/usr must be the ad-hoc standard.  Another
# rationale:  /usr is also the prefix for freetype1 (for as long as that sticks around),
# and putting them in different prefixes causes problems.  Also, we're bumping the -march
# from i386 to i486, as I can't imagine too many people are running the latest Slackware
# with X on a 386 in the year 2002.  If there are, maybe they can get away with running an
# earlier version of X.  :-) 
cd /tmp
rm -rf freetype-$VERSION
tar xjf $CWD/freetype-$VERSION.tar.bz2
cd freetype-$VERSION
chown -R root.root .
CFLAGS="-O2 -march=i486 -mcpu=i686" make setup CFG="--prefix=/usr i486-slackware-linux"
make
make install
ldconfig
# This shouldn't be needed (apps should pick up -I/usr/include/freetype2 from
# `freetype-config --cflags` while compiling), but it's so often reported as a bug that
# I'll give in to the point.  Now that Freetype1 is pretty much gone having this link
# shouldn't hurt anything.  Try not to rely on it, though.
( cd /usr/include
  rm -rf freetype
  ln -sf freetype2/freetype .
)
cp -a docs /usr/X11R6/lib/X11/doc/freetype-$VERSION
rm -rf /usr/X11R6/lib/X11/doc/freetype-$VERSION/reference

