Fix Makefile

This commit is contained in:
Taro L. Saito 2012-09-28 11:56:32 +09:00
parent f7e04b769f
commit 1b803c4b05
2 changed files with 212 additions and 219 deletions

260
Makefile
View File

@ -1,130 +1,130 @@
include Makefile.common
MVN:=mvn
all: snappy
SNAPPY_OUT:=$(TARGET)/$(snappy)-$(os_arch)
SNAPPY_ARCHIVE:=$(TARGET)/snappy-$(VERSION).tar.gz
SNAPPY_CC:=snappy-sinksource.cc snappy-stubs-internal.cc snappy.cc
SNAPPY_SRC_DIR:=$(TARGET)/snappy-$(VERSION)
SNAPPY_SRC:=$(addprefix $(SNAPPY_SRC_DIR)/,$(SNAPPY_CC))
SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/,$(patsubst %.cc,%.o,$(SNAPPY_CC)) SnappyNative.o)
SNAPPY_UNPACKED:=$(TARGET)/snappy-extracted.log
CXXFLAGS:=$(CXXFLAGS) -I$(SNAPPY_SRC_DIR)
$(SNAPPY_ARCHIVE):
@mkdir -p $(@D)
curl -o$@ http://snappy.googlecode.com/files/snappy-$(VERSION).tar.gz
$(SNAPPY_UNPACKED): $(SNAPPY_ARCHIVE)
tar xvfz $< -C $(TARGET)
touch $@
jni-header: $(SRC)/org/xerial/snappy/SnappyNative.h
$(SRC)/org/xerial/snappy/SnappyNative.h: $(SRC)/org/xerial/snappy/SnappyNative.java
@mkdir -p $(TARGET)/classes
$(JAVAH) -classpath $(TARGET)/classes -o $@ org.xerial.snappy.SnappyNative
bytecode: src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode
src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode: src/main/resources/org/xerial/snappy/SnappyNativeLoader.java
@mkdir -p $(TARGET)/temp
$(JAVAC) -source 1.5 -target 1.5 -d $(TARGET)/temp $<
cp $(TARGET)/temp/org/xerial/snappy/SnappyNativeLoader.class $@
$(SNAPPY_SRC): $(SNAPPY_UNPACKED)
$(SNAPPY_OUT)/%.o : $(SNAPPY_SRC_DIR)/%.cc
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/SnappyNative.o : $(SRC)/org/xerial/snappy/SnappyNative.cpp $(SRC)/org/xerial/snappy/SnappyNative.h
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/$(LIBNAME): $(SNAPPY_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $+ $(LINKFLAGS)
$(STRIP) $@
clean-native:
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)
snappy-jar-version:=snappy-java-$(shell $(JAVA) -jar lib/silk-weaver.jar find 'project(artifactId, version)' pom.xml | grep snappy-java | awk '{ print $$2; }')
native: $(SNAPPY_UNPACKED) $(NATIVE_DLL)
snappy: native $(TARGET)/$(snappy-jar-version).jar
$(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME)
@mkdir -p $(@D)
cp $< $@
@mkdir -p $(NATIVE_TARGET_DIR)
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME)
$(TARGET)/$(snappy-jar-version).jar: native $(NATIVE_DLL)
$(MVN) package -Dmaven.test.skip=true
test: $(NATIVE_DLL)
$(MVN) test
win32:
$(MAKE) native CROSS_PREFIX=i686-w64-mingw32- OS_NAME=Windows OS_ARCH=x86
# for cross-compilation on Ubuntu, install the g++-mingw-w64-x86-64 package
win64:
$(MAKE) native CROSS_PREFIX=x86_64-w64-mingw32- OS_NAME=Windows OS_ARCH=amd64
mac32:
$(MAKE) native OS_NAME=Mac OS_ARCH=i386
linux32:
$(MAKE) native OS_NAME=Linux OS_ARCH=i386
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package
linux-arm:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabihf package
linux-armhf:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armhf
clean-native-linux32:
$(MAKE) clean-native OS_NAME=Linux OS_ARCH=i386
clean-native-win32:
$(MAKE) clean-native OS_NAME=Windows OS_ARCH=x86
javadoc:
$(MVN) javadoc:javadoc -DreportOutputDirectory=wiki/apidocs
googlecode-upload: googlecode-lib-upload googlecode-src-upload
googlecode-lib-upload: $(TARGET)/snappy-java-$(VERSION)-lib.upload
googlecode-src-upload: $(TARGET)/snappy-java-$(VERSION)-src.upload
GOOGLECODE_USER:=leo@xerial.org
$(TARGET)/snappy-java-$(VERSION)-lib.upload:
./googlecode_upload.py -s "library for all platforms" -p snappy-java -l "Type-Executable,Featured,OpSys-All" -u "$(GOOGLECODE_USER)" target/snappy-java-$(VERSION).jar
touch $@
$(TARGET)/snappy-java-$(VERSION)-src.upload:
./googlecode_upload.py -s "source code archive" -p snappy-java -l "Type-Source,OpSys-All" -u "$(GOOGLECODE_USER)" target/snappy-java-$(VERSION).tar.gz
touch $@
include Makefile.common
MVN:=mvn
all: snappy
SNAPPY_OUT:=$(TARGET)/$(snappy)-$(os_arch)
SNAPPY_ARCHIVE:=$(TARGET)/snappy-$(VERSION).tar.gz
SNAPPY_CC:=snappy-sinksource.cc snappy-stubs-internal.cc snappy.cc
SNAPPY_SRC_DIR:=$(TARGET)/snappy-$(VERSION)
SNAPPY_SRC:=$(addprefix $(SNAPPY_SRC_DIR)/,$(SNAPPY_CC))
SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/,$(patsubst %.cc,%.o,$(SNAPPY_CC)) SnappyNative.o)
SNAPPY_UNPACKED:=$(TARGET)/snappy-extracted.log
CXXFLAGS:=$(CXXFLAGS) -I$(SNAPPY_SRC_DIR)
$(SNAPPY_ARCHIVE):
@mkdir -p $(@D)
curl -o$@ http://snappy.googlecode.com/files/snappy-$(VERSION).tar.gz
$(SNAPPY_UNPACKED): $(SNAPPY_ARCHIVE)
tar xvfz $< -C $(TARGET)
touch $@
jni-header: $(SRC)/org/xerial/snappy/SnappyNative.h
$(SRC)/org/xerial/snappy/SnappyNative.h: $(SRC)/org/xerial/snappy/SnappyNative.java
@mkdir -p $(TARGET)/classes
$(JAVAH) -classpath $(TARGET)/classes -o $@ org.xerial.snappy.SnappyNative
bytecode: src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode
src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode: src/main/resources/org/xerial/snappy/SnappyNativeLoader.java
@mkdir -p $(TARGET)/temp
$(JAVAC) -source 1.5 -target 1.5 -d $(TARGET)/temp $<
cp $(TARGET)/temp/org/xerial/snappy/SnappyNativeLoader.class $@
$(SNAPPY_SRC): $(SNAPPY_UNPACKED)
$(SNAPPY_OUT)/%.o : $(SNAPPY_SRC_DIR)/%.cc
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/SnappyNative.o : $(SRC)/org/xerial/snappy/SnappyNative.cpp $(SRC)/org/xerial/snappy/SnappyNative.h
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/$(LIBNAME): $(SNAPPY_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $+ $(LINKFLAGS)
$(STRIP) $@
clean-native:
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)
snappy-jar-version:=snappy-java-$(shell $(JAVA) -jar lib/silk-weaver.jar find 'project(artifactId, version)' pom.xml | grep snappy-java | awk '{ print $$2; }')
native: $(SNAPPY_UNPACKED) $(NATIVE_DLL)
snappy: native $(TARGET)/$(snappy-jar-version).jar
$(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME)
@mkdir -p $(@D)
cp $< $@
@mkdir -p $(NATIVE_TARGET_DIR)
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME)
$(TARGET)/$(snappy-jar-version).jar: native $(NATIVE_DLL)
$(MVN) package -Dmaven.test.skip=true
test: $(NATIVE_DLL)
$(MVN) test
win32:
$(MAKE) native CROSS_PREFIX=i686-w64-mingw32- OS_NAME=Windows OS_ARCH=x86
# for cross-compilation on Ubuntu, install the g++-mingw-w64-x86-64 package
win64:
$(MAKE) native CROSS_PREFIX=x86_64-w64-mingw32- OS_NAME=Windows OS_ARCH=amd64
mac32:
$(MAKE) native OS_NAME=Mac OS_ARCH=i386
linux32:
$(MAKE) native OS_NAME=Linux OS_ARCH=i386
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package
linux-arm:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabihf package
linux-armhf:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armhf
clean-native-linux32:
$(MAKE) clean-native OS_NAME=Linux OS_ARCH=i386
clean-native-win32:
$(MAKE) clean-native OS_NAME=Windows OS_ARCH=x86
javadoc:
$(MVN) javadoc:javadoc -DreportOutputDirectory=wiki/apidocs
googlecode-upload: googlecode-lib-upload googlecode-src-upload
googlecode-lib-upload: $(TARGET)/snappy-java-$(VERSION)-lib.upload
googlecode-src-upload: $(TARGET)/snappy-java-$(VERSION)-src.upload
GOOGLECODE_USER:=leo@xerial.org
$(TARGET)/snappy-java-$(VERSION)-lib.upload:
./googlecode_upload.py -s "library for all platforms" -p snappy-java -l "Type-Executable,Featured,OpSys-All" -u "$(GOOGLECODE_USER)" target/snappy-java-$(VERSION).jar
touch $@
$(TARGET)/snappy-java-$(VERSION)-src.upload:
./googlecode_upload.py -s "source code archive" -p snappy-java -l "Type-Source,OpSys-All" -u "$(GOOGLECODE_USER)" target/snappy-java-$(VERSION).tar.gz
touch $@

