Makefiles for JAVA

Discussion in 'Java' started by sasquatch, Nov 8, 2003.

  1. sasquatch

    sasquatch Guest

    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
     
    sasquatch, Nov 8, 2003
    #1
    1. Advertising

  2. sasquatch

    Harald Hein Guest

    "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.
     
    Harald Hein, Nov 8, 2003
    #2
    1. Advertising

  3. 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
     
    Thomas Kellerer, Nov 8, 2003
    #3
  4. sasquatch

    Dale King Guest

    "Harald Hein" <> 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
     
    Dale King, Nov 10, 2003
    #4
  5. sasquatch

    Dave Monroe Guest

    Harald Hein <> 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
     
    Dave Monroe, Nov 11, 2003
    #5
  6. sasquatch

    Dale King Guest

    "Dave Monroe" <> wrote in message
    news:...
    > Harald Hein <> 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
     
    Dale King, Nov 12, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harris L

    Ant vs Makefiles

    Harris L, Nov 26, 2004, in forum: Java
    Replies:
    20
    Views:
    10,775
    Jacob
    Dec 2, 2004
  2. dharmesh Gupta

    Making of Makefiles

    dharmesh Gupta, Aug 26, 2003, in forum: C++
    Replies:
    2
    Views:
    344
    Kevin Goodsell
    Aug 26, 2003
  3. Janne Naukkarinen
    Replies:
    1
    Views:
    375
    Jack Klein
    Jan 15, 2004
  4. db
    Replies:
    2
    Views:
    435
  5. Max

    Help on makefiles

    Max, Sep 26, 2004, in forum: C++
    Replies:
    12
    Views:
    1,958
    Phlip
    Sep 27, 2004
Loading...

Share This Page