
org.enhydra.xml.xmlc.commands.xmlc-config.sh Maven / Gradle / Ivy
The newest version!
#!/bin/sh
#
# Coniguration script for standalone XMLC release.
#
# xmlc-config -java javacmd [-javac javaccmd] [xmlc-home-dir]
#
# This script edits all files in the XMLC standalone distribution that contain
# absolutes paths to have the correct location on systems on which they
# are installed.
#
#
# The script *must* be run in the XMLC_HOME directory to be edited. The
# optional argument xmlc-home-dir specifies the value to use for the XMLC_HOME
# directory. If its not specified, its assumed to be the current directory.
# This is normally not needed, it allows pre-configuring XMLC for installation
# in another directory
#
# The script maybe rerun if necessary, which is useful if the installation
# location must be moved.
#
# Several options are available for specifying the location of external
# packages. They take absolute file paths as arguments. On windows, this
# should be specified using the CygWin windows naming syntax of
# //drive/file/path. For example: //C/mystuff/java1.2.
#
# The options are:
# o -java javacmd - Specifies the full path to the java command to use to
# run XMLC.
#
# o -javac javaccmd - Specifies the full path to the java compiler command to
# use to compile the results of XMLC. If not specified `javac' in
# the same directory as the java command is used.
#
# Build process overrides the jar location using XMLC_CLASSES env var.
#
# Usage msg and exit
usage() {
echo "Usage: xmlc-config -java javacmd [-javac javaccmd] [xmlc-home-dir]" >&2
exit 1
}
#
# Entry point.
#
JAVA=""
JAVAC=""
while [ $# -gt 0 ] ;do
case $1 in
-java)
shift
JAVA="$1"
shift;;
-javac)
shift
JAVAC="$1"
shift;;
--)
shift
break;;
-*)
usage;;
*)
break;;
esac
done
case $# in
0)
XMLC_HOME=`pwd`;;
1)
XMLC_HOME="$1";;
*)
usage;;
esac
XMLC_BIN="${XMLC_HOME}/bin"
XMLC_DIST_BIN="${XMLC_HOME}/dist/bin"
XMLC_CLASSES=${XMLC_CLASSES:="${XMLC_HOME}/lib/xmlc.jar"}
XMLC_SUPPORT_CLASSES="${XMLC_HOME}/lib/xmlc-support.jar"
# Check that we are in the right place.
CHECK_FILE=${XMLC_DIST_BIN}/xmlc.in
if [ ! -r "${CHECK_FILE}" ] ; then
echo "Error: '${CHECK_FILE}' not found" >&2
echo " Current directory must be the XMLC home directory or" >&2
echo " XMLC home directory should be specified on the command line" >&2
exit 1
fi
# Check for existance of java command.
if [ "X${JAVA}" = "X" ] ; then
echo "Error: must specify -java" >&2
exit 1
fi
if [ ! -r "${JAVA}" ] ; then
echo "Error: '${JAVA}' not found" >&2
exit 1
fi
# Default and check javac command
if [ "X${JAVAC}" = "X" ] ; then
JAVAC="`dirname ${JAVA}`/javac"
fi
if [ ! -r "${JAVAC}" ] ; then
echo "Error: '${JAVAC}' not found" >&2
exit 1
fi
# Need JDK runtime in case jikes is used
JDKDIR="`dirname ${JAVA}`/.."
# Generate command
rm -f ${XMLC_BIN}/xmlc
mkdir -p ${XMLC_BIN}
sed -e "s|@XMLC_CLASSES@|${XMLC_CLASSES}|g" \
-e "s|@XMLC_SUPPORT_CLASSES@|${XMLC_SUPPORT_CLASSES}|g" \
-e "s|@JAVA@|${JAVA}|g" \
-e "s|@JAVAC@|${JAVAC}|g" \
-e "s|@JDKDIR@|${JDKDIR}|g" \
< ${XMLC_DIST_BIN}/xmlc.in > ${XMLC_BIN}/xmlc || rm -f ${XMLC_BIN}/xmlc
chmod a+rx,a-w ${XMLC_BIN}/xmlc
© 2015 - 2025 Weber Informatics LLC | Privacy Policy