#! /bin/ksh

#
# Name        : ${HOME}/bin/cc_wrapper
#
# Version     : 1.0
#
# Author      : Gerard van Wageningen
#
# Description : Set a number of defines before calling cc. 
#
# 1.0   First Version
#

\whence set_debug 1>/dev/null 2>&1 && eval $( set_debug ${0##*/} )

MY_DATE="\"$( date '+%m/%d/%y' )\""
MY_TIME="\"$( date '+%H:%M:%S' )\""

PLATFORM="${UNAME:-$( uname )}"
PLATFORM="_$( print ${PLATFORM} | sed -e 's/\//_/g; s/-/_/g' | tr -s a-z A-Z )"

UNAME=$( uname -a )

if [[ "${UNAME}" = 'AIX' ]]
then
  EXTRA="-DMY_OBJECT_MODE=\"${OBJECT_MODE:-'not set'}\""
fi


COMMAND="$1"
shift
OPTIONS="$@"

COMPILER=$( ${COMMAND} -v 2>&1 | grep -i version | head -1 | tr -s ' ' )

"${COMMAND}" \
  -DUSER=\"${LOGNAME:-${USER}}\" \
  -DCOMPILER="\"${COMPILER}\"" \
  -DHOSTNAME="\"${HOSTNAME:-$( uname -n )}\"" \
  -DMY_DATE="${MY_DATE}" \
  -DMY_TIME="${MY_TIME}" \
  -DOPTIONS="\"${COMMAND} ${OPTIONS}\"" \
  -DUNAME="\"${UNAME}\"" \
  -D${PLATFORM} \
  ${EXTRA} \
  ${OPTIONS}

return $?

################# EOF #################
