forked from GitHub/gf-core
support cross-compilation from Linux to Windows
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
INSTALL_PATH = /usr/local
|
||||
|
||||
C_SOURCES = jpgf.c jsg.c jni_utils.c
|
||||
JAVA_SOURCES = $(wildcard org/grammaticalframework/pgf/*.java) \
|
||||
$(wildcard org/grammaticalframework/sg/*.java)
|
||||
@@ -8,23 +10,28 @@ JNI_INCLUDES = $(if $(wildcard /usr/lib/jvm/default-java/include/.*), -I/usr/lib
|
||||
$(if $(wildcard /Library/Java/Home/include/.*), -I/Library/Java/Home/include/ -I/Library/Java/Home/include/darwin, \
|
||||
$(error No JNI headers found)))))
|
||||
|
||||
# For Windows replace the previous line with something like this:
|
||||
# For compilation on Windows replace the previous line with something like this:
|
||||
#
|
||||
# JNI_INCLUDES = -I "C:/Program Files/Java/jdk1.8.0_171/include" -I "C:/Program Files/Java/jdk1.8.0_171/include/win32" -I "C:/MinGW/msys/1.0/local/include"
|
||||
# WINDOWS_FLAGS = -L"C:/MinGW/msys/1.0/local/lib" -no-undefined
|
||||
# WINDOWS_LDFLAGS = -L"C:/MinGW/msys/1.0/local/lib" -no-undefined
|
||||
|
||||
INSTALL_PATH = /usr/local/lib
|
||||
LIBTOOL = glibtool --tag=CC
|
||||
GCC = gcc
|
||||
LIBTOOL = $(if $(shell command -v glibtool 2>/dev/null), glibtool, libtool) --tag=CC
|
||||
|
||||
LIBTOOL = $(if $(shell command -v glibtool 2>/dev/null), glibtool --tag=CC, libtool)
|
||||
# For cross-compilation from Linux to Windows replace the previous two lines with:
|
||||
#
|
||||
# GCC = x86_64-w64-mingw32-gcc
|
||||
# LIBTOOL = ../c/libtool
|
||||
# WINDOWS_CCFLAGS = -I$(INSTALL_PATH)/include
|
||||
# WINDOWS_LDFLAGS = -L$(INSTALL_PATH)/lib -no-undefined
|
||||
|
||||
all: libjpgf.la jpgf.jar
|
||||
|
||||
libjpgf.la: $(patsubst %.c, %.lo, $(C_SOURCES))
|
||||
$(LIBTOOL) --mode=link gcc $(CFLAGS) -g -O -o libjpgf.la -shared $^ -rpath $(INSTALL_PATH) -lgu -lpgf -lsg $(WINDOWS_FLAGS)
|
||||
$(LIBTOOL) --mode=link $(GCC) $(CFLAGS) -g -O -o libjpgf.la -shared $^ -rpath $(INSTALL_PATH)/lib -lgu -lpgf -lsg $(WINDOWS_LDFLAGS)
|
||||
|
||||
%.lo : %.c
|
||||
$(LIBTOOL) --mode=compile gcc $(CFLAGS) -g -O -c $(JNI_INCLUDES) -std=c99 -shared $< -o $@
|
||||
$(LIBTOOL) --mode=compile $(GCC) $(CFLAGS) -g -O -c $(JNI_INCLUDES) $(WINDOWS_CCFLAGS) -std=c99 -shared $< -o $@
|
||||
|
||||
jpgf.jar: $(patsubst %.java, %.class, $(JAVA_SOURCES))
|
||||
jar -cf $@ org/grammaticalframework/pgf/*.class org/grammaticalframework/sg/*.class
|
||||
@@ -33,8 +40,8 @@ jpgf.jar: $(patsubst %.java, %.class, $(JAVA_SOURCES))
|
||||
javac $<
|
||||
|
||||
install: libjpgf.la jpgf.jar
|
||||
$(LIBTOOL) --mode=install install -s libjpgf.la $(INSTALL_PATH)
|
||||
install jpgf.jar $(INSTALL_PATH)
|
||||
$(LIBTOOL) --mode=install install -s libjpgf.la $(INSTALL_PATH)/lib
|
||||
install jpgf.jar $(INSTALL_PATH)/lib
|
||||
|
||||
|
||||
doc:
|
||||
|
||||
Reference in New Issue
Block a user