classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Add jawt build infrastructure


From: Mark Wielaard
Subject: [cp-patches] FYI: Add jawt build infrastructure
Date: Mon, 05 Sep 2005 10:30:02 +0200

Hi,

There was a little bug in our jawt example. The C code used a different
package name. And it wasn't easy to get a working example. Since the
system might come with an incompatible jawt.h and setting up the include
and library paths and flags was kind of a gamble.

This patch introduces a Makefile.jawt.in that generates an (hopefully)
easy to use Makefile.jawt for installation in our examples directory. I
didn't precompile and install this example completely because I was
afraid that would be a bit too much build machinery magic just before
the release. So this only munges the files and puts them in the right
spot for the user.

2005-09-04  Mark Wielaard  <address@hidden>

    * configure.ac (AC_CONFIG_FILES): Add examples/Makefile.jawt.
    * examples/.cvsignore: Add Makefile.jawt.
    * examples/Makefile.am (EXAMPLE_C_FILES): New variable.
    (ALL_EXAMPLE_FILES): Likewise.
    (install-data-local): Use ALL_EXAMPLE_FILES and add Makefile.jawt.
    (uninstall-local): Likewise.
    (EXTRA_DIST): Add Makefile.awt.in.
    * examples/Makefile.jawt.in: New file.
    * examples/README: Add jawt instructions.
    * examples/gnu/classpath/examples/jawt/DemoJAWT.c
    (Java_DemoJAWT_paint): Rename to
    Java_gnu_classpath_examples_jawt_DemoJAWT_paintIt.
    (Java_gnu_classpath_examples_jawt_DemoJAWT_paintIt): Flip foreground
    color based on on parameter.
    * examples/gnu/classpath/examples/jawt/DemoJAWT.java (paint): Renamed
    paintIt.
    (paint): Call paintIt.
    (on): New boolean field.
    (main): Add Frame name, switch on variable every 0.5 seconds and call
    Frame.repaint().
    * examples/gnu/classpath/examples/jawt/Makefile: Removed.
    * include/Makefile.am (include_HEADERS): New for jni.h, jni_md.h,
    jawt.h and jawt_md.h.

For no real reason it also adds some blinking to the example. Tested
against kaffe CVS and jamvm. Should work out of the box after doing:

        cd examples; make -f Makefile.jawt

Committed,

Mark

? examples/DemoJAWT.h
? examples/gnu/classpath/examples/jawt/DemoJAWT$1.class
? examples/gnu/classpath/examples/jawt/DemoJAWT.class
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.104
diff -u -r1.104 configure.ac
--- configure.ac        25 Aug 2005 13:51:56 -0000      1.104
+++ configure.ac        5 Sep 2005 08:19:58 -0000
@@ -497,6 +497,7 @@
 scripts/classpath.spec
 lib/Makefile
 lib/gen-classlist.sh
-examples/Makefile])
+examples/Makefile
+examples/Makefile.jawt])
 AC_CONFIG_COMMANDS([gen-classlist],[chmod 755 lib/gen-classlist.sh])
 AC_OUTPUT
Index: examples/.cvsignore
===================================================================
RCS file: /cvsroot/classpath/classpath/examples/.cvsignore,v
retrieving revision 1.2
diff -u -r1.2 .cvsignore
--- examples/.cvsignore 8 Oct 2004 21:47:05 -0000       1.2
+++ examples/.cvsignore 5 Sep 2005 08:19:58 -0000
@@ -1,3 +1,4 @@
 Makefile
 Makefile.in
 examples.zip
+Makefile.jawt
Index: examples/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/examples/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- examples/Makefile.am        26 Jul 2005 07:12:29 -0000      1.5
+++ examples/Makefile.am        5 Sep 2005 08:19:58 -0000
@@ -22,6 +22,9 @@
 # All our example java source files
 EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java
 
