1#! /bin/sh 2# 3# This file is part of the LibreOffice project. 4# 5# This Source Code Form is subject to the terms of the Mozilla Public 6# License, v. 2.0. If a copy of the MPL was not distributed with this 7# file, You can obtain one at http://mozilla.org/MPL/2.0/. 8# 9# This file incorporates work covered by the following license notice: 10# 11# Licensed to the Apache Software Foundation (ASF) under one or more 12# contributor license agreements. See the NOTICE file distributed 13# with this work for additional information regarding copyright 14# ownership. The ASF licenses this file to you under the Apache 15# License, Version 2.0 (the "License"); you may not use this file 16# except in compliance with the License. You may obtain a copy of 17# the License at http://www.apache.org/licenses/LICENSE-2.0 . 18# 19 20# This script starts a new shell and sets all environment variables, which 21# are necessary for building the examples of the Office Development Kit. 22# The Script was developed for the operating systems Solaris, Linux and MacOS. 23 24# The SDK name 25OO_SDK_NAME=@OO_SDK_NAME@ 26export OO_SDK_NAME 27 28# Installation directory of the Software Development Kit. 29# Example: OO_SDK_HOME=/opt/libreoffice/basis3.4/sdk 30OO_SDK_HOME='@OO_SDK_HOME@' 31 32# Office installation directory. 33# Example: OFFICE_HOME=/opt/libreoffice 34OFFICE_HOME='@OFFICE_HOME@' 35export OFFICE_HOME 36 37# Directory of the make command. 38# Example: OO_SDK_MAKE_HOME=/usr/bin 39OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@ 40 41# Directory of the zip command. 42# Example: OO_SDK_ZIP_HOME=/usr/bin 43OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@ 44 45# Directory of the cat command. 46# Example: OO_SDK_CAT_HOME=/usr/bin 47OO_SDK_CAT_HOME=@OO_SDK_CAT_HOME@ 48 49# Directory of the sed command. 50# Example: OO_SDK_SED_HOME=/usr/bin 51OO_SDK_SED_HOME=@OO_SDK_SED_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# Directory of the Java SDK. 58# Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10 59OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@ 60 61# Special output directory 62# Example: OO_SDK_OUTPUT_DIR=$HOME 63OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@ 64 65# Environment variable to enable auto deployment of example components 66# Example: SDK_AUTO_DEPLOYMENT=YES 67SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@ 68export SDK_AUTO_DEPLOYMENT 69 70# Check installation path for the OpenOffice Development Kit. 71if [ -z "${OO_SDK_HOME}" ] 72then 73 echo Error: Please insert a correct value for the variable OO_SDK_HOME. 74 exit 0 75fi 76 77export OO_SDK_HOME 78 79# Get the operating system. 80sdk_platform=`/bin/sh ${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4` 81 82# Set the directory name. 83programdir=program 84sdk_lo_java_dir=program/classes 85case ${sdk_platform} in 86 darwin*) 87 programdir="Contents/MacOS" 88 sdk_lo_java_dir=Contents/Resources/java 89 ;; 90esac 91 92# Set office program path (only set when using an Office). 93OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir} 94export OFFICE_PROGRAM_PATH 95 96# Set UNO path, necessary to ensure that the cpp examples using the 97# new UNO bootstrap mechanism use the configured office installation (only set 98# when using an Office). 99UNO_PATH=${OFFICE_PROGRAM_PATH} 100export UNO_PATH 101 102case ${sdk_platform} in 103 darwin*) 104 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH} 105 OO_SDK_URE_LIB_DIR=${OFFICE_HOME}/Contents/Frameworks 106 OO_SDK_URE_JAVA_DIR=${OFFICE_HOME}/${sdk_lo_java_dir} 107 ;; 108 *) 109 OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH} 110 OO_SDK_URE_LIB_DIR=${OFFICE_PROGRAM_PATH} 111 OO_SDK_URE_JAVA_DIR=${OFFICE_PROGRAM_PATH}/classes 112 ;; 113esac 114export OO_SDK_URE_BIN_DIR 115export OO_SDK_URE_LIB_DIR 116export OO_SDK_URE_JAVA_DIR 117 118OO_SDK_OUT=$OO_SDK_HOME 119# Prepare appropriate output directory. 120if [ -n "${OO_SDK_OUTPUT_DIR}" ] 121then 122 OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME} 123 export OO_SDK_OUT 124fi 125 126# Set the directory name. 127case ${sdk_platform} in 128 solaris*) 129 sdk_proctype=`/bin/sh ${OO_SDK_HOME}/config.guess | cut -d"-" -f1` 130 if [ "${sdk_proctype}" = "sparc" ] 131 then 132 directoryname=solsparc 133 platform='Solaris Sparc' 134 else 135 directoryname=solintel 136 platform='Solaris x86' 137 fi 138 comid=gcc3 139 soext=so 140 exampleout=SOLARISexample.out 141 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 142 export LD_LIBRARY_PATH 143 ;; 144 145 darwin*) 146 directoryname=macosx 147 comid=gcc3 148 soext=dylib 149 exampleout=MACOSXexample.out 150 platform=MacOSX 151 DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH} 152 export DYLD_LIBRARY_PATH 153 ;; 154 155 linux-gnu*) 156 directoryname=linux 157 comid=gcc3 158 soext=so 159 exampleout=LINUXexample.out 160 platform=Linux 161 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 162 export LD_LIBRARY_PATH 163 ;; 164 165 freebsd*) 166 directoryname=freebsd 167 comid=gcc3 168 soext=so 169 exampleout=FREEBSDexample.out 170 platform=FreeBSD 171 LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH} 172 export LD_LIBRARY_PATH 173 174 if [ -e "/sbin/sysctl" ] 175 then 176 OSVERSION=`/sbin/sysctl -n kern.osreldate` 177 else 178 OSVERSION=`/usr/sbin/sysctl -n kern.osreldate` 179 fi 180 if [ $OSVERSION -lt 500016 ] 181 then 182 PTHREAD_CFLAGS=-D_THREAD_SAFE 183 PTHREAD_LIBS=-pthread 184 export PTHREAD_CFLAGS 185 export PTHREAD_LIBS 186 elif [ $OSVERSION -lt 502102 ] 187 then 188 PTHREAD_CFLAGS=-D_THREAD_SAFE 189 PTHREAD_LIBS=-lc_r 190 export PTHREAD_CFLAGS 191 export PTHREAD_LIBS 192 else 193 PTHREAD_LIBS=-pthread 194 export PTHREAD_LIBS 195 fi 196 ;; 197esac 198 199# Add directory of the SDK tools to the path. 200PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:${PATH} 201 202# Set the classpath 203CLASSPATH=${OO_SDK_URE_JAVA_DIR}/libreoffice.jar:${OO_SDK_URE_JAVA_DIR}/unoloader.jar:${CLASSPATH} 204export CLASSPATH 205 206 207# Add directory of the command make to the path, if necessary. 208if [ -n "${OO_SDK_MAKE_HOME}" ] 209then 210 PATH=${OO_SDK_MAKE_HOME}:${PATH} 211 export OO_SDK_MAKE_HOME 212fi 213 214# Add directory of the zip tool to the path, if necessary. 215if [ -n "${OO_SDK_ZIP_HOME}" ] 216then 217 PATH=${OO_SDK_ZIP_HOME}:${PATH} 218 export OO_SDK_ZIP_HOME 219fi 220 221# Add directory of the sed tool to the path, if necessary. 222if [ -n "${OO_SDK_SED_HOME}" ] 223then 224 PATH=${OO_SDK_SED_HOME}:${PATH} 225 export OO_SDK_SED_HOME 226fi 227 228# Add directory of the cat tool to the path, if necessary. 229if [ -n "${OO_SDK_CAT_HOME}" ] 230then 231 PATH=${OO_SDK_CAT_HOME}:${PATH} 232 export OO_SDK_CAT_HOME 233fi 234 235# Add directory of the C++ tools to the path, if necessary. 236if [ -n "${OO_SDK_CPP_HOME}" ] 237then 238 PATH=${OO_SDK_CPP_HOME}:${PATH} 239 export OO_SDK_CPP_HOME 240fi 241 242# Add directory of the Java tools to the path, if necessary. 243if [ -n "${OO_SDK_JAVA_HOME}" ] 244then 245 PATH=${OO_SDK_JAVA_HOME}/bin:${PATH} 246# JAVA_HOME=${OO_SDK_JAVA_HOME} 247# export JAVA_HOME 248 export OO_SDK_JAVA_HOME 249 250 export PATH 251fi 252 253export PATH 254 255if [ "${platform}" = "MacOSX" ] 256then 257# For URE, prepare symbolic links for libraries: 258# Only necessary on MacOSX, on other Unix systems the links are already prepared 259# in the SDK installation. 260 261# cleanup potential old links first 262 rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \ 263 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \ 264 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \ 265 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \ 266 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}" 267 268# prepare links 269 mkdir -p "${OO_SDK_OUT}/${directoryname}/lib" 270 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \ 271 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" 272 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \ 273 "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" 274 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \ 275 "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" 276 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \ 277 "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" 278 ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \ 279 "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}" 280fi 281 282 283# Prepare shell with all necessary environment variables. 284echo 285echo " ************************************************************************" 286echo " *" 287echo " * SDK environment is prepared for ${platform}" 288echo " *" 289echo " * SDK = $OO_SDK_HOME" 290echo " * Office = $OFFICE_HOME" 291echo " * Make = $OO_SDK_MAKE_HOME" 292echo " * Zip = $OO_SDK_ZIP_HOME" 293echo " * cat = $OO_SDK_CAT_HOME" 294echo " * sed = $OO_SDK_SED_HOME" 295echo " * C++ Compiler = $OO_SDK_CPP_HOME" 296echo " * Java = $OO_SDK_JAVA_HOME" 297echo " * SDK Output directory = $OO_SDK_OUT" 298echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT" 299echo " *" 300echo " ************************************************************************" 301