1#! /bin/sh 2 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. 6 7# The SDK name 8OO_SDK_NAME=@OO_SDK_NAME@ 9export OO_SDK_NAME 10 11# Installation directory of the Software Development Kit. 12# Example: OO_SDK_HOME=/opt/openoffice.org/basis3.0/sdk 13OO_SDK_HOME='@OO_SDK_HOME@' 14 15# Office installation directory. 16# Example: OFFICE_HOME=/opt/openoffice.org3 17OFFICE_HOME='@OFFICE_HOME@' 18OFFICE_BASE_HOME='@OFFICE_BASE_HOME@' 19 20# URE installation directory. 21# Example: OO_SDK_URE_HOME=/opt/openoffice.org/ure 22OO_SDK_URE_HOME='@OO_SDK_URE_HOME@' 23export OO_SDK_URE_HOME 24 25# Directory of the make command. 26# Example: OO_SDK_MAKE_HOME=/usr/bin 27OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@ 28 29# Directory of the zip command. 30# Example: OO_SDK_ZIP_HOME=/usr/bin 31OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@ 32 33# Directory of the C++ compiler. 34# Example: OO_SDK_CPP_HOME=/usr/bin 35OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@ 36 37# Solaris only 38OO_SDK_CC_55_OR_HIGHER=@OO_SDK_CC_55_OR_HIGHER@ 39 40# Directory of the Java SDK. 41# Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10 42OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@ 43 44# Special output directory 45# Example: OO_SDK_OUTPUT_DIR=$HOME 46OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@ 47 48# Environment variable to enable auto deployment of example components 49# Example: SDK_AUTO_DEPLOYMENT=YES 50SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@ 51export SDK_AUTO_DEPLOYMENT 52 53# Check installation path for the OpenOffice Development Kit. 54if [ -z "${OO_SDK_HOME}" ] 55then 56 echo Error: Please insert a correct value for the variable OO_SDK_HOME. 57 exit 0 58fi 59 60export OO_SDK_HOME 61 62# Check installation path for the office. 63if [ -z "${OFFICE_HOME}" ] && [ -z "${OO_SDK_URE_HOME}" ] 64then 65 echo 'Error: Please set either the environment variable OFFICE_HOME or the' 66 echo 'environment variable OO_SDK_URE_HOME.' 67 exit 0 68fi 69 70# Get the operating system. 71sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4` 72 73# Set the directory name. 74programdir=program 75javadir=bin 76case ${sdk_platform} in 77 darwin*) 78 programdir="Contents/MacOS" 79 javacdir=Commands 80 ;; 81esac 82 83# Set office program path (only set when using an Office). 84if [ "${OFFICE_HOME}" ] 85then 86 OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir} 87 export OFFICE_PROGRAM_PATH 88fi 89 90# Set office program path (only set when using an Office). 91if [ "${OFFICE_BASE_HOME}" ] 92then 93 OFFICE_BASE_PROGRAM_PATH=${OFFICE_BASE_HOME}/program 94 export OFFICE_BASE_PROGRAM_PATH 95fi 96 97 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). 101if [ "${OFFICE_HOME}" ] 102then 103 UNO_PATH=${OFFICE_PROGRAM_PATH} 104 export UNO_PATH 105fi 106 107if [ "${OO_SDK_URE_HOME}" ] 108then 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 112else 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 116fi 117export OO_SDK_URE_BIN_DIR 118export OO_SDK_URE_LIB_DIR 119export OO_SDK_URE_JAVA_DIR 120 121OO_SDK_OUT=$OO_SDK_HOME 122# Prepare appropriate output directory. 123if [ -n "${OO_SDK_OUTPUT_DIR}" ] 124then 125 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME} 126 export OO_SDK_OUT 127fi 128 129# Set the directory name. 130case ${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' 140 fi 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 148 ;; 149 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 155 fi 156 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 166 ;; 167 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 173 fi 174 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 184 ;; 185 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 191 fi 192 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 202 203 if [ -e "/sbin/sysctl" ] 204 then 205 OSVERSION=`/sbin/sysctl -n kern.osreldate` 206 else 207 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate` 208 fi 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 224 fi 225 ;; 226esac 227 228# Add directory of the SDK tools to the path. 229PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:.:${PATH} 230 231# Set the classpath 232CLASSPATH=${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} 233export CLASSPATH 234 235 236# Add directory of the command make to the path, if necessary. 237if [ -n "${OO_SDK_MAKE_HOME}" ] 238then 239 PATH=${OO_SDK_MAKE_HOME}:${PATH} 240 export OO_SDK_MAKE_HOME 241fi 242 243# Add directory of the zip tool to the path, if necessary. 244if [ -n "${OO_SDK_ZIP_HOME}" ] 245then 246 PATH=${OO_SDK_ZIP_HOME}:${PATH} 247 export OO_SDK_ZIP_HOME 248fi 249 250# Add directory of the C++ tools to the path, if necessary. 251if [ -n "${OO_SDK_CPP_HOME}" ] 252then 253 PATH=${OO_SDK_CPP_HOME}:${PATH} 254 export OO_SDK_CPP_HOME 255 256 if [ -n "${OO_SDK_CC_55_OR_HIGHER}" ] 257 then 258 export OO_SDK_CC_55_OR_HIGHER 259 fi 260fi 261 262# Add directory of the Java tools to the path, if necessary. 263if [ -n "${OO_SDK_JAVA_HOME}" ] 264then 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 269 270 export PATH 271fi 272 273export PATH 274 275if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${stldebug}.${soext}" ] 276then 277 STLDEBUG=${stldebug} 278 export STLDEBUG 279fi 280 281if [ "${platform}" = "MacOSX" ] 282then 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. 286 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}" 293 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}" 297 fi 298 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}" 313 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}" 318 fi 319 fi 320fi 321 322 323# Prepare shell with all necessary environment variables. 324echo 325echo " ************************************************************************" 326echo " *" 327echo " * SDK environment is prepared for ${platform}" 328echo " *" 329echo " * SDK = $OO_SDK_HOME" 330echo " * Office = $OFFICE_HOME" 331echo " * Office Base = $OFFICE_BASE_HOME" 332echo " * URE = $OO_SDK_URE_HOME" 333echo " * Make = $OO_SDK_MAKE_HOME" 334echo " * Zip = $OO_SDK_ZIP_HOME" 335echo " * C++ Compiler = $OO_SDK_CPP_HOME" 336echo " * Java = $OO_SDK_JAVA_HOME" 337echo " * SDK Output directory = $OO_SDK_OUT" 338echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT" 339echo " *" 340echo " ************************************************************************" 341 342echo "]2;Shell prepared with the SDK environment" 343 344