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 C++ compiler. 54# Example: OO_SDK_CPP_HOME=/usr/bin 55OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@ 56 57# Solaris only 58OO_SDK_CC_55_OR_HIGHER=@OO_SDK_CC_55_OR_HIGHER@ 59 60# Directory of the Java SDK. 61# Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10 62OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@ 63 64# Special output directory 65# Example: OO_SDK_OUTPUT_DIR=$HOME 66OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@ 67 68# Environment variable to enable auto deployment of example components 69# Example: SDK_AUTO_DEPLOYMENT=YES 70SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@ 71export SDK_AUTO_DEPLOYMENT 72 73# Check installation path for the OpenOffice Development Kit. 74if [ -z "${OO_SDK_HOME}" ] 75then 76 echo Error: Please insert a correct value for the variable OO_SDK_HOME. 77 exit 0 78fi 79 80export OO_SDK_HOME 81 82# Check installation path for the office. 83if [ -z "${OFFICE_HOME}" ] && [ -z "${OO_SDK_URE_HOME}" ] 84then 85 echo 'Error: Please set either the environment variable OFFICE_HOME or the' 86 echo 'environment variable OO_SDK_URE_HOME.' 87 exit 0 88fi 89 90# Get the operating system. 91sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4` 92 93# Set the directory name. 94programdir=program 95javadir=bin 96case ${sdk_platform} in 97 darwin*) 98 programdir="Contents/MacOS" 99 javacdir=Commands 100 ;; 101esac 102 103# Set office program path (only set when using an Office). 104if [ "${OFFICE_HOME}" ] 105then 106 OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir} 107 export OFFICE_PROGRAM_PATH 108fi 109 110# Set office program path (only set when using an Office). 111if [ "${OFFICE_BASE_HOME}" ] 112then 113 OFFICE_BASE_PROGRAM_PATH=${OFFICE_BASE_HOME}/program 114 export OFFICE_BASE_PROGRAM_PATH 115fi 116 117 118# Set UNO path, necessary to ensure that the cpp examples using the 119# new UNO bootstrap mechanism use the configured office installation (only set 120# when using an Office). 121if [ "${OFFICE_HOME}" ] 122then 123 UNO_PATH=${OFFICE_PROGRAM_PATH} 124 export UNO_PATH 125fi 126 127if [ "${OO_SDK_URE_HOME}" ] 128then 129 OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin 130 OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib 131 OO_SDK_URE_JAVA_DIR=${OO_SDK_URE_HOME}/share/java 132else 133 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH} 134 OO_SDK_URE_LIB_DIR=${OFFICE_BASE_PROGRAM_PATH} 135 OO_SDK_URE_JAVA_DIR=${OFFICE_BASE_PROGRAM_PATH}/classes 136fi 137export OO_SDK_URE_BIN_DIR 138export OO_SDK_URE_LIB_DIR 139export OO_SDK_URE_JAVA_DIR 140 141OO_SDK_OUT=$OO_SDK_HOME 142# Prepare appropriate output directory. 143if [ -n "${OO_SDK_OUTPUT_DIR}" ] 144then 145 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME} 146 export OO_SDK_OUT 147fi 148 149# Set the directory name. 150case ${sdk_platform} in 151 solaris*) 152 sdk_proctype=`${OO_SDK_HOME}/config.guess | cut -d"-" -f1` 153 if [ "${sdk_proctype}" = "sparc" ] 154 then 155 directoryname=solsparc 156 platform='Solaris Sparc' 157 else 158 directoryname=solintel 159 platform='Solaris x86' 160 fi 161 comid=C52 162 pltfrm=sunpro 163 soext=so 164 exampleout=SOLARISexample.out 165 stldebug=_debug 166 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 167 export LD_LIBRARY_PATH 168 ;; 169 170 darwin*) 171 if [ -n "$OO_SDK_CPP_HOME" ] 172 then 173 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1` 174 export SDK_GXX_INCLUDE_PATH 175 fi 176 177 directoryname=macosx 178 comid=gcc3 179 pltfrm=gcc 180 soext=dylib 181 exampleout=MACOSXexample.out 182 platform=MacOSX 183 stldebug=_stldebug 184 DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH} 185 export DYLD_LIBRARY_PATH 186 ;; 187 188 linux-gnu) 189 if [ -n "$OO_SDK_CPP_HOME" ] 190 then 191 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1` 192 export SDK_GXX_INCLUDE_PATH 193 fi 194 195 directoryname=linux 196 comid=gcc3 197 pltfrm=gcc 198 soext=so 199 exampleout=LINUXexample.out 200 platform=Linux 201 stldebug=_stldebug 202 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 203 export LD_LIBRARY_PATH 204 ;; 205 206 freebsd*) 207 if [ -n "$OO_SDK_CPP_HOME" ] 208 then 209 SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1` 210 export SDK_GXX_INCLUDE_PATH 211 fi 212 213 directoryname=freebsd 214 comid=gcc3 215 pltfrm=gcc 216 soext=so 217 exampleout=FREEBSDexample.out 218 platform=FreeBSD 219 stldebug=_stldebug 220 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 221 export LD_LIBRARY_PATH 222 223 if [ -e "/sbin/sysctl" ] 224 then 225 OSVERSION=`/sbin/sysctl -n kern.osreldate` 226 else 227 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate` 228 fi 229 if [ $OSVERSION -lt 500016 ] 230 then 231 PTHREAD_CFLAGS=-D_THREAD_SAFE 232 PTHREAD_LIBS=-pthread 233 export PTHREAD_CFLAGS 234 export PTHREAD_LIBS 235 elif [ $OSVERSION -lt 502102 ] 236 then 237 PTHREAD_CFLAGS=-D_THREAD_SAFE 238 PTHREAD_LIBS=-lc_r 239 export PTHREAD_CFLAGS 240 export PTHREAD_LIBS 241 else 242 PTHREAD_LIBS=-pthread 243 export PTHREAD_LIBS 244 fi 245 ;; 246esac 247 248# Add directory of the SDK tools to the path. 249PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:.:${PATH} 250 251# Set the classpath 252CLASSPATH=${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} 253export CLASSPATH 254 255 256# Add directory of the command make to the path, if necessary. 257if [ -n "${OO_SDK_MAKE_HOME}" ] 258then 259 PATH=${OO_SDK_MAKE_HOME}:${PATH} 260 export OO_SDK_MAKE_HOME 261fi 262 263# Add directory of the zip tool to the path, if necessary. 264if [ -n "${OO_SDK_ZIP_HOME}" ] 265then 266 PATH=${OO_SDK_ZIP_HOME}:${PATH} 267 export OO_SDK_ZIP_HOME 268fi 269 270# Add directory of the C++ tools to the path, if necessary. 271if [ -n "${OO_SDK_CPP_HOME}" ] 272then 273 PATH=${OO_SDK_CPP_HOME}:${PATH} 274 export OO_SDK_CPP_HOME 275 276 if [ -n "${OO_SDK_CC_55_OR_HIGHER}" ] 277 then 278 export OO_SDK_CC_55_OR_HIGHER 279 fi 280fi 281 282# Add directory of the Java tools to the path, if necessary. 283if [ -n "${OO_SDK_JAVA_HOME}" ] 284then 285 PATH=${OO_SDK_JAVA_HOME}/${javadir}:${PATH} 286# JAVA_HOME=${OO_SDK_JAVA_HOME} 287# export JAVA_HOME 288 export OO_SDK_JAVA_HOME 289 290 export PATH 291fi 292 293export PATH 294 295if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${stldebug}.${soext}" ] 296then 297 STLDEBUG=${stldebug} 298 export STLDEBUG 299fi 300 301if [ "${platform}" = "MacOSX" ] 302then 303# For URE, prepare symbolic links for libraries: 304# Only necessary on MacOSX, on other Unix systems the links are already prepared 305# in the SDK installation. 306 307# cleanup potential old links first 308 rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \ 309 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \ 310 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \ 311 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \ 312 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}" 313 314 if [ -L "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" ] 315 then 316 rm -rf "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" 317 fi 318 319# prepare links 320 if [ "${OO_SDK_URE_HOME}" ] 321 then 322 mkdir -p "${OO_SDK_OUT}/${directoryname}/lib" 323 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \ 324 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" 325 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \ 326 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" 327 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \ 328 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" 329 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \ 330 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" 331 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \ 332 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}" 333 334 if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" ] 335 then 336 ln -s "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" \ 337 "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" 338 fi 339 fi 340fi 341 342 343# Prepare shell with all necessary environment variables. 344echo 345echo " ************************************************************************" 346echo " *" 347echo " * SDK environment is prepared for ${platform}" 348echo " *" 349echo " * SDK = $OO_SDK_HOME" 350echo " * Office = $OFFICE_HOME" 351echo " * Office Base = $OFFICE_BASE_HOME" 352echo " * URE = $OO_SDK_URE_HOME" 353echo " * Make = $OO_SDK_MAKE_HOME" 354echo " * Zip = $OO_SDK_ZIP_HOME" 355echo " * C++ Compiler = $OO_SDK_CPP_HOME" 356echo " * Java = $OO_SDK_JAVA_HOME" 357echo " * SDK Output directory = $OO_SDK_OUT" 358echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT" 359echo " *" 360echo " ************************************************************************" 361 362echo "]2;Shell prepared with the SDK environment" 363 364