re PR java/20309 (gcjh needs a -force option)

2005-05-03  Thomas Fitzsimmons  <fitzsim@redhat.com>

        PR java/20309
        * Make-lang.in (java): Add gjnih.
        (JAVA_TARGET_INDEPENDENT_BIN_TOOLS): Likewise.
        (GJNIH_OBJS): New variable.
        (gjnih$(exeext)): New target.
        (JAVA_MANFILES): Add gjnih.1.
        (java.uninstall): Add gjnih.1.
        (java.mostlyclean): Add gjnih.
        (java.maintainer-clean): Add gjnih.1.
        (java/gjavah-jni.o): New target.
        (.INTERMEDIATE): Add gjnih.pod.
        (gjnih.pod): New target.
        * config-lang.in (stagestuff): Add gjnih.
        * gcj.texi (Top): Add gjnih node.
        (Invoking gcjh): Add descriptions of -force, -old, -trace, -J and
        -bootclasspath options.
        (Invoking gjnih): New node.
        * gjavah.c Initialize flag_jni to 1 if JNI_DEFAULT is defined.
        (TOOLNAME): New macro.
        (error): Replace hard-coded gcjh with TOOLNAME.
        (process_file): Likewise.
        (usage): Likewise.
        (version): Likewise.
        (help): Likewise.  Add help output for -force, -old, -trace and -J
        options.
        (OPT_FORCE, OPT_OLD, OPT_TRACE): New macros.
        (options): Add force, old, trace and J fields.
        (main): Handle -force, -old, -trace and -J options.

From-SVN: r99206
This commit is contained in:
Thomas Fitzsimmons 2005-05-04 01:46:41 +00:00 committed by Thomas Fitzsimmons
parent fbdd0b0924
commit d8be0aabf7
5 changed files with 234 additions and 16 deletions

View File

@ -1,3 +1,34 @@
2005-05-03 Thomas Fitzsimmons <fitzsim@redhat.com>
PR java/20309
* Make-lang.in (java): Add gjnih.
(JAVA_TARGET_INDEPENDENT_BIN_TOOLS): Likewise.
(GJNIH_OBJS): New variable.
(gjnih$(exeext)): New target.
(JAVA_MANFILES): Add gjnih.1.
(java.uninstall): Add gjnih.1.
(java.mostlyclean): Add gjnih.
(java.maintainer-clean): Add gjnih.1.
(java/gjavah-jni.o): New target.
(.INTERMEDIATE): Add gjnih.pod.
(gjnih.pod): New target.
* config-lang.in (stagestuff): Add gjnih.
* gcj.texi (Top): Add gjnih node.
(Invoking gcjh): Add descriptions of -force, -old, -trace, -J and
-bootclasspath options.
(Invoking gjnih): New node.
* gjavah.c Initialize flag_jni to 1 if JNI_DEFAULT is defined.
(TOOLNAME): New macro.
(error): Replace hard-coded gcjh with TOOLNAME.
(process_file): Likewise.
(usage): Likewise.
(version): Likewise.
(help): Likewise. Add help output for -force, -old, -trace and -J
options.
(OPT_FORCE, OPT_OLD, OPT_TRACE): New macros.
(options): Add force, old, trace and J fields.
(main): Handle -force, -old, -trace and -J options.
2005-05-03 Tom Tromey <tromey@redhat.com>
PR java/21245:

View File

