#!/bin/sh

JAVA=@JAVA@

working_dir=@CWD@

exec_prefix=@exec_prefix@


if [ $# -lt 1 ]
then
  echo "Usage: adjavac [ options ] files"
  echo "       -classpath is not supported, use CLASSPATH please"
  exit 1
fi

if test "$CLASSPATH" = ""
then
  if [ -f ${working_dir}/src/adJava/libspmdjava.so ]
  then
    CLASSPATH=${working_dir}/src/adJava/class
  else
    CLASSPATH=${exec_prefix}/lib
  fi
else
  if [ -f ${working_dir}/src/adJava/libspmdjava.so ]
  then
    CLASSPATH=${working_dir}/src/adJava/class:$CLASSPATH
  else
    CLASSPATH=${exec_prefix}/lib:$CLASSPATH
  fi
fi

export CLASSPATH

CMD=$*

#if there is classpath, not finished
#if [ $# -gt 1000 ]
#then
#  until [ $# -eq 1 ]
#  do
#    if [ $1 != -classpath ] 
#    then 
#      CMD="$CMD $1"
#    else
#      CMD="$CMD $1"
#      shift
#      CMD="$CMD .;$JAVA/class:$JAVA/lib/classes.zip:$ADLIB:$1"
#      shift
#    fi  
#  done
#  CMD="$CMD $1"
#else
#  CMD="-classpath .;$JAVA/class:$JAVA/lib/classes.zip:$CLASSPATH $*"
#fi

$JAVA/bin/javac $CMD
