]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.fastlz/native/compile.sh
Merge remote-tracking branch 'origin/svn'
[simantics/platform.git] / bundles / org.simantics.fastlz / native / compile.sh
1 #!/bin/bash
2 #*******************************************************************************
3 # Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 # in Industry THTH ry.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Eclipse Public License v1.0
7 # which accompanies this distribution, and is available at
8 # http://www.eclipse.org/legal/epl-v10.html
9 #
10 # Contributors:
11 #     VTT Technical Research Centre of Finland - initial API and implementation
12 #*******************************************************************************
13
14 if [ -z $JAVA_HOME ]; then
15     echo "JAVA_HOME is not defined, it is needed to find JNI headers (jni.h + jni_md.h)"
16     exit -1
17 fi
18
19 kernel=`uname -s | tr "[:upper:]" "[:lower:]"`
20 arch=`uname -m | tr "[:upper:]" "[:lower:]"`
21
22 #default empty
23 extraparams=""
24
25 if [ $# -gt 0 ]; then
26     arch=$1
27 fi
28
29 case $arch in
30     i386|i586|i686)
31         arch="x86"
32         ;;
33 esac
34
35 case $arch in
36     x86)
37         extraparams="-m32 -Os"
38         ;;
39     x86_64)
40         extraparams="-O3"
41         ;;
42 esac
43
44 #on macs force 64
45 case $kernel in
46     darwin)
47         arch="x86_64"
48         extraparams="-dynamiclib -arch x86_64"
49         ;;
50 esac
51
52 options="${extraparams} -Wall -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -std=c99 -Wall -W -Wundef -Wno-implicit-function-declaration -fPIC -shared"
53 output="../src/libfastlz-${kernel}-${arch}"
54
55 case $kernel in
56     darwin*)
57         output="${output}.dylib"
58         ;;
59     *)
60         output="${output}.so"
61 esac
62
63 echo "Kernel: $kernel"
64 echo "Architecture: $arch"
65 echo "Output library: $output"
66 echo "Compiler options: $options"
67
68 gcc ${options} -o ${output} fastlz.c jniWrapper.c
69
70 size=`ls -l $output | cut -d " " -f 5`
71 echo "library size before stripping: $size"
72
73 strip $output
74
75 size=`ls -l $output | cut -d " " -f 5`
76 echo "library size after stripping:  $size"
77
78 gcc ${extraparams} -o fastlz_test fastlz.c fastlz_read.c fastlz_write.c fastlz_test.c