Java Makefile

E

eli.hen

Hi,

Makefile file is:
--------------------

JAVAC=javac
CLASSPATH=./src:./ext:./ext/jdom.jar
JAVACFLAGS=
SRCPATH=./src
CLSPATH=./classes

..SUFFIXES: .java .class
..java.class:
$(JAVAC) -classpath $(CLASSPATH) -d $(CLSPATH) $(JAVACFLAGS)
$(<:%=$(SRCPATH)/%)

all: Cls1.class Cls2.class


The output of "make all" is:
make: *** No rule to make target `Cls1.class'. Stop.

[make version: 3.72.1 by Richard Stallman and Roland McGrath]

What's wrong? How can it be fixed?

-thanks, Eli
 
M

Malte

Hi,

Makefile file is:
--------------------

JAVAC=javac
CLASSPATH=./src:./ext:./ext/jdom.jar
JAVACFLAGS=
SRCPATH=./src
CLSPATH=./classes

.SUFFIXES: .java .class
.java.class:
$(JAVAC) -classpath $(CLASSPATH) -d $(CLSPATH) $(JAVACFLAGS)
$(<:%=$(SRCPATH)/%)

all: Cls1.class Cls2.class


The output of "make all" is:
make: *** No rule to make target `Cls1.class'. Stop.

[make version: 3.72.1 by Richard Stallman and Roland McGrath]

What's wrong? How can it be fixed?

-thanks, Eli

..java.class: perhaps?

A good fix for make is to use ant :)
 
T

Thomas Weidenfeller

What's wrong? How can it be fixed?

The rule interference fails, because make can't find the needed input
for building a .class file. So it correctly reports that it doesn't know
how to build Cls1.class. It can't find the needed input, because you
have hidden it in another directory.

It is a bad idea to run a makefile from a directory which does not
contain the source. You would have to mess with the ugly VPATH feature
(VPATH can really surprise you if you happen to have files with the same
name in different directories, e.g. an accidental older copy of some
source).

It would be best if you place the makefile in the same directory as the
source which you want to compile.


/Thomas
 
S

slippymississippi

Ant is a platform-independent java-centric make tool based on xml.
It's fairly useful. But if you really want a powerful make tool, go
with Maven 2.0.

To answer your question, though... somewhere in that make file you need
a rule for building Cls1.class and Cls2.class. Generally, all: just
tells you which targets to build. There are no Cls1.class: and
Cls2.class targets.

I don't know enough about make to tell you, but it looks like whoever
gave you this wants you to figure out what the heck the fancy macro
$(<:%=$(SRCPATH)/%) does.
 
T

Thomas Weidenfeller

Ant is a platform-independent java-centric make tool based on xml.

a) it is not a make tool. It is an ill conceived scripting thingy.

b) The usage of xml is a design blunder beyond believe.

/Thomas
 
R

Roedy Green

b) The usage of xml is a design blunder beyond believe.

I tease the ANTish use of XML in the Java glossary
http://mindprod.com/jgloss/ant.html this way:

Conditional execution is extremely clumsy in ant. Imagine in Java that
instead of writing this:

// conditional increment in Java
if ( file.exists() ) i++;

You had to write:

// How ant thinks about conditionals.
// This is how Ant would write java if ant could
// write java programs.
boolean doesFileExist = file.exist();
call maybeIncrement();
//..
void maybeIncrement()
{
if ( ! doesFileExist ) return;
i++;
}

Then you have some idea of the verbosity of ant conditionals.
Obviously, ant conditionals are not written in Java, but they have
that same degree of awkwardness. This comes from trying to do
everything in pure XML syntax. In ant you have to create a named step
called a target that contains the commands you may or may not want to
execute. Then you apply the keyword if and property name to the
target. You have to elsewhere in the program set the property to true
or false depending on whether you want the step executed. Then you
have to do an <antcall to the step to attempt to execute it! All this,
because the ant people have a love affair with XML! It is major
production to conditionally copy a file that may or may not exist.


