#!/bin/sh
#
# Configuration Program for Portable Object Compiler
# Copyright (c) 1997,98. All Rights Reserved.
#
# Script to build some additional libraries
# (after doing a normal ./configure make install)

T=/tmp/$$
MK=make
CF="configure.orig -M"
CP="cp -p"
GCPREF="@GCPREFIX@"
sosuf="@DOTSHLIBSUFFIX@"

PATH=".:$PATH"
export PATH

trap "$MK distclean;rm -f $T; exit 1" 1 2 15

$MK clean 

# runtime library for -gc option
if [ -f $GCPREF/include/gc.h ]; then
cat >$T <<EOF
OTHER_MFLAGS="-q -gc -DOBJCRT_BOEHM"
EOF

$CF -f $T
$MK objcrt
$CP src/objcrt/objcrt.a lib/objcrtgc.a
$MK clean
else
  echo "----------------------------------"
  echo "Couldn't find $GCPREF/include/gc.h"
  echo "Skipping build of objcrtgc.a" 
  echo "objc -gc will not work."
  echo "----------------------------------"
  echo "Use configure --gcprefix=DIR"
  echo "----------------------------------"
  sleep 2
fi

# debug libraries for -g option
cat >$T <<EOF
MFLAGS=DBG_MFLAGS
EOF

$CF -f $T 
$MK objcrt
$MK objpak
$CP src/objcrt/objcrt.a lib/objcrt_g.a
$CP src/objpak/objpak.a lib/objpak_g.a
$MK clean

# reference counted foundation classes for -refcnt option
cat >$T <<EOF
OTHER_MFLAGS="-q -refcnt"
EOF

$CF -f $T
$MK objcrt
$MK objpak
$CP src/objcrt/objcrt.a lib/objcrtr.a
$CP src/objpak/objpak.a lib/objpakr.a
$MK clean 

if false
then
# profile libraries for -pg option
cat >$T <<EOF
OTHER_MFLAGS="-q -pg"
EOF

$CF -f $T
$MK objcrt
$MK objpak
$CP src/objcrt/objcrt.a lib/objcrt_p.a
$CP src/objpak/objpak.a lib/objpak_p.a
$MK clean 
fi

# shared libraries for -dynamic option
cat >$T <<EOF
OTHER_MFLAGS="-q -inlinecache -pic"
AR=echo
EOF

$CF -f $T 
$MK shlib
$CP src/objcrt/libobjcrt$sosuf lib
$CP src/objpak/libobjpak$sosuf lib
$MK clean 

if false
then
# libraries for -otb (double indirection) option
cat >$T <<EOF
OTHER_MFLAGS="-q -otb"
EOF

$CF -f $T
$MK objcrt
$MK objpak
$CP src/objcrt/objcrt.a lib/otbcrt.a
$CP src/objpak/objpak.a lib/otbpak.a
$MK clean

# runtime library for -pthreads option
if [ -f /usr/include/pthreads ]; then
cat >$T <<EOF
OTHER_MFLAGS="-q -DOBJCRT_PTHREADS"
EOF

$CF -f $T 
$MK objcrt
$CP src/objcrt/objcrt.a lib/objcrtth.a
$MK clean 
fi
fi

rm $T
$CF
$MK clean

