From fafdac516a0eed68f31ede54b62689eceb7c6c94 Mon Sep 17 00:00:00 2001 From: Chris Eagle Date: Tue, 25 Aug 2015 11:41:14 -0700 Subject: [PATCH] Make a bad Makefile slightly less bad --- bindings/java/Makefile | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/bindings/java/Makefile b/bindings/java/Makefile index c3cf8b44..94fcfee6 100755 --- a/bindings/java/Makefile +++ b/bindings/java/Makefile @@ -7,6 +7,17 @@ JAVA_PLATFORM_INC := $(shell dirname `find $(JAVA_INC) -name jni_md.h`) UNICORN_INC=../../include SAMPLES := $(shell ls samples/*.java) +SRC := $(shell ls unicorn/*.java) + +OS := $(shell uname) +ifeq ($(OS),Darwin) + LIB_EXT=.dylib +endif +ifeq ($(OS),Linux) + LIB_EXT=.so +else + LIB_EXT=.dll +endif CC=gcc CFLAGS=-fPIC @@ -38,16 +49,17 @@ unicorn_Unicorn.h: unicorn/Unicorn.java unicorn_Unicorn.o: unicorn_Unicorn.c unicorn_Unicorn.h $(CC) -c $(CFLAGS) $(INCS) $< -o $@ -libunicorn_java.so: unicorn_Unicorn.o +libunicorn_java$(LIB_EXT): unicorn_Unicorn.o -lib: libunicorn_java.so unicorn_Unicorn.h +lib: libunicorn_java$(LIB_EXT) unicorn_Unicorn.h $(CC) -o $< $(LDFLAGS) $(OBJS) $(LIBDIR) $(LIBS) samples: $(SAMPLES:.java=.class) +jarfiles: $(SRC:.java=.class) -jar: unicorn/Unicorn.class +jar: jarfiles jar cf $(JARFILE) unicorn/*.class install: lib jar - cp -a libunicorn_java.so /usr/local/lib - cp -a $(JARFILE) $(JAVA_HOME)/lib/ext + cp libunicorn_java$(LIB_EXT) $(JAVA_HOME)/lib/ext + cp $(JARFILE) $(JAVA_HOME)/lib/ext