Results 1 to 8 of 8
Thread: creating a Makefile
- 01-17-2012, 05:19 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
creating a Makefile
Hi
I'm quite familiar with java yet but my question is still a newbie's one to me.
I'm trying to create a Makefile for a java programm.
Indeed, at the beginning, I was just using couple of .sh file to set the LD_LIBRARY_PATH, then to compile all the files with the right options, and then to execute with the right -cp.
But now, I'm working with someone that is has been using Eclipse, which means that all his files are splited among couple of directories with packages names ( I don't know if having packages will change something and require some more attention yet ... ), and I'm not familiar with that at all.
So I think that the best option would be a Makefile, but I don't really know how it works, and even though I have been reading couple of tutos on internet, noone of them is speaking about packages whatsoever, and I don't have anything that really works now.
Basically, the structure of the files is :
( -[x] is the directory "x" and -y is the file "y"
-setLDLP.sh
-compiler.sh
-launch.sh
-Makefile
-[lib]
......-lib1.so
......-lib2.so
......-jar1.jar
......-jar2.jar
-[trunk]
......-[src]
............-file1.java
............-file2.java
............-file3.java
............-file4.java
............-[abstraction]
..................-file5.java
..................-file6.java
............-[controleur]
..................-file7.java
..................-file8.java
............-[communicationUtilities]
..................-file9.java
..................-file10.java
......-[bin]
............-file1.class
............-file2.class
............-file3.class
............-file4.class
............-[abstraction]
..................-file5.class
..................-file6.class
............-[controleur]
..................-file7.class
..................-file8.class
............-[communicationUtilities]
..................-file9.class
..................-file10.class
In my old .sh, I had :
Originally Posted by setLDLP.sh
Originally Posted by compiler.sh and I was just doing :
Originally Posted by launch.sh
source ./setLDLP.sh
./compiler.sh
./launch.sh
to compile and launch the programm
Those are the .sh when I had not those new directories : "controleur", "communicationUtilities", "abstraction", and I had not to handle it.
I tried to create a makefile, but it doesn't work and I really don't know exactly how it should be.
Should I do for each file a :
"trunk/bin/fileX.class: trunk/src/fileX.java
$(JCC) $(JFLAGS) trunk/src/fileX.java"
and like
"trunk/bin/controleur/fileY.class: trunk/src/controleur/fileY.java
$(JCC) $(JFLAGS) trunk/src/controleur/fileY.java"
( where I would put "javac" in JCC and "-cp "lib/jar1.jar:lib/jar2.jar"" in JFLAGS )
??
I would like the class file to be creating in different folders like the sources files are.
I'm really getting lost there, if someone could help me, it would be really helpful.
Thanks in advanceLast edited by Fruz; 01-17-2012 at 05:49 PM.
- 01-17-2012, 05:54 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: creating a Makefile
Blimey, it's been over a decade since I've done a MAKE.
Have you thought of using Ant?
It's similar, but is the tool usually used for Java builds and you'll find a lot more examples for that one...
- 01-17-2012, 06:01 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: creating a Makefile
I've never been using ant
Is it a software ?
I don't really like the fact that if I were doing like most of the students, I would be a "slave-like" of Eclipse, like not being able to do anything without it and that's why I'd like to handle the compiling part of it myself, or at least some of it ( there are couple of other reasons why I don't like Eclipse too ).
I'll give ant a look a bit later today, thanks for the advice.Last edited by Fruz; 01-17-2012 at 06:04 PM.
- 01-17-2012, 06:03 PM #4
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: creating a Makefile
double post sry
( Using that double post at the end )
I tried to modify my "compiler.sh" file before trying to do the makefile.
it became that :
But with it, I have errors because it does not find the packages, like "package controleur does not exist" ( I'm nor really familiar with packages, maybe I should get use to it ... ).
Originally Posted by compiler.sh"
Maybe someone has a solution to that problem ?
Because if I can just compile it like that, I'm cool with itLast edited by Fruz; 01-17-2012 at 06:15 PM.
- 01-17-2012, 06:13 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: creating a Makefile
Apache Ant.
"
Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications.
"
So not too different in aim to 'make', but geared to Java.
- 01-17-2012, 06:24 PM #6
Re: creating a Makefile
I use ant, but you might also consider maven: Welcome to Apache Maven
"Maven can manage a project's build, reporting and documentation from a central piece of information."How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-17-2012, 06:40 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,420
- Blog Entries
- 7
- Rep Power
- 17
Re: creating a Makefile
You can't do that with Java; a.a.m.o.f. javac (the compiler) and the make utility don't like each other much because javac itself is a small make utility, i.e. if a class A references a class B in some way, then, if A is to be compiled, B is also compiled if needed; that behaviour confuses the make utility because some of its dependencies (and targets) are made up to date behind its back. The Ant tool can handle such situations.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 01-18-2012, 07:12 PM #8
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: creating a Makefile
Actually, I just forgot to use the proper -sourcepath with /trunk/src in the "compiler.sh" so that it would work
.
So the project works atm, but thanks still for your help, if I have to be in a big java project in the future, I'll think about using ant.
At least I learned 1 thing : Makefile is not something you use with java project lol =P.
Similar Threads
-
Creating and implementing class for creating a calendar object
By kumalh in forum New To JavaReplies: 9Last Post: 07-29-2011, 02:18 PM -
Help with Linux Makefile
By ruerric in forum New To JavaReplies: 36Last Post: 07-23-2010, 03:46 AM -
Creating files stopped creating...
By Dieter in forum Advanced JavaReplies: 3Last Post: 09-25-2009, 11:45 PM -
MakeFile
By divyanshu023 in forum New To JavaReplies: 1Last Post: 09-18-2009, 08:16 AM -
Help regarding makefile problem
By rams in forum NetworkingReplies: 0Last Post: 11-17-2008, 03:39 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks