X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.fastlz%2Fnative%2Fcompile.sh;fp=bundles%2Forg.simantics.fastlz%2Fnative%2Fcompile.sh;h=05aac11f921d6002be1d1903f9ee984dd35adb09;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.fastlz/native/compile.sh b/bundles/org.simantics.fastlz/native/compile.sh new file mode 100755 index 000000000..05aac11f9 --- /dev/null +++ b/bundles/org.simantics.fastlz/native/compile.sh @@ -0,0 +1,78 @@ +#!/bin/bash +#******************************************************************************* +# Copyright (c) 2007, 2010 Association for Decentralized Information Management +# in Industry THTH ry. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# VTT Technical Research Centre of Finland - initial API and implementation +#******************************************************************************* + +if [ -z $JAVA_HOME ]; then + echo "JAVA_HOME is not defined, it is needed to find JNI headers (jni.h + jni_md.h)" + exit -1 +fi + +kernel=`uname -s | tr "[:upper:]" "[:lower:]"` +arch=`uname -m | tr "[:upper:]" "[:lower:]"` + +#default empty +extraparams="" + +if [ $# -gt 0 ]; then + arch=$1 +fi + +case $arch in + i386|i586|i686) + arch="x86" + ;; +esac + +case $arch in + x86) + extraparams="-m32 -Os" + ;; + x86_64) + extraparams="-O3" + ;; +esac + +#on macs force 64 +case $kernel in + darwin) + arch="x86_64" + extraparams="-dynamiclib -arch x86_64" + ;; +esac + +options="${extraparams} -Wall -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -std=c99 -Wall -W -Wundef -Wno-implicit-function-declaration -fPIC -shared" +output="../src/libfastlz-${kernel}-${arch}" + +case $kernel in + darwin*) + output="${output}.jnilib" + ;; + *) + output="${output}.so" +esac + +echo "Kernel: $kernel" +echo "Architecture: $arch" +echo "Output library: $output" +echo "Compiler options: $options" + +gcc ${options} -o ${output} fastlz.c lz4.c lz4hc.c jniWrapper.c + +size=`ls -l $output | cut -d " " -f 5` +echo "library size before stripping: $size" + +strip $output + +size=`ls -l $output | cut -d " " -f 5` +echo "library size after stripping: $size" + +gcc ${extraparams} -o fastlz_test fastlz.c fastlz_read.c fastlz_write.c fastlz_test.c