Bump for 4.0-15
[LibreOffice.git] / odk / setsdkenv_unix.sh.in
blob11815482231985a873300ab5cbac92d3ec15988e
1 #! /bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # This script starts a new shell and sets all enviroment variables, which
21 # are necessary for building the examples of the Office Development Kit.
22 # The Script was developed for the operating systems Solaris, Linux and MacOS.
24 # The SDK name
25 OO_SDK_NAME=@OO_SDK_NAME@
26 export OO_SDK_NAME
28 # Installation directory of the Software Development Kit.
29 # Example: OO_SDK_HOME=/opt/libreoffice/basis3.4/sdk
30 OO_SDK_HOME='@OO_SDK_HOME@'
32 # Office installation directory.
33 # Example: OFFICE_HOME=/opt/libreoffice
34 OFFICE_HOME='@OFFICE_HOME@'
36 # URE installation directory.
37 # Example: OO_SDK_URE_HOME=/opt/libreoffice/ure
38 OO_SDK_URE_HOME='@OO_SDK_URE_HOME@'
39 export OO_SDK_URE_HOME
41 # Directory of the make command.
42 # Example: OO_SDK_MAKE_HOME=/usr/bin
43 OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@
45 # Directory of the zip command.
46 # Example: OO_SDK_ZIP_HOME=/usr/bin
47 OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@
49 # Directory of the C++ compiler.
50 # Example: OO_SDK_CPP_HOME=/usr/bin
51 OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@
53 # Solaris only
54 OO_SDK_CC_55_OR_HIGHER=@OO_SDK_CC_55_OR_HIGHER@
56 # Directory of the Java SDK.
57 # Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10
58 OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@
60 # Special output directory
61 # Example: OO_SDK_OUTPUT_DIR=$HOME
62 OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@
64 # Environment variable to enable auto deployment of example components
65 # Example: SDK_AUTO_DEPLOYMENT=YES
66 SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@
67 export SDK_AUTO_DEPLOYMENT
69 # Check installation path for the OpenOffice Development Kit.
70 if [ -z "${OO_SDK_HOME}" ]
71 then
72 echo Error: Please insert a correct value for the variable OO_SDK_HOME.
73 exit 0
76 export OO_SDK_HOME
78 # Check installation path for the office.
79 if [ -z "${OFFICE_HOME}" ] && [ -z "${OO_SDK_URE_HOME}" ]
80 then
81 echo 'Error: Please set either the environment variable OFFICE_HOME or the'
82 echo 'environment variable OO_SDK_URE_HOME.'
83 exit 0
86 # Get the operating system.
87 sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4`
89 # Set the directory name.
90 programdir=program
91 javadir=bin
92 case ${sdk_platform} in
93 darwin*)
94 programdir="Contents/MacOS"
95 javacdir=Commands
97 esac
99 # Set office program path (only set when using an Office).
100 if [ "${OFFICE_HOME}" ]
101 then
102 OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir}
103 export OFFICE_PROGRAM_PATH
107 # Set UNO path, necessary to ensure that the cpp examples using the
108 # new UNO bootstrap mechanism use the configured office installation (only set
109 # when using an Office).
110 if [ "${OFFICE_HOME}" ]
111 then
112 UNO_PATH=${OFFICE_PROGRAM_PATH}
113 export UNO_PATH
116 if [ "${OO_SDK_URE_HOME}" ]
117 then
118 OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin
119 OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib
120 OO_SDK_URE_JAVA_DIR=${OO_SDK_URE_HOME}/share/java
121 else
122 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH}
123 OO_SDK_URE_LIB_DIR=${OFFICE_PROGRAM_PATH}
124 OO_SDK_URE_JAVA_DIR=${OFFICE_PROGRAM_PATH}/classes
126 export OO_SDK_URE_BIN_DIR
127 export OO_SDK_URE_LIB_DIR
128 export OO_SDK_URE_JAVA_DIR
130 OO_SDK_OUT=$OO_SDK_HOME
131 # Prepare appropriate output directory.
132 if [ -n "${OO_SDK_OUTPUT_DIR}" ]
133 then
134 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME}
135 export OO_SDK_OUT
138 # Set the directory name.
139 case ${sdk_platform} in
140 solaris*)
141 sdk_proctype=`${OO_SDK_HOME}/config.guess | cut -d"-" -f1`
142 if [ "${sdk_proctype}" = "sparc" ]
143 then
144 directoryname=solsparc
145 platform='Solaris Sparc'
146 else
147 directoryname=solintel
148 platform='Solaris x86'
150 comid=C52
151 pltfrm=sunpro
152 soext=so
153 exampleout=SOLARISexample.out
154 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
155 export LD_LIBRARY_PATH
158 darwin*)
159 directoryname=macosx
160 comid=gcc3
161 pltfrm=gcc
162 soext=dylib
163 exampleout=MACOSXexample.out
164 platform=MacOSX
165 DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH}
166 export DYLD_LIBRARY_PATH
169 linux-gnu)
170 directoryname=linux
171 comid=gcc3
172 pltfrm=gcc
173 soext=so
174 exampleout=LINUXexample.out
175 platform=Linux
176 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
177 export LD_LIBRARY_PATH
180 freebsd*)
181 directoryname=freebsd
182 comid=gcc3
183 pltfrm=gcc
184 soext=so
185 exampleout=FREEBSDexample.out
186 platform=FreeBSD
187 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
188 export LD_LIBRARY_PATH
190 if [ -e "/sbin/sysctl" ]
191 then
192 OSVERSION=`/sbin/sysctl -n kern.osreldate`
193 else
194 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate`
196 if [ $OSVERSION -lt 500016 ]
197 then
198 PTHREAD_CFLAGS=-D_THREAD_SAFE
199 PTHREAD_LIBS=-pthread
200 export PTHREAD_CFLAGS
201 export PTHREAD_LIBS
202 elif [ $OSVERSION -lt 502102 ]
203 then
204 PTHREAD_CFLAGS=-D_THREAD_SAFE
205 PTHREAD_LIBS=-lc_r
206 export PTHREAD_CFLAGS
207 export PTHREAD_LIBS
208 else
209 PTHREAD_LIBS=-pthread
210 export PTHREAD_LIBS
213 esac
215 # Add directory of the SDK tools to the path.
216 PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:.:${PATH}
218 # Set the classpath
219 CLASSPATH=${OO_SDK_URE_JAVA_DIR}/juh.jar:${OO_SDK_URE_JAVA_DIR}/jurt.jar:${OO_SDK_URE_JAVA_DIR}/ridl.jar:${OO_SDK_URE_JAVA_DIR}/unoloader.jar:${OFFICE_PROGRAM_PATH}/classes/unoil.jar:${CLASSPATH}
220 export CLASSPATH
223 # Add directory of the command make to the path, if necessary.
224 if [ -n "${OO_SDK_MAKE_HOME}" ]
225 then
226 PATH=${OO_SDK_MAKE_HOME}:${PATH}
227 export OO_SDK_MAKE_HOME
230 # Add directory of the zip tool to the path, if necessary.
231 if [ -n "${OO_SDK_ZIP_HOME}" ]
232 then
233 PATH=${OO_SDK_ZIP_HOME}:${PATH}
234 export OO_SDK_ZIP_HOME
237 # Add directory of the C++ tools to the path, if necessary.
238 if [ -n "${OO_SDK_CPP_HOME}" ]
239 then
240 PATH=${OO_SDK_CPP_HOME}:${PATH}
241 export OO_SDK_CPP_HOME
243 if [ -n "${OO_SDK_CC_55_OR_HIGHER}" ]
244 then
245 export OO_SDK_CC_55_OR_HIGHER
249 # Add directory of the Java tools to the path, if necessary.
250 if [ -n "${OO_SDK_JAVA_HOME}" ]
251 then
252 PATH=${OO_SDK_JAVA_HOME}/${javadir}:${PATH}
253 # JAVA_HOME=${OO_SDK_JAVA_HOME}
254 # export JAVA_HOME
255 export OO_SDK_JAVA_HOME
257 export PATH
260 export PATH
262 if [ "${platform}" = "MacOSX" ]
263 then
264 # For URE, prepare symbolic links for libraries:
265 # Only necessary on MacOSX, on other Unix systems the links are already prepared
266 # in the SDK installation.
268 # cleanup potential old links first
269 rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \
270 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \
271 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \
272 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \
273 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
275 # prepare links
276 if [ "${OO_SDK_URE_HOME}" ]
277 then
278 mkdir -p "${OO_SDK_OUT}/${directoryname}/lib"
279 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \
280 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}"
281 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \
282 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}"
283 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \
284 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}"
285 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \
286 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}"
287 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \
288 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
293 # Prepare shell with all necessary environment variables.
294 echo
295 echo " ************************************************************************"
296 echo " *"
297 echo " * SDK environment is prepared for ${platform}"
298 echo " *"
299 echo " * SDK = $OO_SDK_HOME"
300 echo " * Office = $OFFICE_HOME"
301 echo " * URE = $OO_SDK_URE_HOME"
302 echo " * Make = $OO_SDK_MAKE_HOME"
303 echo " * Zip = $OO_SDK_ZIP_HOME"
304 echo " * C++ Compiler = $OO_SDK_CPP_HOME"
305 echo " * Java = $OO_SDK_JAVA_HOME"
306 echo " * SDK Output directory = $OO_SDK_OUT"
307 echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT"
308 echo " *"
309 echo " ************************************************************************"
311 echo "\e]2;Shell prepared with the SDK environment\a"