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