xref: /trunk/main/odk/setsdkenv_unix (revision a412ed64)
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
23OSTYPE=`uname -s`
24HOSTNAME=`hostname`
25CURRENTDIR=`/bin/pwd`
26SDKTMPDIR=`dirname $0`
27OO_SDK_HOME=`(cd $SDKTMPDIR && pwd && cd $CURRENTDIR) | head -n 1`
28OOVERSION=`cat $OO_SDK_HOME/settings/dk.mk | tail -2 | head -n 1 | cut -d"=" -f2 | cut -d"." -f1,2`
29if [ "$OSTYPE" = "Darwin" ]
30then
31    OO_SDK_NAME=`basename $OO_SDK_HOME`
32else
33    OO_SDK_NAME=openoffice.org${OOVERSION}_sdk
34fi
35
36export OO_SDK_HOME
37
38if [ "$1" = "--force-configure" ]
39then
40    if [ -r $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh ]
41    then
42	rm $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh
43    fi
44    if [ -r $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.csh ]
45    then
46	rm $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.csh
47    fi
48    shift
49elif [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ -n "$1" ]
50then
51    echo
52    echo " using: setsdkenv_unix [options]"
53    echo ""
54    echo " options:"
55    echo "   --force-configure : force a new configuration of your SDK environment."
56    echo "                       Alternatively can you edit your SDK environment script directly:"
57    echo "                        $HOME/$OO_SDK_NAME/setsdkenv_unix.sh"
58    echo "   -h, --help        : print this help and exit"
59    echo
60    exit 1
61fi
62
63# source the prepared environment and start a new shell
64if [ -r $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh ]
65then
66    . $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh
67else
68    echo
69    echo " ************************************************************************"
70    echo " *"
71    echo " *  You have to configure your SDK environment first before you can"
72    echo " *  can use it! The configuration has to be done only once."
73    echo " *"
74    echo " ************************************************************************"
75    echo
76
77    perl $OO_SDK_HOME/configure.pl $HOSTNAME $OO_SDK_HOME $OO_SDK_NAME
78
79    . $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh
80fi
81
82"$SHELL" "$@"
83echo  Shell terminated.
84
85TERMHEAD=$HOSTNAME
86echo "]2;$TERMHEAD"
87