+# The example C source files
+EXAMPLE_C_FILES = $(srcdir)/gnu/classpath/examples/*/*.c
+
 # The zip files with classes we want to produce.
 EXAMPLE_ZIP = examples.zip
 
@@ -31,6 +34,9 @@
 # the png icons we use in some of the examples.
 EXAMPLE_ICONS = $(srcdir)/gnu/classpath/examples/icons/*.png
 
+# All the files we find "interesting"
+ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_ICONS)
+
 # Some architecture independent data to be installed.
 example_DATA = $(EXAMPLE_ZIP) README
 
@@ -41,7 +47,7 @@
 # (Be careful to strip off the srcdir part of the path when installing.)
 install-data-local:
        srcdir_cnt=`echo $(srcdir) | wc -c`; \
-       for file in $(EXAMPLE_JAVA_FILES) $(EXAMPLE_ICONS); do \
+       for file in $(ALL_EXAMPLE_FILES); do \
          f=`echo $$file | cut -c$$srcdir_cnt-`; \
          fdir=`dirname $$f`; \
          if test ! -d $(DESTDIR)/$(pkgdatadir)/examples/$$fdir; then \
@@ -51,20 +57,24 @@
          echo "$(INSTALL_DATA) $$file $(DESTDIR)/$(pkgdatadir)/examples/$$f"; \
          $(INSTALL_DATA) $$file $(DESTDIR)/$(pkgdatadir)/examples/$$f; \
        done
+       echo "$(INSTALL_DATA) Makefile.jawt $(DESTDIR)/$(pkgdatadir)/examples/"
+       $(INSTALL_DATA) Makefile.jawt $(DESTDIR)/$(pkgdatadir)/examples/
 
 uninstall-local:
        srcdir_cnt=`echo $(srcdir) | wc -c`; \
-       for file in $(EXAMPLE_JAVA_FILES) $(EXAMPLE_ICONS); do \
+       for file in $(ALL_EXAMPLE_FILES); do \
          f=`echo $$file | cut -c$$srcdir_cnt-`; \
          echo "rm -f $(DESTDIR)/$(pkgdatadir)/examples/$$f"; \
          rm -f $(DESTDIR)/$(pkgdatadir)/examples/$$f; \
        done
+       echo "rm -f $(DESTDIR)/$(pkgdatadir)/examples/Makefile.jawt"
+       rm -f $(DESTDIR)/$(pkgdatadir)/examples/Makefile.jawt
 
 # Make sure everything is included in the distribution.
-EXTRA_DIST = README
+EXTRA_DIST = README Makefile.jawt.in
 dist-hook:
        srcdir_cnt=`echo $(srcdir) | wc -c`; \
-       for file in $(EXAMPLE_JAVA_FILES) $(EXAMPLE_ICONS); do \
+       for file in $(ALL_EXAMPLE_FILES); do \
          f=`echo $$file | cut -c$$srcdir_cnt-`; \
          fdir=`dirname $$f`; \
          if test ! -d $(distdir)/$$fdir; then \
Index: examples/Makefile.jawt.in
===================================================================
RCS file: examples/Makefile.jawt.in
diff -N examples/Makefile.jawt.in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ examples/Makefile.jawt.in   5 Sep 2005 08:19:58 -0000
@@ -0,0 +1,29 @@
+# @configure_input@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+includedir = @includedir@
+libdir = @libdir@
+pkglibdir = $(libdir)/@PACKAGE@
+
+all: gnu/classpath/examples/jawt/DemoJAWT.class libDemoJAWT.so
+       @echo "RUN with:"
+       @echo "  LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:.:$(pkglibdir) jamvm \\"
+       @echo "    gnu.classpath.examples.jawt.DemoJAWT"
+
+gnu/classpath/examples/jawt/DemoJAWT.class: 
gnu/classpath/examples/jawt/DemoJAWT.java
+       gcj -C gnu/classpath/examples/jawt/DemoJAWT.java
+
+DemoJAWT.h: gnu/classpath/examples/jawt/DemoJAWT.class
+       gcjh -jni gnu.classpath.examples.jawt.DemoJAWT -o DemoJAWT.h
+
+libDemoJAWT.so: gnu/classpath/examples/jawt/DemoJAWT.c DemoJAWT.h
+       gcc -g -O0 -Wall -I. -I/usr/X11R6/include -L. -L/usr/X11R6/lib \
+       -I$(includedir) -L$(pkglibdir) \
+       -lX11 -ljawtgnu -shared -o libDemoJAWT.so \
+       gnu/classpath/examples/jawt/DemoJAWT.c
+
+clean:
+       rm -f DemoJAWT.h
+       rm -f gnu/classpath/examples/jawt/DemoJAWT*.class
+       rm -f libDemoJAWT.so
Index: examples/README
===================================================================
RCS file: /cvsroot/classpath/classpath/examples/README,v
retrieving revision 1.4
diff -u -r1.4 README
--- examples/README     1 Aug 2005 22:32:44 -0000       1.4
+++ examples/README     5 Sep 2005 08:19:58 -0000
@@ -23,6 +23,29 @@
   kaffe -classpath examples.zip gnu.classpath.examples.awt.Demo
   kaffe -classpath examples.zip gnu.classpath.examples.swing.Demo
 
+The jawt Demo needs some extra support library that currently needs to be
+build by hand.  The following assumes GNU Classpath was installed in
+/usr/local/classpath, if you installed it somewhere else then adjust the
+-I and -L paths accordingly. The included Makefile.jawt is setup this way.
+
+You can invoke it with:
+
+       make -f Makefile.jawt
+
+Or you can compile by hand as follows:
+
+  gcj -C gnu/classpath/examples/jawt/DemoJAWT.java
+  gcjh -jni gnu.classpath.examples.jawt.DemoJAWT -o DemoJAWT.h
+  gcc -g -O0 -Wall -I. -I/usr/X11R6/include -L. -L/usr/X11R6/lib \
+    -I/usr/local/classpath/include -L/usr/local/classpath/lib/classpath \
+    -lX11 -ljawtgnu -shared -o libDemoJAWT.so \
+    gnu/classpath/examples/jawt/DemoJAWT.c
+
+You can then run the example as follows:
+
+  export LD_LIBRARY_PATH=.:/usr/local/classpath/lib/classpath
+  jamvm gnu.classpath.examples.jawt.DemoJAWT
+
 All example code is distributed under the GNU General Public License (GPL).
 
 The example icons used in some of the examples come from gnome-icon-theme
Index: examples/gnu/classpath/examples/jawt/DemoJAWT.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/examples/gnu/classpath/examples/jawt/DemoJAWT.c,v
retrieving revision 1.1
diff -u -r1.1 DemoJAWT.c
--- examples/gnu/classpath/examples/jawt/DemoJAWT.c     12 Aug 2005 05:37:26 
-0000      1.1
+++ examples/gnu/classpath/examples/jawt/DemoJAWT.c     5 Sep 2005 08:19:58 
-0000
@@ -23,7 +23,10 @@
 #include <string.h>
 
 JNIEXPORT void JNICALL
-Java_DemoJAWT_paint (JNIEnv* env, jobject canvas, jobject graphics)
+Java_gnu_classpath_examples_jawt_DemoJAWT_paintIt (JNIEnv* env,
+                                                  jobject canvas,
+                                                  jobject graphics,
+                                                  jboolean on)
 {
   JAWT awt;
   JAWT_DrawingSurface* surface;
@@ -124,7 +127,7 @@
 
   for (c = 5; c >= 0; c--)
     {
-      if (c % 2)
+      if (c % 2 == on)
        XSetForeground (display, gc, yellow.pixel);
       else
        XSetForeground (display, gc, orange.pixel);
Index: examples/gnu/classpath/examples/jawt/DemoJAWT.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/examples/gnu/classpath/examples/jawt/DemoJAWT.java,v
retrieving revision 1.2
diff -u -r1.2 DemoJAWT.java
--- examples/gnu/classpath/examples/jawt/DemoJAWT.java  16 Aug 2005 20:15:17 
-0000      1.2
+++ examples/gnu/classpath/examples/jawt/DemoJAWT.java  5 Sep 2005 08:19:58 
-0000
@@ -30,17 +30,25 @@
     System.loadLibrary ("DemoJAWT");
   }
 
-  public native void paint (Graphics g);
+  public native void paintIt (Graphics g, boolean on);
+
+  public void paint (Graphics g)
+  {
+    paintIt (g, on);
+  }
+
+  private boolean on;
 
   public static void main (String[] args)
   {
-    Frame f = new Frame ();
+    Frame f = new Frame ("GNU Classpath JAWT Demo");
 
     f.setBounds (0, 0, 300, 300);
 
     f.setResizable (false);
 
-    f.add (new DemoJAWT ());
+    DemoJAWT jawtDemo = new DemoJAWT ();
+    f.add (jawtDemo);
 
     f.addWindowListener (new WindowAdapter ()
       {
@@ -51,5 +59,19 @@
       });
 
     f.show ();
+
+    while (true)
+    {
+      try
+       {
+         Thread.sleep (500);
+       }
+      catch (InterruptedException ie)
+       {
+         // ignored
+       }
+      jawtDemo.on = ! jawtDemo.on;
+      f.repaint();
+    }
   }
 }
Index: examples/gnu/classpath/examples/jawt/Makefile
===================================================================
RCS file: examples/gnu/classpath/examples/jawt/Makefile
diff -N examples/gnu/classpath/examples/jawt/Makefile
--- examples/gnu/classpath/examples/jawt/Makefile       12 Aug 2005 05:37:26 
-0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-all: \
-       DemoJAWT.h DemoJAWT.class libDemoJAWT.so
-
-%.class: %.java
-       gcj -C $<
-
-%.h: %.class
-       gcjh -jni $(basename $< .class)
-
-DemoJAWT: DemoJAWT.java
-       gcj -g --main=DemoJAWT -fjni -o DemoJAWT DemoJAWT.java
-
-libDemoJAWT.so: DemoJAWT.c
-       gcc -g -O0 -Wall -I. -I/usr/X11R6/include -shared -o $@ DemoJAWT.c -L. 
-ljawt -L/usr/X11R6/lib -lX11
-
-run:
-       LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:. jamvm DemoJAWT
-
-clean:
-       rm -f DemoJAWT.h DemoJAWT.class DemoJAWT\$$1.class libDemoJAWT.so
Index: include/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/include/Makefile.am,v
retrieving revision 1.47
diff -u -r1.47 Makefile.am
--- include/Makefile.am 17 Aug 2005 02:03:33 -0000      1.47
+++ include/Makefile.am 5 Sep 2005 08:19:58 -0000
@@ -1,3 +1,5 @@
+include_HEADERS = jni.h jni_md.h jawt.h jawt_md.h
+
 DISTCLEANFILES = jni_md.h
 
 ARG_JNI_JAVAH = -jni

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]