@ -49,11 +49,12 @@ GCJ = gcj
# Define the names for selecting java in LANGUAGES.
java: jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) \
gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext)
gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext) \
gjnih$(exeext)
# Define the name of target independent tools to be installed in $(bindir)
# Names are subject to changes
JAVA_TARGET_INDEPENDENT_BIN_TOOLS = gcjh jv-scan jcf-dump
JAVA_TARGET_INDEPENDENT_BIN_TOOLS = gcjh gjnih jv-scan jcf-dump
# Tell GNU make to ignore these if they exist.
.PHONY: java
@ -112,6 +113,10 @@ GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
java/win32-host.o java/zextract.o version.o errors.o ggc-none.o \
intl.o
GJNIH_OBJS = java/gjavah-jni.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
java/win32-host.o java/zextract.o version.o errors.o \
ggc-none.o intl.o
JVSCAN_OBJS = java/parse-scan.o java/jv-scan.o version.o intl.o
JCFDUMP_OBJS = java/jcf-dump.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
@ -138,6 +143,10 @@ gcjh$(exeext): $(GCJH_OBJS) $(LIBDEPS)
rm -f $@
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GCJH_OBJS) $(CPPLIBS) $(ZLIB) $(LIBS)
gjnih$(exeext): $(GJNIH_OBJS) $(LIBDEPS)
rm -f $@
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GJNIH_OBJS) $(CPPLIBS) $(ZLIB) $(LIBS)
jv-scan$(exeext): $(JVSCAN_OBJS) $(LIBDEPS)
rm -f $@
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVSCAN_OBJS) $(LIBICONV) $(LIBS)
@ -175,7 +184,7 @@ dvi:: doc/gcj.dvi
html:: $(htmldir)/java/index.html
JAVA_MANFILES = doc/gcj.1 doc/gcjh.1 doc/jv-scan.1 doc/jcf-dump.1 doc/gij.1 \
doc/jv-convert.1 doc/grmic.1 doc/grmiregistry.1 \
doc/gcj-dbtool.1
doc/gcj-dbtool.1 doc/gjnih.1
java.man: $(JAVA_MANFILES)
@ -231,6 +240,7 @@ java.uninstall:
-rm -rf $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext)
-rm -rf $(DESTDIR)$(man1dir)/$(JAVA_INSTALL_NAME)$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/gcjh$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/gjnih$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/jv-scan$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/jcf-dump$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/gij$(man1ext)
@ -248,13 +258,14 @@ java.mostlyclean:
-rm -f java/parse.c java/parse-scan.c
-rm -f java/*$(objext) $(DEMANGLER_PROG)
-rm -f java/*$(coverageexts)
-rm -f jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext) s-java
-rm -f jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) gcjh$(exeext) \
gjnih$(exeext) jv-scan$(exeext) jcf-dump$(exeext) s-java
java.clean:
java.distclean:
-rm -f java/config.status java/Makefile
-rm -f java/parse.output java/y.tab.c
java.maintainer-clean:
-rm -f $(docobjdir)/gcj.1 $(docobjdir)/gcjh.1
-rm -f $(docobjdir)/gcj.1 $(docobjdir)/gcjh.1 $(docobjdir)/gjnih.1
-rm -f $(docobjdir)/jv-scan.1 $(docobjdir)/jcf-dump.1
-rm -f $(docobjdir)/gij.1
-rm -f $(docobjdir)/jv-convert.1
@ -370,6 +381,14 @@ java/jcf-path.o: java/jcf-path.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
-DDEFAULT_TARGET_VERSION=\"$(version)\" \
$(srcdir)/java/jcf-path.c $(OUTPUT_OPTION)
# create gjnih's object
java/gjavah-jni.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(JAVA_TREE_H) \
java/gjavah.c java/jcf-reader.c java/jcf.h java/javaop.h version.h $(GGC_H) \
intl.h
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(ZLIBINC) \
-DJNI_DEFAULT=1 \
$(srcdir)/java/gjavah.c $(OUTPUT_OPTION)
TEXI_JAVA_FILES = java/gcj.texi $(docdir)/include/fdl.texi \
$(docdir)/include/gpl.texi $(docdir)/include/gcc-common.texi \
gcc-vers.texi
@ -390,12 +409,14 @@ $(htmldir)/java/index.html: $(TEXI_JAVA_FILES)
$(TEXI2HTML) -I $(docdir)/include -I $(srcdir)/java -o $(@D) $<
.INTERMEDIATE: gcj.pod gcjh.pod jv-scan.pod jcf-dump.pod gij.pod \
jv-convert.pod grmic.pod grmiregistry.pod gcj-dbtool.pod
jv-convert.pod grmic.pod grmiregistry.pod gcj-dbtool.pod gjnih.pod
gcj.pod: java/gcj.texi
-$(TEXI2POD) -D gcj < $< > $@
gcjh.pod: java/gcj.texi
-$(TEXI2POD) -D gcjh < $< > $@
gjnih.pod: java/gcj.texi
-$(TEXI2POD) -D gjnih < $< > $@
jv-scan.pod: java/gcj.texi
-$(TEXI2POD) -D jv-scan < $< > $@
jcf-dump.pod: java/gcj.texi

View File

@ -34,7 +34,7 @@ language="java"
compilers="jc1\$(exeext) jvgenmain\$(exeext)"
stagestuff="jc1\$(exeext) gcj\$(exeext) jvgenmain\$(exeext) gcjh\$(exeext) jv-scan\$(exeext) jcf-dump\$(exeext)"
stagestuff="jc1\$(exeext) gcj\$(exeext) jvgenmain\$(exeext) gcjh\$(exeext) gjnih\$(exeext) jv-scan\$(exeext) jcf-dump\$(exeext)"
gtfiles="\$(srcdir)/java/java-tree.h \$(srcdir)/java/jcf.h \$(srcdir)/java/lex.h \$(srcdir)/java/parse.h \$(srcdir)/java/builtins.c \$(srcdir)/java/class.c \$(srcdir)/java/constants.c \$(srcdir)/java/decl.c \$(srcdir)/java/expr.c \$(srcdir)/java/jcf-parse.c \$(srcdir)/java/jcf-write.c \$(srcdir)/java/lang.c \$(srcdir)/java/mangle.c \$(srcdir)/java/parse.y \$(srcdir)/java/resource.c"

View File

@ -59,6 +59,8 @@ man page gfdl(7).
@direntry
* gcjh: (gcj)Invoking gcjh.
Generate header files from Java class files
* gjnih: (gcj)Invoking gjnih.
Generate JNI header files from Java class files
* jv-scan: (gcj)Invoking jv-scan.
Print information about Java source files
* jcf-dump: (gcj)Invoking jcf-dump.
@ -111,6 +113,7 @@ files and object files, and it can read both Java source code and
* Invoking gcj:: Compiler options supported by @command{gcj}
* Compatibility:: Compatibility between gcj and other tools for Java
* Invoking gcjh:: Generate header files from class files
* Invoking gjnih:: Generate JNI header files from class files
* Invoking jv-scan:: Print information about source files
* Invoking jcf-dump:: Print information about class files
* Invoking gij:: Interpreting Java bytecodes
@ -145,7 +148,7 @@ gcj [@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
@var{sourcefile}@dots{}
@c man end
@c man begin SEEALSO gcj
gcc(1), gcjh(1), gij(1), jv-scan(1), jcf-dump(1), gfdl(7),
gcc(1), gcjh(1), gjnih(1), gij(1), jv-scan(1), jcf-dump(1), gfdl(7),
and the Info entries for @file{gcj} and @file{gcc}.
@c man end
@end ignore
@ -673,9 +676,11 @@ required native methods.
@ignore
@c man begin SYNOPSIS gcjh
gcjh [@option{-stubs}] [@option{-jni}]
[@option{-force}] [@option{-old}] [@option{-trace}] [@option{-J} @var{option}]
[@option{-add} @var{text}] [@option{-append} @var{text}] [@option{-friend} @var{text}]
[@option{-preprend} @var{text}]
[@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}]
[@option{--bootclasspath}=@var{path}]
[@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
[@option{-o} @var{file}] [@option{-td} @var{dir}]
[@option{-M}] [@option{-MM}] [@option{-MD}] [@option{-MMD}]
@ -701,6 +706,18 @@ By default the stub file will be named after the class, with a suffix of
This tells @code{gcjh} to generate a JNI header or stub. By default,
CNI headers are generated.
@item -force
This option forces @code{gcjh} to write the output file.
@item -old
This option is accepted but ignored for compatibility.
@item -trace
This option is accepted but ignored for compatibility.
@item -J @var{option}
This option is accepted but ignored for compatibility.
@item -add @var{text}
Inserts @var{text} into the class body. This is ignored in JNI mode.
@ -718,6 +735,7 @@ This is ignored in JNI mode.
@item --classpath=@var{path}
@itemx --CLASSPATH=@var{path}
@itemx --bootclasspath=@var{path}
@itemx -I@var{directory}
@itemx -d @var{directory}
@itemx -o @var{file}
@ -757,6 +775,120 @@ All remaining options are considered to be names of classes.
@c man end
@node Invoking gjnih
@chapter Invoking gjnih
@c man title gjnih generate JNI header files from Java class files
@c man begin DESCRIPTION gjnih
The @code{gjnih} program is used to generate JNI header files from class
files. Running it is equivalent to running @code{gcjh -jni}.
@c man end
@ignore
@c man begin SYNOPSIS gjnih
gjnih [@option{-stubs}] [@option{-jni}]
[@option{-force}] [@option{-old}] [@option{-trace}] [@option{-J} @var{option}]
[@option{-add} @var{text}] [@option{-append} @var{text}] [@option{-friend} @var{text}]
[@option{-preprend} @var{text}]
[@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}]
[@option{--bootclasspath}=@var{path}]
[@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
[@option{-o} @var{file}] [@option{-td} @var{dir}]
[@option{-M}] [@option{-MM}] [@option{-MD}] [@option{-MMD}]
[@option{--version}] [@option{--help}] [@option{-v}] [@option{--verbose}]
@var{classname}@dots{}
@c man end
@c man begin SEEALSO gjnih
gcc(1), gcj(1), gcjh(1), gij(1), jv-scan(1), jcf-dump(1), gfdl(7),
and the Info entries for @file{gcj} and @file{gcc}.
@c man end
@end ignore
@c man begin OPTIONS gjnih
@table @gcctabopt
@item -stubs
This causes @code{gjnih} to generate stub files instead of header files.
By default the stub file will be named after the class, with a suffix of
@samp{.c}.
@item -jni
This option specifies the default behavior which is to generate a JNI
header or stub.
@item -force
This option forces @code{gjnih} to write the output file.
@item -old
This option is accepted but ignored for compatibility.
@item -trace
This option is accepted but ignored for compatibility.
@item -J @var{option}
This option is accepted but ignored for compatibility.
@item -add @var{text}
Inserts @var{text} into the class body. This is ignored in by
@code{gjnih}.
@item -append @var{text}
Inserts @var{text} into the header file after the class declaration.
This is ignored in by @code{gjnih}.
@item -friend @var{text}
Inserts @var{text} into the class as a @code{friend} declaration.
This is ignored by @code{gjnih}.
@item -prepend @var{text}
Inserts @var{text} into the header file before the class declaration.
This is ignored in by @code{gjnih}.
@item --classpath=@var{path}
@itemx --CLASSPATH=@var{path}
@itemx --bootclasspath=@var{path}
@itemx -I@var{directory}
@itemx -d @var{directory}
@itemx -o @var{file}
These options are all identical to the corresponding @command{gcj} options.
@item -o @var{file}
Sets the output file name. This cannot be used if there is more than
one class on the command line.
@item -td @var{directory}
Sets the name of the directory to use for temporary files.
@item -M
Print all dependencies to stdout; suppress ordinary output.
@item -MM
Print non-system dependencies to stdout; suppress ordinary output.
@item -MD
Print all dependencies to stdout.
@item -MMD
Print non-system dependencies to stdout.
@item --help
Print help about @code{gjnih} and exit. No further processing is done.
@item --version
Print version information for @code{gjnih} and exit. No further
processing is done.
@item -v, --verbose
Print extra information while running.
@end table
All remaining options are considered to be names of classes.
@c man end
@node Invoking jv-scan
@chapter Invoking jv-scan

View File

@ -53,8 +53,16 @@ FILE *out = NULL;
/* Nonzero on failure. */
static int found_error = 0;
#ifdef JNI_DEFAULT
#define TOOLNAME "gjnih"
/* Nonzero if we're generating JNI output. */
int flag_jni = 1;
#else
#define TOOLNAME "gcjh"
int flag_jni = 0;
#endif
/* When nonzero, warn when source file is newer than matching class
file. */
@ -266,7 +274,7 @@ error (const char *msgid, ...)
va_start (ap, msgid);
fprintf (stderr, "gcjh: ");
fprintf (stderr, TOOLNAME ": ");
vfprintf (stderr, _(msgid), ap);
va_end (ap);
fprintf (stderr, "\n");
@ -2093,11 +2101,11 @@ process_file (JCF *jcf, FILE *out)
cstart, mode, cend);
else
{
fprintf (out, "%s This file was created by `gcjh -stubs%s'.%s\n\
fprintf (out, "%s This file was created by `" TOOLNAME " -stubs%s'.%s\n\
%s\n\
%s This file is intended to give you a head start on implementing native\n\
%s methods using %s.\n\
%s Be aware: running `gcjh -stubs %s' once more for this class may\n\
%s Be aware: running `" TOOLNAME " -stubs %s' once more for this class may\n\
%s overwrite any edits you have made to this file.%s\n\n",
cstart, jflag, mode,
cstart2,
@ -2299,6 +2307,9 @@ process_file (JCF *jcf, FILE *out)
#define OPT_MG LONG_OPT (12)
#define OPT_MD LONG_OPT (13)
#define OPT_MMD LONG_OPT (14)
#define OPT_FORCE LONG_OPT (15)
#define OPT_OLD LONG_OPT (16)
#define OPT_TRACE LONG_OPT (17)
static const struct option options[] =
{
@ -2321,23 +2332,33 @@ static const struct option options[] =
{ "MD", no_argument, NULL, OPT_MD },
{ "MMD", no_argument, NULL, OPT_MMD },
{ "jni", no_argument, &flag_jni, 1 },
{ "force", no_argument, NULL, OPT_FORCE },
/* If the output file should be named "ld" then a space is needed
between -o and its argument, ld. */
{ "old", no_argument, NULL, OPT_OLD },
{ "trace", no_argument, NULL, OPT_TRACE },
{ NULL, required_argument, NULL, 'J' },
{ NULL, no_argument, NULL, 0 }
};
static void
usage (void)
{
fprintf (stderr, _("Try 'gcjh --help' for more information.\n"));
fprintf (stderr, _("Try '" TOOLNAME " --help' for more information.\n"));
exit (1);
}
static void
help (void)
{
printf (_("Usage: gcjh [OPTION]... CLASS...\n\n"));
printf (_("Generate C++ header files from .class files\n\n"));
printf (_("Usage: " TOOLNAME " [OPTION]... CLASS...\n\n"));
printf (_("Generate C or C++ header files from .class files\n\n"));
printf (_(" -stubs Generate an implementation stub file\n"));
printf (_(" -jni Generate a JNI header or stub\n"));
printf (_(" -force Always overwrite output files\n"));
printf (_(" -old Unused compatibility option\n"));
printf (_(" -trace Unused compatibility option\n"));
printf (_(" -J OPTION Unused compatibility option\n"));
printf ("\n");
printf (_(" -add TEXT Insert TEXT into class body\n"));
printf (_(" -append TEXT Insert TEXT after class declaration\n"));
@ -2372,7 +2393,7 @@ help (void)
static void
version (void)
{
printf ("gcjh (GCC) %s\n\n", version_string);
printf (TOOLNAME " (GCC) %s\n\n", version_string);
printf ("Copyright %s 2004 Free Software Foundation, Inc.\n", _("(C)"));
printf (_("This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"));
@ -2404,7 +2425,7 @@ main (int argc, char** argv)
/* We use getopt_long_only to allow single `-' long options. For
some of our options this is more natural. */
while ((opt = getopt_long_only (argc, argv, "I:d:o:v", options, NULL)) != -1)
while ((opt = getopt_long_only (argc, argv, "J:I:d:o:v", options, NULL)) != -1)
{
switch (opt)
{
@ -2502,6 +2523,19 @@ main (int argc, char** argv)
jcf_dependency_init (0);
break;
case OPT_FORCE:
break;
case OPT_OLD:
break;
case OPT_TRACE:
break;
case 'J':
/* Ignore -J options. */
break;
default:
usage ();
break;