xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Brunsmann <joerg.brunsm...@FernUni-Hagen.de>
Subject Re: Makefile's
Date Thu, 25 Nov 1999 19:37:50 GMT
James Duncan Davidson wrote:

> Compilers can work this stuff out for themselves. I've found the only
> check that saves any amount of time is just to compare a source file
> time against a class file time and if it's out of date, put it on the
> update list. 

And you don't even need to maintain a makefile for this. Just a script 
which I found some time ago:

#!/bin/bash
# see documentation below

src=${MAJA_SRC:-/usr/local/XTC/src}

classes=${MAJA_CLASSES:-/usr/local/XTC/classes}

javac=${MAJA_JAVAC:-javac}

recurse() {
  for source in "$@"; do
    if [ -d $source ]; then
      recurse $source/*
    else
      case $source in
      *.java) 
        class=$classes/${source%.java}.class
        if [ $source -nt $class -o ! -e $class ]; then
          echo $source
        fi
      esac
    fi
  done
}

cd $src
files=$(recurse *)

if [ -n "$files" ]; then
  echo $files
  $javac -d $classes "$@" $files
fi

exit

<<<<* MAJA, the shell script for MAking JAva *>>>>

Maja is a deceptively simple, but extremely useful script.  It
constructs a list of .java files that are newer than their
corrisponding .class files, and then calls javac once on the entire
list. 

Maja has a distinct advantage over make, which runs javac on each file
individually. Remember, a good portion of the time spent invoking
javac is simply to get a working java process up and running. Maja
incurrs that penalty only once, instead of possibly hundreds of times!

Also unlike make, there is no need to maintain a "make file": maja
simply keeps all .class files in the $MAJA_CLASS directory up to
date with the .java files in the $MAJA_SRC directory, including
sub-directories.

Maja uses one more environment variable: $MAJA_JAVAC. If this 
is defined, it is used as the name of the compiler. The default
is javac.

All the command-line arguments to maja are passed on to the compiler.
for instance, use "maja -O" to optimize maja's output.

Mime
View raw message