<!-- conditional file copy in ANT -->

<!-- copy pad.xml from website to project dir, if it exists -->
<available property="has.pad.xml"
file="${pad.dir}/${ant.project.name}.xml" />

<antcall target="copy.pad.xml" />

<!-- copy pad.xml from website to project dir, if there is one. -->
<target name="copy.pad.xml" if="has.pad.xml">
<copy file="${pad.dir}/${ant.project.name}.xml"
todir="${package.dir}" failonerror="false" overwrite="true" />
</target>
 
S

slippymississippi

a) it is not a make tool. It is an ill conceived scripting thingy.

Ant is clunky, but it led to the creation of Maven 2.0, which is a
thing of pure beauty.
 
D

Dimitri Maziuk

Roedy Green sez:
most people use Ant instead of Make. It will work many times faster
and will be multiplatform. The syntax sucks 100 day old hen eggs, (XML
based), but it works.

More specifically, Java doesn't have a separate link stage,
so ".java.class" Makefile rule only works for stand-alone
classes. Usually you need something like
javac /some/path/*.java
and the only way to tell make that target depends on all
java files in /some/path is to list them all in the Makefile.
And that won't do incremental compiles.

In ant this logic is built in, making it a better Java build
tool in spite of "declarative" (read: the only way to make a
procedural rule like .c.o is is to code it in Java as an ant
task) XML.

Dima
 
J

Jean-Francois Briere

Ant is one of the most widely used build tools in the Java universe.
There are many reasons for it. Among other things, it solved many
problems related to makefiles.
So if you are not yet familiar with Ant, do yourself a favor and try
it.

Regards
 
T

Thomas Weidenfeller

Jean-Francois Briere said:
Ant is one of the most widely used build tools in the Java universe.

Which doesn't change that fact that it is fundamentally flawed with its
XML syntax.

/Thomas
 
T

Thomas Weidenfeller

Michael Redlich wrote:

Oh, did I forgot to plonk you in this group? I'll change that in a second.
Hmmm...this is an interesting response coming from the author of
XMLtp...

Nop. It just means that I have an informed opinion about the usage of
XML in ant. And that opinion is that the XML usage in ant is a design
blunder beyond believe.
For those of you not familiar with XMLtp, check out
http://mitglied.lycos.de/xmltp/.

Thanks for advertising my software, it has been discussed here a few
times in the past. However, these days I recommend that people use
Java's build in XML API if they are in need to handle XML. XMLtp is less
powerful and limited and originated from the times when Java SE didn't
come with XML support.

/Thomas
 
M

Michael Redlich

Thomas said:
Oh, did I forgot to plonk you in this group? I'll change that in a second.

Mach was sie wollen...
Nop. It just means that I have an informed opinion about the usage of
XML in ant. And that opinion is that the XML usage in ant is a design
blunder beyond believe.

OK, so far I've heard you say *three* times that the XML usage in Ant
is a design blunder beyond belief. The only thing I haven't heard is
your explanation for *why* it is flawed.
Thanks for advertising my software, it has been discussed here a few
times in the past. However, these days I recommend that people use
Java's build in XML API if they are in need to handle XML. XMLtp is less
powerful and limited and originated from the times when Java SE didn't
come with XML support.

No problem. I downloaded your software despite the fact that you
explicity stated that it was developed before the Java API had support
for XML. I was curious to see how you implemented an XML parser, and I
was especially impressed with the GUI demo application.
As-a-matter-of-fact, it parsed an Ant build.xml file quite nicely.
:-0

I am actually planning to demo your software at an upcoming ACGNJ Java
Users Group. I usually make most of the presentations, but a
presentation from the author would be more effective, don't you think?
Whaddya say, Thomas? Why not take some vacation time to visit scenic
New Jersey sometime next year? Heck, I'll even take some time off to
show you around New York City as well.

Sind sie von Deutchland? Ich bin auch Deutch (ya know, redlich, an old
German term meaning integrity). My parents were born in Germany...

Tchuss..

Mike.
 
R

Roedy Green

OK, so far I've heard you say *three* times that the XML usage in Ant
is a design blunder beyond belief. The only thing I haven't heard is
your explanation for *why* it is flawed.

See http://mindprod.com/jgloss/ant.html

Where I show some examples of the circumlocutions you need with XML
that would take only a line of code in any sane language.
..
 
A

Alan Krueger

Michael said:
Sind sie von Deutchland? Ich bin auch Deutch (ya know, redlich, an old

"Deutschland" and "Deutsch"
German term meaning integrity). My parents were born in Germany...

Tchuss..

"Tschüss"

According to custom, any spelling/grammer critique is supposed to have
an error of its own, so I've inserted at least one into this sentence.
 
S

Stefan Ram

Alan Krueger said:
"Tschüss"

First, to add something to the subject of the thread: This
topic (Ant-Makefile-Syntax) currently also is being discussed
in de.comp.lang.java.

My personal reference the Duden (1973) only lists

"tschüs!".

(More recent instances of this book might have added a second
"s" to the end)

The complete entry is:

*tschüs! /fr./ [auch: /tschüß/] (ugs.-
- ·

fam. für: auf Wiedersehen!)

Where "[/tschüß/]" does not intend to give the spelling, but
only an alternate pronunciation as being described by the
Duden (1973):

[] Die e c k i g e n K l a m m e r n schließen
Aussprachebezeichnungen (vgl. S. 13, VI), zusätzliche
Trennungsangaben (z.B. Ecke [/Trenn/.: Ek|ke]), Zusätze zu
Erklärungen in runden Klammern (vgl. S. 13, V) und
beliebige Auslassungen (Buchstaben und Silben, wie z.B. in
abschnittweise, Wißbegier[de]) ein.

(...)

Die (...) verwendete besondere L a u t s c h r i f t
ergänzt das lateinische Alphabet:

(...)

ß ist das stimmlose (harte) s, z.B. Malice [...liß@]

(...)

Ein unter den Selbstlaut (Vokal) gesetzter P u n k t
gibt betonte K ü r z e an, ein Strich betonte
L ä n g e

(...)

The bibliographic data of that Duden are:

[resource:book/Duden Rechtschreibung 1973] =
< :is-a = [book]
:description:editor = [Dudenredaktion]
:description:series = [Duden]
:description:title = [Rechtschreibung]
:description:publisher = [Bibliographisches Institut AG]
:description:address = [Mannheim]
:description:date = [1973]
:description:volume = [1]
:description:isbn = [3-411-00911-X]
 
M

Michael Redlich

Alan said:
"Deutschland" and "Deutsch"


"Tschüss"

According to custom, any spelling/grammer critique is supposed to have
an error of its own, so I've inserted at least one into this sentence.

Guten tag, Alan:

Oops. Thanks for pointing out my spelling errors. I *definitely*
should have known better. I was, however, aware that "tschüss" had
the umlaut, but I couldn't remember the keystroke sequence for 'ü'
while I was typing this morning. Oh, and by-the-way, 'grammer' should
be 'grammar'.

OK, it's time for mittag essen here in New Jersey (guten appetit).

I assume that you live in Germany? If so, where? My mom was born in a
small town near Bad Kreuznach, called Pfaffen Schwabenheim. My dad was
originally from Lauchhammer, near Dresden.

Tschüss...

Mike.
 
A

Alan Krueger

Michael said:
Alan Krueger wrote: [...]
According to custom, any spelling/grammer critique is supposed to have
an error of its own, so I've inserted at least one into this sentence.
[...]
Oh, and by-the-way, 'grammer' should be 'grammar'.

Indeed.
 
L

Luc The Perverse

Alan Krueger said:
Michael said:
Alan Krueger wrote: [...]
According to custom, any spelling/grammer critique is supposed to have
an error of its own, so I've inserted at least one into this sentence.
[...]
Oh, and by-the-way, 'grammer' should be 'grammar'.

Indeed.

Not nearly as ironic as "speling"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top