165 lines
5.9 KiB
Makefile
Executable File
165 lines
5.9 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/xerial/snappy/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
|
|
ifeq ($(OS_NAME),Windows)
|
|
sep := ;
|
|
else
|
|
sep := :
|
|
endif
|
|
|
|
snappy := snappy-$(VERSION)
|
|
|
|
|
|
jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h | head -1)
|
|
ifneq ($(jni_md),)
|
|
jni_include := $(shell dirname "$(jni_md)")
|
|
endif
|
|
|
|
|
|
# os=Default is meant to be generic unix/linux
|
|
|
|
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armhf Mac-x86 Mac-x86_64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-x86 SunOS-sparc SunOS-x86_64
|
|
os_arch := $(OS_NAME)-$(OS_ARCH)
|
|
|
|
ifeq (,$(findstring $(strip $(os_arch)),$(known_os_archs)))
|
|
os_arch := Default
|
|
endif
|
|
|
|
# cross-compilation toolchain prefix (e.g. "arm-linux-gnueabi-")
|
|
CROSS_PREFIX :=
|
|
|
|
Default_CXX := $(CROSS_PREFIX)g++
|
|
Default_STRIP := $(CROSS_PREFIX)strip
|
|
Default_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
|
|
Default_LINKFLAGS := -shared -static
|
|
Default_LIBNAME := libsnappyjava.so
|
|
Default_SNAPPY_FLAGS :=
|
|
|
|
Linux-x86_CXX := $(CROSS_PREFIX)g++
|
|
Linux-x86_STRIP := $(CROSS_PREFIX)strip
|
|
Linux-x86_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m32
|
|
Linux-x86_LINKFLAGS := -shared -static-libgcc -static-libstdc++
|
|
Linux-x86_LIBNAME := libsnappyjava.so
|
|
Linux-x86_SNAPPY_FLAGS:=
|
|
|
|
Linux-x86_64_CXX := $(CROSS_PREFIX)g++
|
|
Linux-x86_64_STRIP := $(CROSS_PREFIX)strip
|
|
Linux-x86_64_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64
|
|
Linux-x86_64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
|
|
Linux-x86_64_LIBNAME := libsnappyjava.so
|
|
Linux-x86_64_SNAPPY_FLAGS :=
|
|
|
|
SunOS-x86_CXX := g++
|
|
SunOS-x86_STRIP := strip
|
|
SunOS-x86_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden
|
|
SunOS-x86_LINKFLAGS := -shared -static-libgcc -static-libstdc++
|
|
SunOS-x86_LIBNAME := libsnappyjava.so
|
|
SunOS-x86_SNAPPY_FLAGS :=
|
|
|
|
SunOS-sparc_CXX := g++
|
|
SunOS-sparc_STRIP := strip
|
|
SunOS-sparc_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden
|
|
SunOS-sparc_LINKFLAGS := -shared -static-libgcc -static-libstdc++
|
|
SunOS-sparc_LIBNAME := libsnappyjava.so
|
|
SunOS-sparc_SNAPPY_FLAGS :=
|
|
|
|
SunOS-x86_64_CXX := g++
|
|
SunOS-x86_64_STRIP := strip
|
|
SunOS-x86_64_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64
|
|
SunOS-x86_64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
|
|
SunOS-x86_64_LIBNAME := libsnappyjava.so
|
|
SunOS-x86_64_SNAPPY_FLAGS :=
|
|
|
|
# '-include lib/inc_linux/jni_md.h' is used to force the use of our version,
|
|
# which defines JNIEXPORT differently; otherwise, since OpenJDK includes
|
|
# jni_md.h in same directory as jni.h, the include path is ignored when
|
|
# jni_md.h is included from jni.h
|
|
|
|
Linux-arm_CXX := $(CROSS_PREFIX)g++
|
|
Linux-arm_STRIP := $(CROSS_PREFIX)strip
|
|
Linux-arm_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=softfp
|
|
Linux-arm_LINKFLAGS := -shared -static-libgcc
|
|
Linux-arm_LIBNAME := libsnappyjava.so
|
|
Linux-arm_SNAPPY_FLAGS:=
|
|
|
|
Linux-armhf_CXX := $(CROSS_PREFIX)g++
|
|
Linux-armhf_STRIP := $(CROSS_PREFIX)strip
|
|
Linux-armhf_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=hard
|
|
Linux-armhf_LINKFLAGS := -shared -static-libgcc
|
|
Linux-armhf_LIBNAME := libsnappyjava.so
|
|
Linux-armhf_SNAPPY_FLAGS:=
|
|
|
|
Mac-x86_CXX := g++ -arch i386
|
|
Mac-x86_STRIP := strip -x
|
|
Mac-x86_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden
|
|
Mac-x86_LINKFLAGS := -dynamiclib -static-libgcc
|
|
Mac-x86_LIBNAME := libsnappyjava.jnilib
|
|
Mac-x86_SNAPPY_FLAGS :=
|
|
|
|
Mac-x86_64_CXX := g++ -arch $(OS_ARCH)
|
|
Mac-x86_64_STRIP := strip -x
|
|
Mac-x86_64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5 -fvisibility=hidden
|
|
Mac-x86_64_LINKFLAGS := -dynamiclib -static-libgcc
|
|
Mac-x86_64_LIBNAME := libsnappyjava.jnilib
|
|
Mac-x86_64_SNAPPY_FLAGS :=
|
|
|
|
FreeBSD-x86_64_CXX := $(CROSS_PREFIX)g++
|
|
FreeBSD-x86_64_STRIP := $(CROSS_PREFIX)strip
|
|
FreeBSD-x86_64_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
|
|
FreeBSD-x86_64_LINKFLAGS := -shared -static-libgcc
|
|
FreeBSD-x86_64_LIBNAME := libsnappyjava.so
|
|
FreeBSD-x86_64_SNAPPY_FLAGS :=
|
|
|
|
Windows-x86_CXX := $(CROSS_PREFIX)g++
|
|
Windows-x86_STRIP := $(CROSS_PREFIX)strip
|
|
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2
|
|
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static
|
|
Windows-x86_LIBNAME := snappyjava.dll
|
|
Windows-x86_SNAPPY_FLAGS :=
|
|
|
|
Windows-x86_64_CXX := $(CROSS_PREFIX)g++
|
|
Windows-x86_64_STRIP := $(CROSS_PREFIX)strip
|
|
Windows-x86_64_CXXFLAGS := -Ilib/inc_win -O2
|
|
Windows-x86_64_LINKFLAGS := -Wl,--kill-at -shared -static
|
|
Windows-x86_64_LIBNAME := snappyjava.dll
|
|
Windows-x86_64_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)
|
|
|
|
|
|
|
|
CXXFLAGS := $(CXXFLAGS) -Ilib/include
|
|
ifneq ($(jni_include),)
|
|
CXXFLAGS := $(CXXFLAGS) -I"$(jni_include)"
|
|
endif
|
|
|