Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Makefiles for JAVA

Reply
Thread Tools

Makefiles for JAVA

 
 
sasquatch
Guest
Posts: n/a
 
      11-08-2003
I've recently started developing JAVA apps for some of my courses, but I
work on both Windows and Unix. Can somebody point me in the direction of
any good tutorials on what exactly makefiles are and how to do them? Any
help is sincerely appreciated.

Alex Marshall


 
Reply With Quote
 
 
 
 
Harald Hein
Guest
Posts: n/a
 
      11-08-2003
"sasquatch" wrote:

> I've recently started developing JAVA apps for some of my courses,
> but I work on both Windows and Unix. Can somebody point me in the
> direction of any good tutorials on what exactly makefiles are and
> how to do them?


Makefiles are text files that the input files for a tool called make.
Actually, there are many, many versions of make out there, a lot of
them slightly incompatible when it comes to enhancements.

The original make was written by a guy called Stuard I. Feldman. He
wrote the Bell Labs Unix FORTRAN stuff and needed a build utility:
make. The name comes from the development cycle he used to build his
programs: think - edit - make - test.

A makefile consists of rules, and describes how to transform one type
of a file (e.g. a source code file) to another type (e.g. an object
module). If one (the source file) is newer than the other (the object
code) a script is triggers (e.g. running the compiler), to generate the
one from the other.

Many people have bashed heavily. IMHO this is uncalled. Make does
exactly what it is supposed to do, and a few things more. However, it
is not a general purpose scripting utility. Make has a certain rough
charme, but does not show its beauty to everyone.

Classic make and a lot of the modern enhanced version have a problem
with Java. It is easy and common to have circular references between
source files in Java. Classic make does not allow one to specify
circular references. Using such a make, you have to degrade your build
rules to "always compile everything" which results in loosing all
advantages of make. Fortunately Sun has published a version of make
that can handle this: http://developers.sun.com/dev/coolstuff/javamake/
If you use make, you migth want to get this one. Be careful, there are
several make versions out there which are called "javamake". Get the
one from Sun.

People will suggest an alternative for make when compiling Java. This
thing is called ant. I don't like it too much. The idea of a special
purpose scripting language based on XML doesn't appeal to me. You will
find that ant fans are very religious about the tool.
 
Reply With Quote
 
 
 
 
Thomas Kellerer
Guest
Posts: n/a
 
      11-08-2003
Harald Hein schrieb:
> People will suggest an alternative for make when compiling Java. This
> thing is called ant. I don't like it too much. The idea of a special
> purpose scripting language based on XML doesn't appeal to me. You will
> find that ant fans are very religious about the tool.


Well I like it, but I'm not "religious" about it. IMHO I find the ant files
easier to read and understand then make files. But I do think it's a matter
of taste. But it does ease the creation of Java binaries. Such as writing
the manifest information without an external manifest file, built in tar,
jar and zip support. I admit that there are numerous tools which can do
that as well, but still I like to have everything "in one place"

Btw: the creation of tar files on Windows and setting *nix file permissions
and flags (i.e. executable) is something I really like!

Thomas


 
Reply With Quote
 
Dale King
Guest
Posts: n/a
 
      11-10-2003
"Harald Hein" <(E-Mail Removed)> wrote in message
news:Xns942D73BD0F9C6hhtoken@194.97.5.11...
> "sasquatch" wrote:
>
> Classic make and a lot of the modern enhanced version have a problem
> with Java. It is easy and common to have circular references between
> source files in Java. Classic make does not allow one to specify
> circular references. Using such a make, you have to degrade your build
> rules to "always compile everything" which results in loosing all
> advantages of make. Fortunately Sun has published a version of make
> that can handle this: http://developers.sun.com/dev/coolstuff/javamake/
> If you use make, you migth want to get this one. Be careful, there are
> several make versions out there which are called "javamake". Get the
> one from Sun.


Just to be clear, javamake is not a version of the make tool. It is a
standalone tool that will handle dependencies and compile all of the source
affected by a change.

