merge the formfield patch from ooo-build
[ooovba.git] / odk / setsdkenv_unix.sh.in
blob0f6ef22519cd0c3c0a6edfbd6575f236b9add5c6
1 #! /bin/sh
3 # This script starts a new shell and sets all enviroment variables, which
4 # are necessary for building the examples of the Office Development Kit.
5 # The Script was developed for the operating systems Solaris, Linux and MacOS.
7 # The SDK name
8 OO_SDK_NAME=@OO_SDK_NAME@
9 export OO_SDK_NAME
11 # Installation directory of the Software Development Kit.
12 # Example: OO_SDK_HOME=/opt/openoffice.org/basis3.0/sdk
13 OO_SDK_HOME=@OO_SDK_HOME@
15 # Office installation directory.
16 # Example: OFFICE_HOME=/opt/openoffice.org3
17 OFFICE_HOME=@OFFICE_HOME@
18 OFFICE_BASE_HOME=@OFFICE_BASE_HOME@
20 # URE installation directory.
21 # Example: OO_SDK_URE_HOME=/opt/openoffice.org/ure
22 OO_SDK_URE_HOME=@OO_SDK_URE_HOME@
23 export OO_SDK_URE_HOME
25 # Directory of the make command.
26 # Example: OO_SDK_MAKE_HOME=/usr/bin
27 OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@
29 # Directory of the zip command.
30 # Example: OO_SDK_ZIP_HOME=/usr/bin
31 OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@
33 # Directory of the C++ compiler.
34 # Example: OO_SDK_CPP_HOME=/usr/bin
35 OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@
37 # Solaris only
38 OO_SDK_CC_55_OR_HIGHER=@OO_SDK_CC_55_OR_HIGHER@
40 # Directory of the Java SDK.
41 # Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10
42 OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@
44 # Special output directory
45 # Example: OO_SDK_OUTPUT_DIR=$HOME
46 OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@
48 # Environment variable to enable auto deployment of example components
49 # Example: SDK_AUTO_DEPLOYMENT=YES
50 SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@
51 export SDK_AUTO_DEPLOYMENT
53 # Check installation path for the OpenOffice Development Kit.
54 if [ -z "${OO_SDK_HOME}" ]
55 then
56 echo Error: Please insert a correct value for the variable OO_SDK_HOME.
57 exit 0
60 export OO_SDK_HOME
62 # Check installation path for the office.
63 if [ -z "${OFFICE_HOME}" ] && [ -z "${OO_SDK_URE_HOME}" ]
64 then
65 echo 'Error: Please set either the environment variable OFFICE_HOME or the'
66 echo 'environment variable OO_SDK_URE_HOME.'
67 exit 0
70 # Get the operating system.
71 sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4`
73 # Set the directory name.
74 programdir=program
75 javadir=bin
76 case ${sdk_platform} in
77 darwin*)
78 programdir="Contents/MacOS"
79 javacdir=Commands
81 esac
83 # Set office program path (only set when using an Office).
84 if [ "${OFFICE_HOME}" ]
85 then
86 OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir}
87 export OFFICE_PROGRAM_PATH
90 # Set office program path (only set when using an Office).
91 if [ "${OFFICE_BASE_HOME}" ]
92 then
93 OFFICE_BASE_PROGRAM_PATH=${OFFICE_BASE_HOME}/program
94 export OFFICE_BASE_PROGRAM_PATH
98 # Set UNO path, necessary to ensure that the cpp examples using the
99 # new UNO bootstrap mechanism use the configured office installation (only set
100 # when using an Office).
101 if [ "${OFFICE_HOME}" ]
102 then
103 UNO_PATH=${OFFICE_PROGRAM_PATH}
104 export UNO_PATH
107 if [ "${OO_SDK_URE_HOME}" ]
108 then
109 OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin
110 OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib
111 OO_SDK_URE_JAVA_DIR=${OO_SDK_URE_HOME}/share/java
112 else
113 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH}
114 OO_SDK_URE_LIB_DIR=${OFFICE_BASE_PROGRAM_PATH}
115 OO_SDK_URE_JAVA_DIR=${OFFICE_BASE_PROGRAM_PATH}/classes
117 export OO_SDK_URE_BIN_DIR
118 export OO_SDK_URE_LIB_DIR
119 export OO_SDK_URE_JAVA_DIR
121 OO_SDK_OUT=$OO_SDK_HOME
122 # Prepare appropriate output directory.
123 if [ -n "${OO_SDK_OUTPUT_DIR}" ]
124 then
125 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME}
126 export OO_SDK_OUT
129 # Set the directory name.
130 case ${sdk_platform} in
131 solaris*)
132 sdk_proctype=`${OO_SDK_HOME}/config.guess | cut -d"-" -f1`
133 if [ "${sdk_proctype}" = "sparc" ]
134 then
135 directoryname=solsparc
136 platform='Solaris Sparc'
137 else
138 directoryname=solintel
139 platform='Solaris x86'
141 comid=C52
142 pltfrm=sunpro
143 soext=so
144 exampleout=SOLARISexample.out
145 stldebug=_debug
146 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
147 export LD_LIBRARY_PATH
150 darwin*)
151 if [ -n "$OO_SDK_CPP_HOME" ]
152 then
153 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
154 export SDK_GXX_INCLUDE_PATH
157 directoryname=macosx
158 comid=gcc3
159 pltfrm=gcc
160 soext=dylib
161 exampleout=MACOSXexample.out
162 platform=MacOSX
163 stldebug=_stldebug
164 DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH}
165 export DYLD_LIBRARY_PATH
168 linux-gnu)
169 if [ -n "$OO_SDK_CPP_HOME" ]
170 then
171 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
172 export SDK_GXX_INCLUDE_PATH
175 directoryname=linux
176 comid=gcc3
177 pltfrm=gcc
178 soext=so
179 exampleout=LINUXexample.out
180 platform=Linux
181 stldebug=_stldebug
182 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
183 export LD_LIBRARY_PATH
186 freebsd*)
187 if [ -n "$OO_SDK_CPP_HOME" ]
188 then
189 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
190 export SDK_GXX_INCLUDE_PATH
193 directoryname=freebsd
194 comid=gcc3
195 pltfrm=gcc
196 soext=so
197 exampleout=FREEBSDexample.out
198 platform=FreeBSD
199 stldebug=_stldebug
200 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
201 export LD_LIBRARY_PATH
203 if [ -e "/sbin/sysctl" ]
204 then
205 OSVERSION=`/sbin/sysctl -n kern.osreldate`
206 else
207 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate`
209 if [ $OSVERSION -lt 500016 ]
210 then
211 PTHREAD_CFLAGS=-D_THREAD_SAFE
212 PTHREAD_LIBS=-pthread
213 export PTHREAD_CFLAGS
214 export PTHREAD_LIBS
215 elif [ $OSVERSION -lt 502102 ]
216 then
217 PTHREAD_CFLAGS=-D_THREAD_SAFE
218 PTHREAD_LIBS=-lc_r
219 export PTHREAD_CFLAGS
220 export PTHREAD_LIBS
221 else
222 PTHREAD_LIBS=-pthread
223 export PTHREAD_LIBS
226 esac
228 # Add directory of the SDK tools to the path.
229 PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:.:${PATH}
231 # Set the classpath
232 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_BASE_PROGRAM_PATH}/classes/unoil.jar:${CLASSPATH}
233 export CLASSPATH
236 # Add directory of the command make to the path, if necessary.
237 if [ -n "${OO_SDK_MAKE_HOME}" ]
238 then
239 PATH=${OO_SDK_MAKE_HOME}:${PATH}
240 export OO_SDK_MAKE_HOME
243 # Add directory of the zip tool to the path, if necessary.
244 if [ -n "${OO_SDK_ZIP_HOME}" ]
245 then
246 PATH=${OO_SDK_ZIP_HOME}:${PATH}
247 export OO_SDK_ZIP_HOME
250 # Add directory of the C++ tools to the path, if necessary.
251 if [ -n "${OO_SDK_CPP_HOME}" ]
252 then
253 PATH=${OO_SDK_CPP_HOME}:${PATH}
254 export OO_SDK_CPP_HOME
256 if [ -n "${OO_SDK_CC_55_OR_HIGHER}" ]
257 then
258 export OO_SDK_CC_55_OR_HIGHER
262 # Add directory of the Java tools to the path, if necessary.
263 if [ -n "${OO_SDK_JAVA_HOME}" ]
264 then
265 PATH=${OO_SDK_JAVA_HOME}/${javadir}:${PATH}
266 # JAVA_HOME=${OO_SDK_JAVA_HOME}
267 # export JAVA_HOME
268 export OO_SDK_JAVA_HOME
270 export PATH
273 export PATH
275 if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${stldebug}.${soext}" ]
276 then
277 STLDEBUG=${stldebug}
278 export STLDEBUG
281 if [ "${platform}" = "MacOSX" ]
282 then
283 # For URE, prepare symbolic links for libraries:
284 # Only necessary on MacOSX, on other Unix systems the links are already prepared
285 # in the SDK installation.
287 # cleanup potential old links first
288 rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \
289 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \
290 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \
291 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \
292 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
294 if [ -L "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" ]
295 then
296 rm -rf "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}"
299 # prepare links
300 if [ "${OO_SDK_URE_HOME}" ]
301 then
302 mkdir -p "${OO_SDK_OUT}/${directoryname}/lib"
303 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \
304 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}"
305 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \
306 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}"
307 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \
308 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}"
309 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \
310 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}"
311 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \
312 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
314 if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" ]
315 then
316 ln -s "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" \
317 "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}"
323 # Prepare shell with all necessary environment variables.
324 echo
325 echo " ************************************************************************"
326 echo " *"
327 echo " * SDK environment is prepared for ${platform}"
328 echo " *"
329 echo " * SDK = $OO_SDK_HOME"
330 echo " * Office = $OFFICE_HOME"
331 echo " * Office Base = $OFFICE_BASE_HOME"
332 echo " * URE = $OO_SDK_URE_HOME"
333 echo " * Make = $OO_SDK_MAKE_HOME"
334 echo " * Zip = $OO_SDK_ZIP_HOME"
335 echo " * C++ Compiler = $OO_SDK_CPP_HOME"
336 echo " * Java = $OO_SDK_JAVA_HOME"
337 echo " * SDK Output directory = $OO_SDK_OUT"
338 echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT"
339 echo " *"
340 echo " ************************************************************************"
342 echo "\e]2;Shell prepared with the SDK environment\a"