#! /bin/bash
#set -xv
#=========================================================================
# Copyright (C) GemTalk Systems 1986-2024.  All Rights Reserved.
#
# Name - makeinstall.sh
#
# Usage - buildsystests [make-args]
#         Examples:
#           buildsystests CC=gcc  # will compile and link using gcc instead of cc
#           buildsystests clobber # will remove all executables and objects. 
# Purpose - invoke the install Makefile with the proper host dependent
#           arguments.
#
#=========================================================================

# Install defaults
. $ARCHBASE/gsmake/setup_build.sh 64

if [ "x$BASH_VERSION" = "x" ]; then
  if [ "a$GSBASH" = "a" ]; then
    if [ "a$GEMSTONE" = "a" ]; then
      echo "ERROR: GemStone scripts require a GEMSTONE environment variable."
      echo "       Please set it to the directory where GemStone resides."
      exit 1
    fi
    BASH=$GEMSTONE/bin/bash
  else
    BASH=$GSBASH
  fi
  # Should be using -x here, but we have Ultrix /bin/sh to consider..
  if [ ! -f $BASH ]; then
    echo "ERROR: I can't find $BASH. Please check your GEMSTONE environment"
    echo "       variable, or call GemStone Customer Support for assistance."
    exit 1
  fi
  if [ ! -f /etc/license ]; then # don't do this with Ultrix shell
    unset ENV
  fi
  exec $BASH -norc -noprofile $0 $*
  exit $?
fi

# Set up correct path.  THIS IS NOT TRIVIAL!!!
savedPath=$PATH
PATH=/bin:/usr/bin		# minimal
if [ -d /usr/ccs/bin ]; then
  PATH=/usr/ccs/bin:$PATH	# must be after /bin, but before /usr/ucb
fi
# PATH=$PATH:/usr/ucb		# /usr/ucb not needed by this script.
PATH=$PATH:$savedPath		# put your junk AFTER my junk.
export PATH

# For internal work
if [ -f Makefile.install ]; then
  INSTALLGSmake="${GMAKE} -f Makefile.install"
else
  INSTALLGSmake="${GMAKE}"
fi

# C++ compiler is required here.
CC=$NATIVE_CXX
export CC
CFLAGS="$NATIVE_DEBUG_CXXFLAGS -D$HOSTTYPE$OSTYPE -I$SRCDIR "
export CFLAGS

LDLIBS=$DEFAULT_LIBS
export LDLIBS

exec $INSTALLGSmake $*

