help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to have dependencies based on target?


From: Chad Loder
Subject: Re: how to have dependencies based on target?
Date: Tue, 27 Nov 2001 17:43:55 -0800

Java and make don't work well together. You can get
a reasonable make system for Java using some of
the cool features of GNU make, but honestly it's
a pain.

In particular, dependency analysis will never
work exactly the way you want. Make doesn't like
mutually dependent targets (something very common
in Java programs).

Another annoying thing (although it can be solved
by correct use of VPATH) is Java's insistence that
the directory structure of .java and .class files
reflect the package structure of the classes. This
means that the Java compiler will create the appropriate
subdirectories as needed. Not insurmountable, but
certainly another source of complexity.

After 4 years of dealing with various Java+make systems,
I would recommend using Ant http://jakarta.apache.org/ant/
for non-trivial Java build systems. A nice thing about
using Ant to build Java programs is it "knows" about packages
and Java dependencies, so it can compile and recompile much
faster than your typical Java make system.

        c

At Tuesday 11/27/2001 11:08 AM -1000, you wrote:
I would like to build a java jar file  x.jar  based on changes to
any  .class  files in subtree  x .  I tried the rule

%.jar: $(shell find $* -name \*.java | sed 's/\.java$$/.class/')
        @$(RM) $@
        $(JAR) cf $@ $^

but  find  doesn't like this.  When I tried hardwiring the directory
as an experiment, like so

%.jar: $(shell find x -name \*.java | sed 's/\.java$$/.class/')
        @$(RM) $@
        $(JAR) cf $@ $^

it worked as expected.  But it seems that  $@  and  $*  are not
expanded on the target line (i.e. in the dependecies list)!  (Hence
why  find  complains, I think.)

Is this correct behavior, or am I doing something wrong?  How can I
get this to work -- it seems such a basic thing?

Please CC me, as I am not a member of this list.  Thanks!

_______________________________________________
Help-make mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/help-make





reply via email to

[Prev in Thread] Current Thread [Next in Thread]