tdf#124162: Crash when trying to accept changes
[LibreOffice.git] / odk / config / setsdkenv_unix.sh.in
blob61f5c5a07651c691342a9f1fda16de3cc7f0347d
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 environment 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@'
35 export OFFICE_HOME
37 # Directory of the make command.
38 # Example: OO_SDK_MAKE_HOME=/usr/bin
39 OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@
41 # Directory of the zip command.
42 # Example: OO_SDK_ZIP_HOME=/usr/bin
43 OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@
45 # Directory of the cat command.
46 # Example: OO_SDK_CAT_HOME=/usr/bin
47 OO_SDK_CAT_HOME=@OO_SDK_CAT_HOME@
49 # Directory of the sed command.
50 # Example: OO_SDK_SED_HOME=/usr/bin
51 OO_SDK_SED_HOME=@OO_SDK_SED_HOME@
53 # Directory of the C++ compiler.
54 # Example: OO_SDK_CPP_HOME=/usr/bin
55 OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@
57 # Directory of the Java SDK.
58 # Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10
59 OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@
61 # Special output directory
62 # Example: OO_SDK_OUTPUT_DIR=$HOME
63 OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@
65 # Environment variable to enable auto deployment of example components
66 # Example: SDK_AUTO_DEPLOYMENT=YES
67 SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@
68 export SDK_AUTO_DEPLOYMENT
70 # Check installation path for the OpenOffice Development Kit.
71 if [ -z "${OO_SDK_HOME}" ]
72 then
73 echo Error: Please insert a correct value for the variable OO_SDK_HOME.
74 exit 0
77 export OO_SDK_HOME
79 # Get the operating system.
80 sdk_platform=`/bin/sh ${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4`
82 # Set the directory name.
83 programdir=program
84 sdk_lo_java_dir=program/classes
85 case ${sdk_platform} in
86 darwin*)
87 programdir="Contents/MacOS"
88 sdk_lo_java_dir=Contents/Resources/java
90 esac
92 # Set office program path (only set when using an Office).
93 OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir}
94 export OFFICE_PROGRAM_PATH
96 # Set UNO path, necessary to ensure that the cpp examples using the
97 # new UNO bootstrap mechanism use the configured office installation (only set
98 # when using an Office).
99 UNO_PATH=${OFFICE_PROGRAM_PATH}
100 export UNO_PATH
102 case ${sdk_platform} in
103 darwin*)
104 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH}
105 OO_SDK_URE_LIB_DIR=${OFFICE_HOME}/Contents/Frameworks
106 OO_SDK_URE_JAVA_DIR=${OFFICE_HOME}/${sdk_lo_java_dir}
109 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH}
110 OO_SDK_URE_LIB_DIR=${OFFICE_PROGRAM_PATH}
111 OO_SDK_URE_JAVA_DIR=${OFFICE_PROGRAM_PATH}/classes
113 esac
114 export OO_SDK_URE_BIN_DIR
115 export OO_SDK_URE_LIB_DIR
116 export OO_SDK_URE_JAVA_DIR
118 OO_SDK_OUT=$OO_SDK_HOME
119 # Prepare appropriate output directory.
120 if [ -n "${OO_SDK_OUTPUT_DIR}" ]
121 then
122 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME}
123 export OO_SDK_OUT
126 # Set the directory name.
127 case ${sdk_platform} in
128 solaris*)
129 sdk_proctype=`/bin/sh ${OO_SDK_HOME}/config.guess | cut -d"-" -f1`
130 if [ "${sdk_proctype}" = "sparc" ]
131 then
132 directoryname=solsparc
133 platform='Solaris Sparc'
134 else
135 directoryname=solintel
136 platform='Solaris x86'
138 comid=gcc3
139 soext=so
140 exampleout=SOLARISexample.out
141 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
142 export LD_LIBRARY_PATH
145 darwin*)
146 directoryname=macosx
147 comid=gcc3
148 soext=dylib
149 exampleout=MACOSXexample.out
150 platform=MacOSX
151 DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH}
152 export DYLD_LIBRARY_PATH
155 linux-gnu*)
156 directoryname=linux
157 comid=gcc3
158 soext=so
159 exampleout=LINUXexample.out
160 platform=Linux
161 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
162 export LD_LIBRARY_PATH
165 freebsd*)
166 directoryname=freebsd
167 comid=gcc3
168 soext=so
169 exampleout=FREEBSDexample.out
170 platform=FreeBSD
171 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
172 export LD_LIBRARY_PATH
174 if [ -e "/sbin/sysctl" ]
175 then
176 OSVERSION=`/sbin/sysctl -n kern.osreldate`
177 else
178 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate`
180 if [ $OSVERSION -lt 500016 ]
181 then
182 PTHREAD_CFLAGS=-D_THREAD_SAFE
183 PTHREAD_LIBS=-pthread
184 export PTHREAD_CFLAGS
185 export PTHREAD_LIBS
186 elif [ $OSVERSION -lt 502102 ]
187 then
188 PTHREAD_CFLAGS=-D_THREAD_SAFE
189 PTHREAD_LIBS=-lc_r
190 export PTHREAD_CFLAGS
191 export PTHREAD_LIBS
192 else
193 PTHREAD_LIBS=-pthread
194 export PTHREAD_LIBS
197 esac
199 # Add directory of the SDK tools to the path.
200 PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:${PATH}
202 # Set the classpath
203 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_HOME}/$sdk_lo_java_dir/unoil.jar:${CLASSPATH}
204 export CLASSPATH
207 # Add directory of the command make to the path, if necessary.
208 if [ -n "${OO_SDK_MAKE_HOME}" ]
209 then
210 PATH=${OO_SDK_MAKE_HOME}:${PATH}
211 export OO_SDK_MAKE_HOME
214 # Add directory of the zip tool to the path, if necessary.
215 if [ -n "${OO_SDK_ZIP_HOME}" ]
216 then
217 PATH=${OO_SDK_ZIP_HOME}:${PATH}
218 export OO_SDK_ZIP_HOME
221 # Add directory of the sed tool to the path, if necessary.
222 if [ -n "${OO_SDK_SED_HOME}" ]
223 then
224 PATH=${OO_SDK_SED_HOME}:${PATH}
225 export OO_SDK_SED_HOME
228 # Add directory of the cat tool to the path, if necessary.
229 if [ -n "${OO_SDK_CAT_HOME}" ]
230 then
231 PATH=${OO_SDK_CAT_HOME}:${PATH}
232 export OO_SDK_CAT_HOME
235 # Add directory of the C++ tools to the path, if necessary.
236 if [ -n "${OO_SDK_CPP_HOME}" ]
237 then
238 PATH=${OO_SDK_CPP_HOME}:${PATH}
239 export OO_SDK_CPP_HOME
242 # Add directory of the Java tools to the path, if necessary.
243 if [ -n "${OO_SDK_JAVA_HOME}" ]
244 then
245 PATH=${OO_SDK_JAVA_HOME}/bin:${PATH}
246 # JAVA_HOME=${OO_SDK_JAVA_HOME}
247 # export JAVA_HOME
248 export OO_SDK_JAVA_HOME
250 export PATH
253 export PATH
255 if [ "${platform}" = "MacOSX" ]
256 then
257 # For URE, prepare symbolic links for libraries:
258 # Only necessary on MacOSX, on other Unix systems the links are already prepared
259 # in the SDK installation.
261 # cleanup potential old links first
262 rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \
263 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \
264 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \
265 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \
266 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
268 # prepare links
269 mkdir -p "${OO_SDK_OUT}/${directoryname}/lib"
270 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \
271 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}"
272 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \
273 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}"
274 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \
275 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}"
276 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \
277 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}"
278 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \
279 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
283 # Prepare shell with all necessary environment variables.
284 echo
285 echo " ************************************************************************"
286 echo " *"
287 echo " * SDK environment is prepared for ${platform}"
288 echo " *"
289 echo " * SDK = $OO_SDK_HOME"
290 echo " * Office = $OFFICE_HOME"
291 echo " * Make = $OO_SDK_MAKE_HOME"
292 echo " * Zip = $OO_SDK_ZIP_HOME"
293 echo " * cat = $OO_SDK_CAT_HOME"
294 echo " * sed = $OO_SDK_SED_HOME"
295 echo " * C++ Compiler = $OO_SDK_CPP_HOME"
296 echo " * Java = $OO_SDK_JAVA_HOME"
297 echo " * SDK Output directory = $OO_SDK_OUT"
298 echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT"
299 echo " *"
300 echo " ************************************************************************"