> People will suggest an alternative for make when compiling Java. This
> thing is called ant. I don't like it too much. The idea of a special
> purpose scripting language based on XML doesn't appeal to me. You will
> find that ant fans are very religious about the tool.


The real issue is that those religious about it will tell you that it
actually is an alternative to make. It is nothing of the kind. It is a
special-purpose XML scripting language. make is all about handling
dependencies between files and the steps to create them. Ant has little in
the way of expressing dependencies, including many ad-hoc, undocumented, and
insufficient attempts at dependency handling. It is easy to create scenarios
in Ant where you can edit a source file, run ant, have it report no
problems, and have an incorrect build. The goal of make is that this never
happens.

Note that javamake is usable as an ant task so that you can at least do that
to get your java building correct.

--
Dale King


 
Reply With Quote
 
Dave Monroe
Guest
Posts: n/a
 
      11-11-2003
Harald Hein <(E-Mail Removed)> wrote in message news:<Xns942D73BD0F9C6hhtoken@194.97.5.11>...
> "sasquatch" wrote:
>
> > I've recently started developing JAVA apps for some of my courses,
> > but I work on both Windows and Unix. Can somebody point me in the
> > direction of any good tutorials on what exactly makefiles are and
> > how to do them?

>
> Makefiles are text files that the input files for a tool called make.
> Actually, there are many, many versions of make out there, a lot of
> them slightly incompatible when it comes to enhancements.
>
> The original make was written by a guy called Stuard I. Feldman. He
> wrote the Bell Labs Unix FORTRAN stuff and needed a build utility:
> make. The name comes from the development cycle he used to build his
> programs: think - edit - make - test.
>


Wow, Harald, that brings back memories. Nice to know there are still
a few of us old Unix guys around.

Make is a good old tool and is probably adequate as a build utility
for a Java project.

Check out 'ant' (apache.org) - it might be better suited to the task.
That's what I usually wind up using.

My $0.02.

Dave Monroe
 
Reply With Quote
 
Dale King
Guest
Posts: n/a
 
      11-12-2003
"Dave Monroe" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Harald Hein <(E-Mail Removed)> wrote in message

news:<Xns942D73BD0F9C6hhtoken@194.97.5.11>...
> > "sasquatch" wrote:
> >
> > > I've recently started developing JAVA apps for some of my courses,
> > > but I work on both Windows and Unix. Can somebody point me in the
> > > direction of any good tutorials on what exactly makefiles are and
> > > how to do them?

> >
> > Makefiles are text files that the input files for a tool called make.
> > Actually, there are many, many versions of make out there, a lot of
> > them slightly incompatible when it comes to enhancements.
> >
> > The original make was written by a guy called Stuard I. Feldman. He
> > wrote the Bell Labs Unix FORTRAN stuff and needed a build utility:
> > make. The name comes from the development cycle he used to build his
> > programs: think - edit - make - test.
> >

>
> Wow, Harald, that brings back memories. Nice to know there are still
> a few of us old Unix guys around.
>
> Make is a good old tool and is probably adequate as a build utility
> for a Java project.


Unfortunately, it isn't. It works for C/C++ because object files only depend
on source files. In Java class files depend on a source file and other class
files. This means that there can be circular dependencies in Java. The only
way to resolve some circular dependencies is to make sure that all the
necessary source files are compiled at the same time. Java has no means to
do this.

> Check out 'ant' (apache.org) - it might be better suited to the task.
> That's what I usually wind up using.


Unfortunately, ant is less suited to the task.

--
Dale King


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ant vs Makefiles Harris L Java 20 12-02-2004 10:35 AM
Help on makefiles Max C++ 12 09-27-2004 03:31 AM
Structure of the code (files, dir's, namespaces, makefiles) db C++ 2 04-13-2004 03:46 PM
Can someone make winvn makefiles tith Digital MarsMars (DMC) IDDE Janne Naukkarinen C++ 1 01-15-2004 03:43 AM
Making of Makefiles dharmesh Gupta C++ 2 08-26-2003 06:54 AM



Advertisments