#!/bin/bash
#
# THIS IS ONLY FOR CORE TEAM MEMBERS.  IT WON'T WORK IF YOU'RE NOT A CORE
# TEAM MEMBER.  DON'T BOTHER
#

if [ $# != 1 ]; then
  echo "Run this as $0 <libc-string>"
  echo "e.g. $0 glibc2"
  echo "     $0 libc5"
  exit 1
fi



eval `grep "^MAJOR_VERSION=" configure.in`
eval `grep "^MINOR_VERSION=" configure.in`
eval `grep "^PICO_VERSION=" configure.in`
Release=$MAJOR_VERSION.$MINOR_VERSION.$PICO_VERSION
BUILD_MAJOR="1"
BUILD_MINOR="2"

echo '######################################################################'
echo ' Making release $Release for $0'
echo '######################################################################'


#
# Xlt build
#
rm -rf /opt/lesstif/*
if ! ( cd lib/Xlt
       autoheader
       automake -i
       autoconf
      ./configure --prefix=/opt/lesstif --enable-static=no
      make install
)
then
	echo "making Xlt failed"
#	exit
fi

#
# core lesstif build
#
autoheader
automake -i
autoconf
./configure --prefix=/opt/lesstif --enable-static=no --enable-build-${BUILD_MAJOR}${BUILD_MINOR}
if ! make
then
	echo "make failed"
	exit
fi
if ! make install
then
	echo "make install failed"
	exit
fi

#
# Strip and Tar it up
#
strip /opt/lesstif/lib/libXm.so.*
strip /opt/lesstif/lib/libMrm.so.*
strip /opt/lesstif/lib/libXlt.so.*
strip /opt/lesstif/bin/mwm
strip /opt/lesstif/bin/uil
strip /opt/lesstif/bin/xmbind
cp clients/Motif-1.2/mwm/README /opt/lesstif/LessTif/README.mwm
cd /opt
if ! tar -cf lesstif-$Release-linux-$1.tar lesstif
then
	echo "tar failed"
	exit
fi
if ! gzip -f -9 lesstif-$Release-linux-$1.tar
then
	echo "gzip failed"
	exit
fi
exit

echo '######################################################################'
echo ' Done making release $Release for $0'
echo '######################################################################'
