help-make
[Top][All Lists]
Advanced

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

Re: have a problem mixing Make and java.


From: Dave Hylands
Subject: Re: have a problem mixing Make and java.
Date: Tue, 21 Feb 2006 09:36:21 -0800

Hi richt,

On 2/20/06, richard t <address@hidden> wrote:
> heres a minimal version of my make file
>
> src = ./src
> obj = ./obj
> ui_c = com/rich/tool/ui/MainPanel.class
> db_c= com/rich/tool/db/Connect.class \
>           com/rich/tool/db/User.class
> tl_c =  com/rich/tool/Tool.class
>
> classes = $(ui_c) $(db_c) $(tl_c)
>
> target: $(classes)
>        echo "done"
>
> $(classes) : $(subst .class,.java,$(subst
> $(obj),$(src),$(classes)))
>        javac $(JFLAGS) $(subst $(src)/,,$<)
>
> ok the problem that I get is that the macro ($<) does
> not seem to iterate for the
> different source files and I would like to know why
> that happens, and also a problem is that when a source
> file gets changed Make doesnt seem to know that it
> needs to recompile the source for it and I would like
> to know why that is...

$< is defined as the first prerequisite. It doesn't iterate. Actually
not much in make iterates.

> in the gnu make user's manual you should be able to do
> something like:
>
> $(dir)/%.o : $(dir)/%.c
>     $(cc) $(cflags) $<
>
> so I would think that my makefile should work. as a
> sideline note, I did make a work around for this by
> using the target macro $@ which does seem to iterate
> through the target list. Unfortunately I still have
> the problem where a modified source doesn't trigger
> make to recompile it.

You need to add a rule like this (I'm not a java person) to create a
.class file in the $(obj) directory from a .java file in the $(src)
directory.

$(obj)/%.class : $(src)/%.java
        javac $(JFLAGS) -o $@ $<

I don't know if I got the syntax right. "-o $@" is to specify the name
of the .class file, and $< specifies the name of the .java file.

However, your class files don't appear to be in a $(obj) directory, so
what I've shown won't work properly.

What we need to know to create a functional example is this:

1 - For the class file com/rich/tool/ui/MainPanel.class, where is the
MainPanel.java file?
2 - How do you tell javac where to put an output file and what to name it?

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/




reply via email to

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