snappy-java/Makefile.common

117 lines
3.4 KiB
Makefile
Executable File

TARGET:=target
SRC:=src/main/java
include $(SRC)/org/xerial/snappy/VERSION
ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
endif
JAVA := "$$JAVA_HOME/bin/java"
JAVAC := "$$JAVA_HOME/bin/javac"
JAVAH := "$$JAVA_HOME/bin/javah"
OSINFO_CLASS := org.xerial.snappy.OSInfo
OSINFO_PROG := lib/org/xerial/snappy/OSInfo.class
## building OSInfo.java
#$(info compiling OSInfo.java)
#$(shell mkdir -p lib)
#$(shell $(JAVAC) src/main/java/org/sqlite/OSInfo.java -d lib)
OS_NAME := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --os)
OS_ARCH := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --arch)
LIB_FOLDER := $(shell $(JAVA) -cp lib $(OSINFO_CLASS))
# Windows uses different path separators, because they hate me
ifeq ($(OS_NAME),Windows)
sep := ;
else
sep := :
endif
snappy := snappy-$(VERSION)
SNAPPY_SRC:=$(TARGET)/snappy-$(VERSION)
jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h)
ifneq ($(jni_md),)
jni_include := $(shell dirname "$(jni_md)")
endif
# os=Default is meant to be generic unix/linux
known_os_archs := Linux-i386 Linux-amd64 Mac-i386 Mac-x86_64 Windows-x86 Windows-amd64
os_arch := $(OS_NAME)-$(OS_ARCH)
ifeq (,$(findstring $(strip $(os_arch)),$(known_os_archs)))
os_arch := Default
endif
Default_CXX := g++
Default_STRIP := strip
Default_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC
Default_LINKFLAGS := -shared -static
Default_LIBNAME := libsnappy.so
Default_SNAPPY_FLAGS :=
Linux-i386_CXX := g++
Linux-i386_STRIP := strip
Linux-i386_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC
Linux-i386_LINKFLAGS := -shared -static
Linux-i386_LIBNAME := libsnappy.so
Linux-i386_SNAPPY_FLAGS:=
Linux-amd64_CXX := g++
Linux-amd64_STRIP := strip
Linux-amd64_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC
Linux-amd64_LINKFLAGS := -shared -static
Linux-amd64_LIBNAME := libsnappy.so
Linux-amd64_SNAPPY_FLAGS :=
Mac-i386_CXX := g++ -arch $(OS_ARCH)
Mac-i386_STRIP := strip -x
Mac-i386_CXXFLAGS := -I$(JAVA_HOME)/include -O2 -fPIC
Mac-i386_LINKFLAGS := -dynamiclib -static
Mac-i386_LIBNAME := libsnappy.jnilib
Mac-i386_SNAPPY_FLAGS :=
Mac-x86_64_CXX := g++ -arch $(OS_ARCH)
Mac-x86_64_STRIP := strip -x
Mac-x86_64_CXXFLAGS := -I$(JAVA_HOME)/include -O2 -fPIC
Mac-x86_64_LINKFLAGS := -dynamiclib -static
Mac-x86_64_LIBNAME := libsnappy.jnilib
Mac-x86_64_SNAPPY_FLAGS :=
Windows-x86_CXX := mingw32-g++
Windows-x86_STRIP := strip
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_LIBNAME := snappy.dll
Windows-x86_SNAPPY_FLAGS :=
Windows-amd64_CXX := x86_64-w64-mingw32-g++
Windows-amd64_STRIP := x86_64-w64-mingw32-strip
#Windows-amd64_CXX := i686-w64-mingw32-g++
#Windows-amd64_STRIP := i686-w64-mingw32-strip
Windows-amd64_CXXFLAGS := -Ilib/inc_win -O2
Windows-amd64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-amd64_LIBNAME := snappy.dll
Windows-amd64_SNAPPY_FLAGS :=
CXX := $($(os_arch)_CXX)
STRIP := $($(os_arch)_STRIP)
CXXFLAGS := $($(os_arch)_CXXFLAGS)
LINKFLAGS := $($(os_arch)_LINKFLAGS)
LIBNAME := $($(os_arch)_LIBNAME)
SNAPPY_FLAGS := $($(os_arch)_SNAPPY_FLAGS)
SNAPPY_OUT:=$(TARGET)/$(snappy)-$(os_arch)
CXXFLAGS := $(CXXFLAGS) -Ilib/include -I$(SNAPPY_OUT) -I$(SNAPPY_SRC)
ifneq ($(jni_include),)
CXXFLAGS := $(CXXFLAGS) -I"$(jni_include)"
endif