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