View File

@ -1,89 +1,82 @@
# Makefile for building and collecting native libraries in Win/Mac/Linux (32/64bit).
include Makefile.common
RESOURCE_DIR=src/main/resources
NATIVE_DIR=$(RESOURCE_DIR)/native
RSYNC=rsync -av -e ssh --exclude=".hg"
WORK:=work/hg/snappy-java
WIN64_SERVER=localhost
MAC_SERVER=172.16.133.41
MAC_TIGER_SERVER=172.16.133.171
AMD_SERVER=hx02
BUILD_CMD_PREFIX = hg pull -u && make clean-native && make
BUILD_CMD = $(BUILD_CMD_PREFIX) native
TEST_CMD = hg pull -u && mvn test
all: compile test
.PHONY: compile test native clean
DLL_DIR=src/main/resources/org/xerial/snappy/native
DLL_WIN=$(DLL_DIR)/Windows/x86/snappyjava.dll
DLL_WIN64=$(DLL_DIR)/Windows/amd64/snappyjava.dll
DLL_MAC=$(DLL_DIR)/Mac/x86_64/libsnappyjava.jnilib
DLL_TIGER_MAC=$(DLL_DIR)/Mac/i386/libsnappyjava.jnilib
DLL_LINUX=$(DLL_DIR)/Linux/i386/libsnappyjava.so
DLL_AMD64=$(DLL_DIR)/Linux/amd64/libsnappyjava.so
version_file:=src/main/java/org/xerial/snappy/VERSION
$(DLL_WIN): $(version_file)
ssh $(WIN64_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD_PREFIX) win32"
mkdir -p $(dir $(DLL_WIN))
$(RSYNC) $(WIN_SERVER):./$(WORK)/$(DLL_WIN) $(DLL_WIN)
$(DLL_WIN64): $(version_file)
ssh $(WIN64_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_WIN64))
$(RSYNC) $(WIN64_SERVER):./$(WORK)/$(DLL_WIN64) $(DLL_WIN64)
$(DLL_MAC): $(version_file)
ssh $(MAC_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_MAC))
$(RSYNC) $(MAC_SERVER):./$(WORK)/$(DLL_MAC) $(DLL_MAC)
$(DLL_TIGER_MAC): $(version_file)
ssh $(MAC_TIGER_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_TIGER_MAC))
$(RSYNC) $(MAC_TIGER_SERVER):./$(WORK)/$(DLL_TIGER_MAC) $(DLL_TIGER_MAC)
$(DLL_LINUX):$(version_file)
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD_PREFIX) linux32"
mkdir -p $(dir $(DLL_LINUX))
$(RSYNC) $(AMD_SERVER):./$(WORK)/$(DLL_LINUX) $(DLL_LINUX)
$(DLL_AMD64):$(version_file)
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_AMD64))
$(RSYNC) $(AMD_SERVER):./$(WORK)/$(DLL_AMD64) $(DLL_AMD64)
native: $(DLL_WIN) $(DLL_WIN64) $(DLL_LINUX) $(DLL_AMD64) $(DLL_MAC) $(DLL_TIGER_MAC)
compile: native
test:
ssh $(WIN64_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
ssh $(MAC_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
ssh $(MAC_TIGER_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
release:
mvn release:prepare
mvn release:perform
release-xerial:
mvn release:perform -Dtag=snappy-java-$(VERSION)
release-sourceforge:
mvn release:perform -Darguments="-P sourceforge" -Dtag=snappy-java-$(VERSION)
# Makefile for building and collecting native libraries in Win/Mac/Linux (32/64bit).
include Makefile.common
RESOURCE_DIR=src/main/resources
NATIVE_DIR=$(RESOURCE_DIR)/native
RSYNC=rsync -av -e ssh --exclude=".hg"
WORK:=work/hg/snappy-java
WIN64_SERVER=localhost
MAC_SERVER=172.16.133.41
MAC_TIGER_SERVER=172.16.133.171
AMD_SERVER=hx02
BUILD_CMD_PREFIX = hg pull -u && make clean-native && make
BUILD_CMD = $(BUILD_CMD_PREFIX) native
TEST_CMD = hg pull -u && mvn test
all: compile test
.PHONY: compile test native clean
DLL_DIR=src/main/resources/org/xerial/snappy/native
DLL_WIN=$(DLL_DIR)/Windows/x86/snappyjava.dll
DLL_WIN64=$(DLL_DIR)/Windows/amd64/snappyjava.dll
DLL_MAC=$(DLL_DIR)/Mac/x86_64/libsnappyjava.jnilib
DLL_TIGER_MAC=$(DLL_DIR)/Mac/i386/libsnappyjava.jnilib
DLL_LINUX=$(DLL_DIR)/Linux/i386/libsnappyjava.so
DLL_AMD64=$(DLL_DIR)/Linux/amd64/libsnappyjava.so
version_file:=src/main/java/org/xerial/snappy/VERSION
$(DLL_WIN): $(version_file)
ssh $(WIN64_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD_PREFIX) win32"
mkdir -p $(dir $(DLL_WIN))
$(RSYNC) $(WIN_SERVER):./$(WORK)/$(DLL_WIN) $(DLL_WIN)
$(DLL_WIN64): $(version_file)
ssh $(WIN64_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_WIN64))
$(RSYNC) $(WIN64_SERVER):./$(WORK)/$(DLL_WIN64) $(DLL_WIN64)
$(DLL_MAC): $(version_file)
ssh $(MAC_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_MAC))
$(RSYNC) $(MAC_SERVER):./$(WORK)/$(DLL_MAC) $(DLL_MAC)
$(DLL_TIGER_MAC): $(version_file)
ssh $(MAC_TIGER_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_TIGER_MAC))
$(RSYNC) $(MAC_TIGER_SERVER):./$(WORK)/$(DLL_TIGER_MAC) $(DLL_TIGER_MAC)
$(DLL_LINUX):$(version_file)
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD_PREFIX) linux32"
mkdir -p $(dir $(DLL_LINUX))
$(RSYNC) $(AMD_SERVER):./$(WORK)/$(DLL_LINUX) $(DLL_LINUX)
$(DLL_AMD64):$(version_file)
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(BUILD_CMD)"
mkdir -p $(dir $(DLL_AMD64))
$(RSYNC) $(AMD_SERVER):./$(WORK)/$(DLL_AMD64) $(DLL_AMD64)
native: $(DLL_WIN) $(DLL_WIN64) $(DLL_LINUX) $(DLL_AMD64) $(DLL_MAC) $(DLL_TIGER_MAC)
compile: native
test:
ssh $(WIN64_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
ssh $(MAC_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
ssh $(MAC_TIGER_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
release:
mvn deploy -DperformRelease=true