2012-09-28 04:56:32 +02:00
|
|
|
|
|
|
|
include Makefile.common
|
|
|
|
|
|
|
|
MVN:=mvn
|
2014-06-26 07:12:03 +02:00
|
|
|
SBT:=./sbt
|
2012-09-28 04:56:32 +02:00
|
|
|
|
|
|
|
all: snappy
|
|
|
|
|
2017-01-19 18:53:27 +01:00
|
|
|
SNAPPY_OUT:=$(TARGET)/snappy-$(SNAPPY_VERSION)-$(os_arch)
|
2016-04-01 02:33:17 +02:00
|
|
|
SNAPPY_ARCHIVE:=$(TARGET)/snappy-$(SNAPPY_VERSION).tar.gz
|
2012-09-28 04:56:32 +02:00
|
|
|
SNAPPY_CC:=snappy-sinksource.cc snappy-stubs-internal.cc snappy.cc
|
2016-04-01 02:33:17 +02:00
|
|
|
SNAPPY_SRC_DIR:=$(TARGET)/snappy-$(SNAPPY_VERSION)
|
2012-09-28 04:56:32 +02:00
|
|
|
SNAPPY_SRC:=$(addprefix $(SNAPPY_SRC_DIR)/,$(SNAPPY_CC))
|
2016-03-31 07:49:43 +02:00
|
|
|
SNAPPY_GIT_REPO_URL:=https://github.com/google/snappy
|
2017-11-14 09:18:27 +01:00
|
|
|
SNAPPY_GIT_REV:=b02bfa754ebf27921d8da3bd2517eab445b84ff9 # 1.1.7
|
2016-03-29 16:14:33 +02:00
|
|
|
SNAPPY_UNPACKED:=$(TARGET)/snappy-extracted.log
|
|
|
|
SNAPPY_GIT_UNPACKED:=$(TARGET)/snappy-git-extracted.log
|
2017-11-15 21:16:41 +01:00
|
|
|
SNAPPY_CMAKE_CACHE=$(SNAPPY_OUT)/CMakeCache.txt
|
2016-03-29 16:14:33 +02:00
|
|
|
|
2016-03-31 04:43:05 +02:00
|
|
|
BITSHUFFLE_ARCHIVE:=$(TARGET)/bitshuffle-$(BITSHUFFLE_VERSION).tar.gz
|
|
|
|
BITSHUFFLE_C:=bitshuffle_core.c iochain.c
|
|
|
|
BITSHUFFLE_SRC_DIR:=$(TARGET)/bitshuffle-$(BITSHUFFLE_VERSION)/src
|
|
|
|
BITSHUFFLE_SRC:=$(addprefix $(BITSHUFFLE_SRC_DIR)/,$(BITSHUFFLE_C))
|
|
|
|
BITSHUFFLE_UNPACKED:=$(TARGET)/bitshuffle-extracted.log
|
2016-03-29 16:14:33 +02:00
|
|
|
|
2016-03-31 04:43:05 +02:00
|
|
|
$(BITSHUFFLE_ARCHIVE):
|
2016-03-29 16:14:33 +02:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
curl -L -o$@ https://github.com/kiyo-masui/bitshuffle/archive/$(BITSHUFFLE_VERSION).tar.gz
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2016-03-31 04:43:05 +02:00
|
|
|
$(BITSHUFFLE_UNPACKED): $(BITSHUFFLE_ARCHIVE)
|
2016-03-29 16:14:33 +02:00
|
|
|
$(TAR) xvfz $< -C $(TARGET)
|
|
|
|
touch $@
|
|
|
|
|
2016-03-31 04:43:05 +02:00
|
|
|
$(BITSHUFFLE_SRC): $(BITSHUFFLE_UNPACKED)
|
2016-03-29 16:14:33 +02:00
|
|
|
|
2016-04-01 02:18:03 +02:00
|
|
|
$(SNAPPY_OUT)/%.o: $(BITSHUFFLE_SRC_DIR)/%.c
|
2016-03-29 16:14:33 +02:00
|
|
|
@mkdir -p $(@D)
|
2016-04-14 06:41:11 +02:00
|
|
|
$(CXX) $(CXXFLAGS) $(CXXFLAGS_BITSHUFFLE) -c $< -o $@
|
2016-03-29 16:14:33 +02:00
|
|
|
|
2016-04-01 02:11:50 +02:00
|
|
|
SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/,$(patsubst %.cc,%.o,$(SNAPPY_CC)) $(patsubst %.c,%.o,$(BITSHUFFLE_C)) SnappyNative.o BitShuffleNative.o)
|
2016-03-29 16:14:33 +02:00
|
|
|
|
2017-11-16 18:02:46 +01:00
|
|
|
CXXFLAGS:=$(CXXFLAGS) -I$(SNAPPY_SRC_DIR) -I$(SNAPPY_OUT) -I$(BITSHUFFLE_SRC_DIR)
|
2016-04-14 06:41:11 +02:00
|
|
|
|
|
|
|
ifndef CXXFLAGS_BITSHUFFLE
|
|
|
|
ifeq ($(OS_NAME)-$(OS_ARCH),Linux-x86_64)
|
|
|
|
# SSE2 is supported in all the x86_64 platforms and AVX2 is only supported
|
|
|
|
# in the small part of them. gcc in linux/x86_64 typically enables SSE2 by default though,
|
|
|
|
# we explicitly set flags below to make this precondition clearer.
|
|
|
|
CXXFLAGS_BITSHUFFLE:=-U__AVX2__ -msse2
|
|
|
|
else
|
|
|
|
# Undefined macros to generate a platform-independent binary
|
|
|
|
CXXFLAGS_BITSHUFFLE:=-U__AVX2__ -U__SSE2__
|
|
|
|
endif
|
2016-03-31 06:09:26 +02:00
|
|
|
endif
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2013-08-13 16:49:22 +02:00
|
|
|
ifeq ($(OS_NAME),SunOS)
|
|
|
|
TAR:= gtar
|
2017-02-13 16:34:26 +01:00
|
|
|
else
|
|
|
|
ifeq ($(OS_NAME),AIX)
|
|
|
|
TAR:= gtar
|
2013-08-13 16:49:22 +02:00
|
|
|
else
|
|
|
|
TAR:= tar
|
|
|
|
endif
|
2017-02-13 16:34:26 +01:00
|
|
|
endif
|
2013-08-13 16:49:22 +02:00
|
|
|
|
2012-09-28 04:56:32 +02:00
|
|
|
$(SNAPPY_ARCHIVE):
|
|
|
|
@mkdir -p $(@D)
|
2016-04-01 02:33:17 +02:00
|
|
|
curl -L -o$@ https://github.com/google/snappy/releases/download/$(SNAPPY_VERSION)/snappy-$(SNAPPY_VERSION).tar.gz
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2016-03-29 16:14:33 +02:00
|
|
|
$(SNAPPY_UNPACKED): $(SNAPPY_ARCHIVE)
|
|
|
|
$(TAR) xvfz $< -C $(TARGET)
|
|
|
|
touch $@
|
|
|
|
|
2014-06-18 03:15:52 +02:00
|
|
|
$(SNAPPY_GIT_UNPACKED):
|
2017-11-15 21:31:07 +01:00
|
|
|
@mkdir -p $(SNAPPY_OUT)
|
2016-03-31 07:49:43 +02:00
|
|
|
rm -rf $(SNAPPY_SRC_DIR)
|
2014-06-18 03:15:52 +02:00
|
|
|
@mkdir -p $(SNAPPY_SRC_DIR)
|
2016-03-31 07:49:43 +02:00
|
|
|
git clone $(SNAPPY_GIT_REPO_URL) $(SNAPPY_SRC_DIR)
|
2017-01-19 18:53:27 +01:00
|
|
|
git --git-dir=$(SNAPPY_SRC_DIR)/.git --work-tree=$(SNAPPY_SRC_DIR) checkout -b local/snappy-$(SNAPPY_VERSION) $(SNAPPY_GIT_REV)
|
|
|
|
touch $@
|
|
|
|
|
2017-11-15 21:16:41 +01:00
|
|
|
$(SNAPPY_CMAKE_CACHE): $(SNAPPY_GIT_UNPACKED)
|
|
|
|
@mkdir -p $(SNAPPY_OUT)
|
2017-11-16 04:08:47 +01:00
|
|
|
cd $(SNAPPY_OUT) && cmake $(SNAPPY_CMAKE_OPTS) ../../$(SNAPPY_SRC_DIR)
|
2014-06-18 03:15:52 +02:00
|
|
|
touch $@
|
|
|
|
|
2017-11-15 21:31:07 +01:00
|
|
|
jni-header: $(SNAPPY_GIT_UNPACKED) $(BITSHUFFLE_UNPACKED) $(SRC)/org/xerial/snappy/SnappyNative.h $(SRC)/org/xerial/snappy/BitShuffleNative.h
|
|
|
|
|
|
|
|
snappy-header: $(SNAPPY_CMAKE_CACHE)
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2016-04-01 02:18:03 +02:00
|
|
|
$(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class: $(SRC)/org/xerial/snappy/SnappyNative.java
|
2014-06-26 07:33:54 +02:00
|
|
|
@mkdir -p $(TARGET)/jni-classes
|
2017-01-20 07:25:56 +01:00
|
|
|
$(JAVAC) -source 1.7 -target 1.7 -d $(TARGET)/jni-classes -sourcepath $(SRC) $<
|
2013-04-10 03:33:28 +02:00
|
|
|
|
2014-06-26 07:33:54 +02:00
|
|
|
$(SRC)/org/xerial/snappy/SnappyNative.h: $(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class
|
2014-07-07 21:51:27 +02:00
|
|
|
$(JAVAH) -force -classpath $(TARGET)/jni-classes -o $@ org.xerial.snappy.SnappyNative
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2016-04-01 02:18:03 +02:00
|
|
|
$(TARGET)/jni-classes/org/xerial/snappy/BitShuffleNative.class: $(SRC)/org/xerial/snappy/BitShuffleNative.java
|
2016-03-31 04:43:05 +02:00
|
|
|
@mkdir -p $(TARGET)/jni-classes
|
2017-01-20 07:25:56 +01:00
|
|
|
$(JAVAC) -source 1.7 -target 1.7 -d $(TARGET)/jni-classes -sourcepath $(SRC) $<
|
2016-03-31 04:43:05 +02:00
|
|
|
|
|
|
|
$(SRC)/org/xerial/snappy/BitShuffleNative.h: $(TARGET)/jni-classes/org/xerial/snappy/BitShuffleNative.class
|
|
|
|
$(JAVAH) -force -classpath $(TARGET)/jni-classes -o $@ org.xerial.snappy.BitShuffleNative
|
|
|
|
|
2017-01-25 15:35:18 +01:00
|
|
|
$(SNAPPY_SRC): $(SNAPPY_GIT_UNPACKED)
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-11-16 04:08:47 +01:00
|
|
|
# aarch64 can use big-endian optimzied code
|
|
|
|
ifeq ($(OS_ARCH),aarch64)
|
|
|
|
SNAPPY_CXX_OPTS:=-DSNAPPY_IS_BIG_ENDIAN
|
|
|
|
endif
|
|
|
|
|
2016-04-01 02:18:03 +02:00
|
|
|
$(SNAPPY_OUT)/%.o: $(SNAPPY_SRC_DIR)/%.cc
|
2012-09-28 04:56:32 +02:00
|
|
|
@mkdir -p $(@D)
|
2017-11-15 21:16:41 +01:00
|
|
|
$(CXX) $(SNAPPY_CXX_OPTS) $(CXXFLAGS) -c $< -o $@
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2016-04-01 02:11:50 +02:00
|
|
|
$(SNAPPY_OUT)/SnappyNative.o: $(SRC)/org/xerial/snappy/SnappyNative.cpp $(SRC)/org/xerial/snappy/SnappyNative.h
|
|
|
|
@mkdir -p $(@D)
|
2017-11-15 21:16:41 +01:00
|
|
|
$(CXX) $(SNAPPY_CXX_OPTS) $(CXXFLAGS) -c $< -o $@
|
2016-04-01 02:11:50 +02:00
|
|
|
|
|
|
|
$(SNAPPY_OUT)/BitShuffleNative.o: $(SRC)/org/xerial/snappy/BitShuffleNative.cpp $(SRC)/org/xerial/snappy/BitShuffleNative.h
|
2012-09-28 04:56:32 +02:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
$(SNAPPY_OUT)/$(LIBNAME): $(SNAPPY_OBJ)
|
2016-03-29 16:14:33 +02:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $+ $(LINKFLAGS)
|
2017-01-19 19:22:36 +01:00
|
|
|
# Workaround for strip Protocol error when using VirtualBox on Mac
|
|
|
|
cp $@ /tmp/$(@F)
|
|
|
|
$(STRIP) /tmp/$(@F)
|
|
|
|
cp /tmp/$(@F) $@
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2016-03-29 16:14:33 +02:00
|
|
|
clean-native:
|
2012-09-28 04:56:32 +02:00
|
|
|
rm -rf $(SNAPPY_OUT)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(TARGET)
|
|
|
|
|
|
|
|
NATIVE_DIR:=src/main/resources/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
|
|
|
|
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
|
|
|
|
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)
|
|
|
|
|
2014-06-26 07:12:03 +02:00
|
|
|
snappy-jar-version:=snappy-java-$(shell perl -npe "s/version in ThisBuild\s+:=\s+\"(.*)\"/\1/" version.sbt | sed -e "/^$$/d")
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-11-16 18:02:46 +01:00
|
|
|
native: jni-header snappy-header $(NATIVE_DLL)
|
2017-12-01 01:39:16 +01:00
|
|
|
native-nocmake: jni-header $(NATIVE_DLL)
|
2012-09-28 04:56:32 +02:00
|
|
|
snappy: native $(TARGET)/$(snappy-jar-version).jar
|
|
|
|
|
2017-02-15 07:26:06 +01:00
|
|
|
native-all: win32 win64 mac64 native-arm linux32 linux64 linux-ppc64le linux-aarch64
|
2017-01-19 23:28:06 +01:00
|
|
|
|
2017-11-15 21:16:41 +01:00
|
|
|
$(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME)
|
2012-09-28 04:56:32 +02:00
|
|
|
@mkdir -p $(@D)
|
2017-01-19 20:05:46 +01:00
|
|
|
cp $(SNAPPY_OUT)/$(LIBNAME) $@
|
2012-09-28 04:56:32 +02:00
|
|
|
@mkdir -p $(NATIVE_TARGET_DIR)
|
2017-01-19 20:05:46 +01:00
|
|
|
cp $(SNAPPY_OUT)/$(LIBNAME) $(NATIVE_TARGET_DIR)/$(LIBNAME)
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2014-06-26 07:33:54 +02:00
|
|
|
package: $(TARGET)/$(snappy-jar-version).jar
|
|
|
|
|
2016-03-29 16:14:33 +02:00
|
|
|
$(TARGET)/$(snappy-jar-version).jar:
|
|
|
|
$(SBT) package
|
2012-09-28 04:56:32 +02:00
|
|
|
|
|
|
|
test: $(NATIVE_DLL)
|
2014-06-26 07:12:03 +02:00
|
|
|
$(SBT) test
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-01-20 08:29:17 +01:00
|
|
|
DOCKER_RUN_OPTS:=--rm
|
2017-01-19 19:12:34 +01:00
|
|
|
|
2017-01-19 19:22:36 +01:00
|
|
|
win32: jni-header
|
2017-11-15 21:31:07 +01:00
|
|
|
./docker/dockcross-windows-x86 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native snappy-header native CROSS_PREFIX=i686-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86 SNAPPY_CMAKE_OPTS="-DHAVE_SYS_UIO_H=0"'
|
2017-01-19 19:12:34 +01:00
|
|
|
|
2017-01-19 19:22:36 +01:00
|
|
|
win64: jni-header
|
2017-11-15 21:31:07 +01:00
|
|
|
./docker/dockcross-windows-x64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native snappy-header native CROSS_PREFIX=x86_64-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86_64 SNAPPY_CMAKE_OPTS="-DHAVE_SYS_UIO_H=0"'
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
# deprecated
|
|
|
|
mac32: jni-header
|
2013-08-13 10:49:51 +02:00
|
|
|
$(MAKE) native OS_NAME=Mac OS_ARCH=x86
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
mac64: jni-header
|
|
|
|
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86_64
|
|
|
|
|
2017-01-19 23:15:59 +01:00
|
|
|
linux32: jni-header
|
2017-12-01 01:39:16 +01:00
|
|
|
docker run $(DOCKER_RUN_OPTS) -ti -v $$PWD:/work xerial/centos5-linux-x86_64-pic bash -c 'make clean-native native-nocmake OS_NAME=Linux OS_ARCH=x86'
|
2017-01-20 01:48:28 +01:00
|
|
|
|
|
|
|
linux64: jni-header
|
2017-12-01 01:39:16 +01:00
|
|
|
docker run $(DOCKER_RUN_OPTS) -ti -v $$PWD:/work xerial/centos5-linux-x86_64-pic bash -c 'make clean-native native-nocmake OS_NAME=Linux OS_ARCH=x86_64'
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2012-11-11 19:23:47 +01:00
|
|
|
freebsd64:
|
2013-08-13 10:49:51 +02:00
|
|
|
$(MAKE) native OS_NAME=FreeBSD OS_ARCH=x86_64
|
2012-11-11 19:23:47 +01:00
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
# For ARM
|
2017-01-19 20:28:50 +01:00
|
|
|
native-arm: linux-arm linux-armv6 linux-armv7 linux-android-arm
|
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
linux-arm: jni-header
|
|
|
|
./docker/dockcross-armv5 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm'
|
|
|
|
|
|
|
|
linux-armv6: jni-header
|
|
|
|
./docker/dockcross-armv6 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv6'
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
linux-armv7: jni-header
|
|
|
|
./docker/dockcross-armv7 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv7'
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
linux-android-arm: jni-header
|
|
|
|
./docker/dockcross-android-arm -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/arm-linux-androideabi/bin/arm-linux-androideabi- OS_NAME=Linux OS_ARCH=android-arm'
|
2015-01-16 23:42:17 +01:00
|
|
|
|
2017-02-14 16:46:30 +01:00
|
|
|
linux-ppc64le: jni-header
|
2017-02-14 16:48:33 +01:00
|
|
|
./docker/dockcross-ppc64le -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64le-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64le'
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2017-02-14 17:20:08 +01:00
|
|
|
linux-ppc64: jni-header
|
2017-02-15 07:26:06 +01:00
|
|
|
./docker/dockcross-ppc64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64'
|
2017-02-14 17:20:08 +01:00
|
|
|
|
2017-01-19 19:51:35 +01:00
|
|
|
linux-aarch64: jni-header
|
2017-01-19 20:14:34 +01:00
|
|
|
./docker/dockcross-aarch64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=aarch64-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64'
|
2012-09-28 04:56:32 +02:00
|
|
|
|
|
|
|
javadoc:
|
2014-06-26 07:12:03 +02:00
|
|
|
$(SBT) doc
|
2012-09-28 04:56:32 +02:00
|
|
|
|
2014-06-26 07:12:03 +02:00
|
|
|
install-m2:
|
|
|
|
$(SBT) publishM2
|