[4413] in java-interest
UNIX make script
daemon@ATHENA.MIT.EDU (R.Volkmann)
Fri Dec 22 12:55:48 1995
Date: Fri, 22 Dec 1995 10:14:29 -0600
From: "R.Volkmann" <m224873@svxtrm17.mdc.com>
To: java-interest@java.sun.com
Reply-To: "R. Mark Volkmann"<m224873@svmstr01.mdc.com>
Here's a make script I threw together this morning for compiling all .java
files in the current directory. It seems like a useful thing but who am I
to say. I'm no UNIX shell script expert so feel free to send me ideas for
improvements.
#!/bin/sh
#-------------------------------------------------------------------------------
# Name: make
# Author: Mark Volkmann
# EMail: m224873@svmstr01.mdc.com
#
# This script compiles all Java programs in the current directory if needed.
# The CLASSES enviroment variable must be set to indicate where the .class
# files of packages should be placed.
#
# NOTE: Because no attempt is being made to track the dependencies between
# source files, ordering of the compiles can affect their success.
# If one file imports another that will be compiled after it then it
# may be necessary to run this script again to get a successful compile.
#
# NOTE: In shell 0 is true and 1 is false.
#-------------------------------------------------------------------------------
options="" # Put options which should be used for all compiles here.
if [ "$CLASSES" = "" ]
then
echo "The environment variable CLASSES must be set to the directory"
echo "where the .class files of packages should be placed."
exit 1
fi
# For each .java file in the current directory ...
for javaFile in *.java
do
# Determine the name of the corresponding .class file.
name=`echo $javaFile | cut -f1 -d.`
classFile=$name.class
# If the .java file contains a package statement ...
package=`grep package $javaFile`
if [ $? -eq 0 ]
then
# Strip off the word package and the semi-colon at the end, then
# change the periods to slashes.
subDir=`echo $package | cut -f2 -d" " | cut -f1 -d";" | \
sed -e 's/\./\//g'`
classFile="$CLASSES/$subDir/$classFile"
opt="$options -d $CLASSES"
else
opt=$options
fi
compile=1
# If the .class file exists
if [ -s $classFile ]
then
# If the .java file is newer than the .class file then compile it.
find . -name $javaFile -newer $classFile -exec compile=0 \;
else
# There is no .class file so compile the .java file.
compile=0
fi
# If the .java needs to be compiled ...
if [ $compile -eq 0 ]
then
echo "---"
echo "compiling $javaFile to produce $classFile"
javac $opt $javaFile
fi
done
|------------------------------------------------------------|
| R. Mark Volkmann - Principal Specialist Programmer/Analyst |
| McDonnell Douglas Aerospace, St. Louis, Missouri, USA |
| email m224873@svmstr01.mdc.com, voice (314)232-0498 |
|------------------------------------------------------------|
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com