1#! /bin/sh 2############################################################### 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21############################################################### 22 23# This script starts a new shell and sets all enviroment variables, which 24# are necessary for building the examples of the Office Development Kit. 25# The Script was developed for the operating systems Solaris, Linux and MacOS. 26 27# The SDK name 28OO_SDK_NAME=@OO_SDK_NAME@ 29export OO_SDK_NAME 30 31# Installation directory of the Software Development Kit. 32# Example: OO_SDK_HOME=/opt/openoffice.org/basis3.0/sdk 33OO_SDK_HOME='@OO_SDK_HOME@' 34 35# Office installation directory. 36# Example: OFFICE_HOME=/opt/openoffice.org3 37OFFICE_HOME='@OFFICE_HOME@' 38OFFICE_BASE_HOME='@OFFICE_BASE_HOME@' 39 40# URE installation directory. 41# Example: OO_SDK_URE_HOME=/opt/openoffice.org/ure 42OO_SDK_URE_HOME='@OO_SDK_URE_HOME@' 43export OO_SDK_URE_HOME 44 45# Directory of the make command. 46# Example: OO_SDK_MAKE_HOME=/usr/bin 47OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@ 48 49# Directory of the zip command. 50# Example: OO_SDK_ZIP_HOME=/usr/bin 51OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@ 52 53# Directory of the cat command. 54# Example: OO_SDK_CAT_HOME=/usr/bin 55OO_SDK_CAT_HOME=@OO_SDK_CAT_HOME@ 56 57# Directory of the sed command. 58# Example: OO_SDK_SED_HOME=/usr/bin 59OO_SDK_SED_HOME=@OO_SDK_SED_HOME@ 60 61# Directory of the C++ compiler. 62# Example: OO_SDK_CPP_HOME=/usr/bin 63OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@ 64 65# Solaris only 66OO_SDK_CC_55_OR_HIGHER=@OO_SDK_CC_55_OR_HIGHER@ 67 68# Directory of the Java SDK. 69# Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10 70OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@ 71 72# Special output directory 73# Example: OO_SDK_OUTPUT_DIR=$HOME 74OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@ 75 76# Environment variable to enable auto deployment of example components 77# Example: SDK_AUTO_DEPLOYMENT=YES 78SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@ 79export SDK_AUTO_DEPLOYMENT 80 81# Check installation path for the OpenOffice Development Kit. 82if [ -z "${OO_SDK_HOME}" ] 83then 84 echo Error: Please insert a correct value for the variable OO_SDK_HOME. 85 exit 0 86fi 87 88export OO_SDK_HOME 89 90# Check installation path for the office. 91if [ -z "${OFFICE_HOME}" ] && [ -z "${OO_SDK_URE_HOME}" ] 92then 93 echo 'Error: Please set either the environment variable OFFICE_HOME or the' 94 echo 'environment variable OO_SDK_URE_HOME.' 95 exit 0 96fi 97 98# Get the operating system. 99sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4` 100 101# Set the directory name. 102programdir=program 103javadir=bin 104case ${sdk_platform} in 105 darwin*) 106 programdir="Contents/MacOS" 107 javacdir=Commands 108 ;; 109esac 110 111# Set office program path (only set when using an Office). 112if [ "${OFFICE_HOME}" ] 113then 114 OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir} 115 export OFFICE_PROGRAM_PATH 116fi 117 118# Set office program path (only set when using an Office). 119if [ "${OFFICE_BASE_HOME}" ] 120then 121 OFFICE_BASE_PROGRAM_PATH=${OFFICE_BASE_HOME}/program 122 export OFFICE_BASE_PROGRAM_PATH 123fi 124 125 126# Set UNO path, necessary to ensure that the cpp examples using the 127# new UNO bootstrap mechanism use the configured office installation (only set 128# when using an Office). 129if [ "${OFFICE_HOME}" ] 130then 131 UNO_PATH=${OFFICE_PROGRAM_PATH} 132 export UNO_PATH 133fi 134 135if [ "${OO_SDK_URE_HOME}" ] 136then 137 OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin 138 OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib 139 OO_SDK_URE_JAVA_DIR=${OO_SDK_URE_HOME}/share/java 140else 141 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH} 142 OO_SDK_URE_LIB_DIR=${OFFICE_BASE_PROGRAM_PATH} 143 OO_SDK_URE_JAVA_DIR=${OFFICE_BASE_PROGRAM_PATH}/classes 144fi 145export OO_SDK_URE_BIN_DIR 146export OO_SDK_URE_LIB_DIR 147export OO_SDK_URE_JAVA_DIR 148 149OO_SDK_OUT=$OO_SDK_HOME 150# Prepare appropriate output directory. 151if [ -n "${OO_SDK_OUTPUT_DIR}" ] 152then 153 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME} 154 export OO_SDK_OUT 155fi 156 157# Set the directory name. 158case ${sdk_platform} in 159 solaris*) 160 sdk_proctype=`${OO_SDK_HOME}/config.guess | cut -d"-" -f1` 161 if [ "${sdk_proctype}" = "sparc" ] 162 then 163 directoryname=solsparc 164 platform='Solaris Sparc' 165 else 166 directoryname=solintel 167 platform='Solaris x86' 168 fi 169 comid=C52 170 pltfrm=sunpro 171 soext=so 172 exampleout=SOLARISexample.out 173 stldebug=_debug 174 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 175 export LD_LIBRARY_PATH 176 ;; 177 178 darwin*) 179 if [ -n "$OO_SDK_CPP_HOME" ] 180 then 181 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1` 182 export SDK_GXX_INCLUDE_PATH 183 fi 184 185 directoryname=macosx 186 comid=gcc3 187 pltfrm=gcc 188 soext=dylib 189 exampleout=MACOSXexample.out 190 platform=MacOSX 191 stldebug=_stldebug 192 DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH} 193 export DYLD_LIBRARY_PATH 194 ;; 195 196 linux-gnu) 197 if [ -n "$OO_SDK_CPP_HOME" ] 198 then 199 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1` 200 export SDK_GXX_INCLUDE_PATH 201 fi 202 203 directoryname=linux 204 comid=gcc3 205 pltfrm=gcc 206 soext=so 207 exampleout=LINUXexample.out 208 platform=Linux 209 stldebug=_stldebug 210 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 211 export LD_LIBRARY_PATH 212 ;; 213 214 freebsd*) 215 if [ -n "$OO_SDK_CPP_HOME" ] 216 then 217 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1` 218 export SDK_GXX_INCLUDE_PATH 219 fi 220 221 directoryname=freebsd 222 comid=gcc3 223 pltfrm=gcc 224 soext=so 225 exampleout=FREEBSDexample.out 226 platform=FreeBSD 227 stldebug=_stldebug 228 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 229 export LD_LIBRARY_PATH 230 231 if [ -e "/sbin/sysctl" ] 232 then 233 OSVERSION=`/sbin/sysctl -n kern.osreldate` 234 else 235 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate` 236 fi 237 if [ $OSVERSION -lt 500016 ] 238 then 239 PTHREAD_CFLAGS=-D_THREAD_SAFE 240 PTHREAD_LIBS=-pthread 241 export PTHREAD_CFLAGS 242 export PTHREAD_LIBS 243 elif [ $OSVERSION -lt 502102 ] 244 then 245 PTHREAD_CFLAGS=-D_THREAD_SAFE 246 PTHREAD_LIBS=-lc_r 247 export PTHREAD_CFLAGS 248 export PTHREAD_LIBS 249 else 250 PTHREAD_LIBS=-pthread 251 export PTHREAD_LIBS 252 fi 253 ;; 254esac 255 256# Add directory of the SDK tools to the path. 257PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:.:${PATH} 258 259# Set the classpath 260CLASSPATH=${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} 261export CLASSPATH 262 263 264# Add directory of the command make to the path, if necessary. 265if [ -n "${OO_SDK_MAKE_HOME}" ] 266then 267 PATH=${OO_SDK_MAKE_HOME}:${PATH} 268 export OO_SDK_MAKE_HOME 269fi 270 271# Add directory of the zip tool to the path, if necessary. 272if [ -n "${OO_SDK_ZIP_HOME}" ] 273then 274 PATH=${OO_SDK_ZIP_HOME}:${PATH} 275 export OO_SDK_ZIP_HOME 276fi 277 278# Add directory of the sed tool to the path, if necessary. 279if [ -n "${OO_SDK_SED_HOME}" ] 280then 281 PATH=${OO_SDK_SED_HOME}:${PATH} 282 export OO_SDK_SED_HOME 283fi 284 285# Add directory of the cat tool to the path, if necessary. 286if [ -n "${OO_SDK_CAT_HOME}" ] 287then 288 PATH=${OO_SDK_CAT_HOME}:${PATH} 289 export OO_SDK_CAT_HOME 290fi 291 292# Add directory of the C++ tools to the path, if necessary. 293if [ -n "${OO_SDK_CPP_HOME}" ] 294then 295 PATH=${OO_SDK_CPP_HOME}:${PATH} 296 export OO_SDK_CPP_HOME 297 298 if [ -n "${OO_SDK_CC_55_OR_HIGHER}" ] 299 then 300 export OO_SDK_CC_55_OR_HIGHER 301 fi 302fi 303 304# Add directory of the Java tools to the path, if necessary. 305if [ -n "${OO_SDK_JAVA_HOME}" ] 306then 307 PATH=${OO_SDK_JAVA_HOME}/${javadir}:${PATH} 308# JAVA_HOME=${OO_SDK_JAVA_HOME} 309# export JAVA_HOME 310 export OO_SDK_JAVA_HOME 311 312 export PATH 313fi 314 315export PATH 316 317if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${stldebug}.${soext}" ] 318then 319 STLDEBUG=${stldebug} 320 export STLDEBUG 321fi 322 323if [ "${platform}" = "MacOSX" ] 324then 325# For URE, prepare symbolic links for libraries: 326# Only necessary on MacOSX, on other Unix systems the links are already prepared 327# in the SDK installation. 328 329# cleanup potential old links first 330 rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \ 331 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \ 332 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \ 333 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \ 334 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}" 335 336 if [ -L "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" ] 337 then 338 rm -rf "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" 339 fi 340 341# prepare links 342 if [ "${OO_SDK_URE_HOME}" ] 343 then 344 mkdir -p "${OO_SDK_OUT}/${directoryname}/lib" 345 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \ 346 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" 347 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \ 348 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" 349 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \ 350 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" 351 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \ 352 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" 353 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \ 354 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}" 355 356 if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" ] 357 then 358 ln -s "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" \ 359 "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" 360 fi 361 fi 362fi 363 364 365# Prepare shell with all necessary environment variables. 366echo 367echo " ************************************************************************" 368echo " *" 369echo " * SDK environment is prepared for ${platform}" 370echo " *" 371echo " * SDK = $OO_SDK_HOME" 372echo " * Office = $OFFICE_HOME" 373echo " * Office Base = $OFFICE_BASE_HOME" 374echo " * URE = $OO_SDK_URE_HOME" 375echo " * Make = $OO_SDK_MAKE_HOME" 376echo " * Zip = $OO_SDK_ZIP_HOME" 377echo " * cat = $OO_SDK_CAT_HOME" 378echo " * sed = $OO_SDK_SED_HOME" 379echo " * C++ Compiler = $OO_SDK_CPP_HOME" 380echo " * Java = $OO_SDK_JAVA_HOME" 381echo " * SDK Output directory = $OO_SDK_OUT" 382echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT" 383echo " *" 384echo " ************************************************************************" 385 386echo "]2;Shell prepared with the SDK environment" 387 388