[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating jar file using autotools
From: |
Stefano Lattarini |
Subject: |
Re: Creating jar file using autotools |
Date: |
Fri, 25 Nov 2011 16:45:38 +0100 |
User-agent: |
KMail/1.13.7 (Linux/2.6.30-2-686; KDE/4.6.5; i686; ; ) |
On Wednesday 23 November 2011, Peter Fodrek wrote:
> Dear autotools experts,
>
> I am stranger in builtools like autotols. My practice in Unix based C and
> Java
> programming using manually created Makefiles lasts 15 years.
>
> I am able to produce both ELF binaries (from C source code and java source
> using gcj) and class files form java source codes, but I am not able to
> produce
> jar archive form class or java source files.
>
> Would anybody describe me where are my mistakes,please?
> Would anybody describe me possible solutions, please?
>
> I was unable to find out soultion except
> one at URL http://lists.gnu.org/archive/html/automake/2011-07/msg00015.html
> that does not work for me.
>
Note that the thread you are referring to is just a proposal to a new
feature that will probably be implemented in a *future* version of
automake. The autotools have currently no built-in support for building
and installing jar files, unfortunately.
Still, this message:
<http://lists.gnu.org/archive/html/automake/2011-07/msg00016.html>
refers to some code that an automake user was successfully employing
to build jar files. You might want to take a look at that.
> Thank you for any answer
>
> I look forward hearing form you
>
> Yours faithfully
>
> Peter Fodrek
>
Now, I have some remarks about your code snippets ...
>
> P.S.
> My top level
> configure.in
> file contanis
>
> AC_INIT(hello.c)
>
> PACKAGE=helloworld
> VERSION=0.1.0
> AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
>
This is obsolete usage of AC_INIT and AM_INIT_AUTOMAKE.
You should be doing something like this instead:
AC_INIT([helloworld], [0.1.0])
AM_INIT_AUTOMAKE([automake-options-here-if-needed])
> AC_PROG_CC = gcc
>
This makes no sense. I suggest you to read an introduction to the
autotools before trying to use them, since proceeding by copy & paste
will only bring you errors and pain. I had found this one very clear
and helpful when I was still new to the autotools:
<http://www.lrde.epita.fr/~adl/autotools.html>
> #INTI_REQUIRED_VERSION=1.0.7
> #PKG_CHECK_MODULES(INTI, inti-1.0 >= $INTI_REQUIRED_VERSION)
> #AC_SUBST(INTI_CFLAGS)
> #AC_SUBST(INTI_LIBS)
>
> AM_PROG_GCJ = gcj
> AC_PROG_CC = gcj
>
Again, this makes no sense.
> AC_OUTPUT(Makefile java/Makefile)
>
Old-style usage. You should prefer this today:
AC_CONFIG_FILES([Makefile java/Makefile])
AC_OUTPUT
> my top level
> Makefile.am
> file con contains
>
> bin_PROGRAMS = helloworld
> SUBDIRS = . java
>
> #AM_CFLAGS = $(INTI_CFLAGS)
>
> AM_JAVAC = javac -d .
>
AM_JAVAC is not a variable used by automake.
> helloworld_SOURCES= hello.c
>
>
> and Makaefile.am
> in the java directory contains
>
>
> #bin_PROGRAMS = helloJ.jar
> java_PROGRAMS = helloJAVA
> #jar_ARCHIVES = helloJ
>
> JARTARGET= jar
> #JARS = jar
>
> javadir = ./java
> jardir = ./java
> #_JAVA = jar
> AM_JAVAC = javac
> AM_JAR = jar
>
Again, AM_JAVAC and AM_JAR are not variables used by automake.
>
> JAVACFLAGS = -d .
>
> dist_java_JAVA = ./helloJ.java ./hello.java
>
> dist_java_JAR = ./helloJ.java ./hello.java
>
> jar_JARS = helloJ.jar
>
Unfortunately, JARS is not a primary known to automake (yet).
> #helloJ_jar_SOURCES = ./helloJ.java ./hello.java
>
>
>
> dir = java
> AC_OUTPUT= java
>
It makes no sense to use AC_OUTPUT in a Makefile.am.
> helloJAVA_SOURCES= hello.java
> helloJAVA_LDFLAGS=--main=hello
>
HTH,
Stefano