Mostly automated "make java" for Cygwin users.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 28 Jul 2007 05:10:10 +0000
changeset 65 f3800c3a248c
parent 64 1ff62390e3db
child 66 34db7431bd63
Mostly automated "make java" for Cygwin users.
Makefile
README
--- a/Makefile	Fri Jul 27 21:32:06 2007 +0000
+++ b/Makefile	Sat Jul 28 05:10:10 2007 +0000
@@ -1,14 +1,21 @@
+# Set this variable if you need to.
+WINDOWS_JDK_PATH := C:\\Program\ Files\\Java\\jdk1.6.0_02\\
 
 linux := false
 macosx := false
+cygwin := false
 
-os := $(shell uname -s)
-ifeq ($(strip $(os)),Darwin)
+uname_s := $(shell uname -s)
+uname_o := $(shell uname -o)
+ifeq ($(strip $(uname_s)),Darwin)
   macosx := true
 endif
-ifeq ($(strip $(os)),Linux)
+ifeq ($(strip $(uname_s)),Linux)
   linux := true
 endif
+ifeq ($(strip $(uname_o)),Cygwin)
+  cygwin := true
+endif
 
 CFLAGS += -O0 -Wall -g -c
 CFLAGS += -I.
@@ -26,10 +33,22 @@
   LDFLAGS += -ldl
 endif
 
+JAVAC := javac
+
 ifeq ($(strip $(linux)),true)
   CFLAGS += -I/usr/src/linux/include
 endif
 
+ifeq ($(strip $(cygwin)),true)
+  CFLAGS += -mno-cygwin
+  LDFLAGS += -mno-cygwin
+  MANYMOUSEJNILIB := ManyMouse.dll
+  JDKPATH := $(WINDOWS_JDK_PATH)
+  JAVAC := $(JDKPATH)bin\\javac
+endif
+
+
+
 BASEOBJS := linux_evdev.o macosx_hidmanager.o windows_wminput.o x11_xinput.o manymouse.o
 
 .PHONY: clean all
@@ -73,13 +92,13 @@
 java: $(MANYMOUSEJNILIB) ManyMouse.class ManyMouseEvent.class TestManyMouse.class
 
 ManyMouse.class: contrib/java/ManyMouse.java $(MANYMOUSEJNILIB)
-	javac -d . -classpath contrib/java $<
+	$(JAVAC) -d . -classpath contrib/java $<
 
 ManyMouseEvent.class: contrib/java/ManyMouseEvent.java ManyMouse.class
-	javac -d . -classpath contrib/java $<
+	$(JAVAC) -d . -classpath contrib/java $<
 
 TestManyMouse.class: contrib/java/TestManyMouse.java ManyMouse.class ManyMouseEvent.class
-	javac -d . $<
+	$(JAVAC) -d . $<
 
 
 ifeq ($(strip $(macosx)),true)
@@ -92,5 +111,17 @@
 
 endif
 
+
+ifeq ($(strip $(cygwin)),true)
+ManyMouseJava.o: contrib/java/ManyMouseJava.c
+	$(CC) $(CFLAGS) -o $@ $< -I$(JDKPATH)include -I$(JDKPATH)include\\win32
+
+$(MANYMOUSEJNILIB): $(BASEOBJS) ManyMouseJava.o
+	@mkdir -p $(dir $@)
+	$(LD) $(LDFLAGS) -o $@ $^ -Wl,--add-stdcall-alias -shared
+
+endif
+
+
 # end of Makefile ...
 
--- a/README	Fri Jul 27 21:32:06 2007 +0000
+++ b/README	Sat Jul 28 05:10:10 2007 +0000
@@ -67,8 +67,13 @@
 
   Thanks to Brian Ballsun-Stanton for kicking this into gear.
 
+  Mac OS X and Cygwin can run "make java" to build the bindings and run
+  "java TestManyMouse" to make sure they worked. Cygwin users may need to
+  adjust the WINDOWS_JDK_PATH line at the top of the Makefile to match their
+  JDK installation.
 
-Some notes:
+
+Some general ManyMouse usage notes:
  - If a mouse is disconnected, it will not return future events, even if you
    plug it right back in. You will be alerted of disconnects programmatically
    through the MANYMOUSE_EVENT_DISCONNECT event, which will be the last