Skip to content

Instantly share code, notes, and snippets.

@hardlifeofapo
Created April 24, 2013 08:31
Show Gist options
  • Save hardlifeofapo/5450605 to your computer and use it in GitHub Desktop.
Save hardlifeofapo/5450605 to your computer and use it in GitHub Desktop.
Makefile for building Freeling Java API on Mac OS X Follow the instructions on http://hardlifeofapo.com/building-freeling-in-mac-os-x/ to build Freeling itself.
# Change these paths to match your installation
# Alternatively, you can call 'make' overriding variable values, E.g.:
# make FREELINGDIR=/my/freeling/dir SWIGDIR=/my/swig/dir JAVADIR=/my/java/dir
FREELINGDIR = /usr/local/share
SWIGDIR = /opt/local/share/swig/2.0.9/
JAVADIR = /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/
# you may change the package name if you want
PACKAGE = edu/upc/freeling
JPACKAGE = edu.upc.freeling
# Change your compiler, if necessary.
GCC=g++
# on Mac the shared libraries are called dynamic libraries and have the extension .dylib not .so
all: freeling_javaAPI.cxx libfreeling_javaAPI.dylib
.PHONY: all
# Compile the C++ API
#Do not forget to to include: /opt/local/include/
#To generate the dynamic library you should use --dynamiclib flag not -shared
libfreeling_javaAPI.dylib: freeling_javaAPI.cxx
g++ -dynamiclib /usr/local/lib/libfreeling.dylib -o libfreeling_javaAPI.dylib freeling_javaAPI.cxx -I$(FREELINGDIR)/src/include -I$(JAVADIR) -I/opt/local/include/ -fPIC
javac $(PACKAGE)/*.java
jar -cf freeling.jar $(PACKAGE)
#Build the Java JNI wrapper classes.
freeling_javaAPI.cxx: freeling_javaAPI.i ../common/freeling.i
rm -rf $(PACKAGE)
mkdir -p $(PACKAGE)
swig -c++ -java -package $(JPACKAGE) -outdir $(PACKAGE) -o freeling_javaAPI.cxx -I$(SWIGDIR)/java -I$(SWIGDIR)/std -I$(SWIGDIR) freeling_javaAPI.i
clean:
rm -rf *.jar *.dylib *.cxx *.class edu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment