source: trunk/kBuild/env.sh@ 296

Last change on this file since 296 was 249, checked in by bird, 20 years ago

..

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
RevLine 
[224]1#!/bin/bash
2# $Id: env.sh 249 2005-04-03 00:42:29Z bird $
3## @file
4#
5# Environment setup script.
6#
7# Copyright (c) 2005 knut st. osmundsen <bird@innotek.de>
8#
9#
10# This file is part of kBuild.
11#
12# kBuild is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# kBuild is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with kBuild; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25#
26#
27#set -x
28
29# kBuild path.
30if [ -z "$PATH_KBUILD" ]; then
31 PATH_KBUILD=`readlink -f $0`
32 PATH_KBUILD=`dirname "$PATH_KBUILD"`
33fi
34if [ ! -f "$PATH_KBUILD/footer.kmk" -o ! -f "$PATH_KBUILD/header.kmk" -o ! -f "$PATH_KBUILD/rules.kmk" ]; then
35 echo "$0: error: PATH_KBUILD ($PATH_KBUILD) is not pointing to a popluated kBuild directory.";
36 sleep 1;
37 exit 1;
38fi
39export PATH_KBUILD
40echo "dbg: PATH_KBUILD=$PATH_KBUILD"
41
42# Type.
43if [ -z "$BUILD_TYPE" ]; then
44 BUILD_TYPE=debug
45fi
46export BUILD_TYPE
47echo "dbg: BUILD_TYPE=$BUILD_TYPE"
48
49
50# Host platform.
51if [ -z "$BUILD_PLATFORM_CPU" ]; then
52 BUILD_PLATFORM_CPU=`uname -m`
53fi
54export BUILD_PLATFORM_CPU
55echo "dbg: BUILD_PLATFORM_CPU=$BUILD_PLATFORM_CPU"
56
57if [ -z "$BUILD_PLATFORM_ARCH" ]; then
58 case "$BUILD_PLATFORM_CPU" in
59 i[3456789]86|x86)
60 BUILD_PLATFORM_ARCH='x86'
61 ;;
62
63 *) echo "$0: unknown cpu/arch - $BUILD_PLATFORM_CPU"
64 sleep 1
65 exit 1
66 ;;
67 esac
68
69fi
70export BUILD_PLATFORM_ARCH
71echo "dbg: BUILD_PLATFORM_ARCH=$BUILD_PLATFORM_ARCH"
72
73
74if [ -z "$BUILD_PLATFORM" ]; then
75 BUILD_PLATFORM=`uname -o`
76 case "$BUILD_PLATFORM" in
77 linux|Linux|GNU/Linux|LINUX)
78 BUILD_PLATFORM=linux
79 ;;
80
81 os2|OS/2|OS2)
82 BUILD_PLATFORM=os2
83 ;;
84
85 freebsd|FreeBSD|FREEBSD)
86 BUILD_PLATFORM=freebsd
87 ;;
88
89 openbsd|OpenBSD|OPENBSD)
90 BUILD_PLATFORM=openbsd
91 ;;
92
93 netbsd|NetBSD|NETBSD)
94 BUILD_PLATFORM=netbsd
95 ;;
96
97 *)
98 echo "$0: unknown os $BUILD_PLATFORM"
99 sleep 1
100 exit 1
101 ;;
102 esac
103fi
104export BUILD_PLATFORM
105echo "dbg: BUILD_PLATFORM=$BUILD_PLATFORM"
106
107
108# Target platform.
109if [ -z "$BUILD_TARGET_CPU" ]; then
110 BUILD_TARGET_CPU=$BUILD_PLATFORM_CPU
111fi
112export BUILD_TARGET_CPU
113echo "dbg: BUILD_TARGET_CPU=$BUILD_TARGET_CPU"
114
115if [ -z "$BUILD_TARGET_ARCH" ]; then
116 case "$BUILD_TARGET_CPU" in
117 i[3456789]86|x86)
118 BUILD_TARGET_ARCH='x86'
119 ;;
120
121 *) echo "$0: unknown cpu/arch - $BUILD_TARGET_CPU"
122 sleep 1
123 exit 1
124 ;;
125 esac
126
127fi
128export BUILD_TARGET_ARCH
129echo "dbg: BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH"
130
131if [ -z "$BUILD_TARGET" ]; then
132 BUILD_TARGET=$BUILD_PLATFORM
133fi
134export BUILD_TARGET
[249]135echo "dbg: BUILD_TARGET=$BUILD_TARGET"
[224]136
137
138# Determin executable extension and path separator.
139_SUFF_EXE=
140_PATH_SEP=":"
141case "$BUILD_PLATFORM" in
142 os2|win32|winnt|win2k|winxp)
143 _SUFF_EXE=".exe"
144 _PATH_SEP=";"
145 ;;
146esac
147
148# Make shell
149export MAKESHELL="$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/ash${_SUFF_EXE}";
150
151# The PATH.
152PATH="$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${_PATH_SEP}$PATH"
153export PATH
154echo "dbg: PATH=$PATH"
155
156# Sanity and x bits.
157if [ ! -d "$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/" ]; then
158 echo "$0: warning: The bin directory for this platform doesn't exists. ($PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/)"
159else
160 for prog in kmk kDepCCxx cat cp mkdir mv rm sed;
161 do
162 chmod a+x $PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${prog} > /dev/null 2>&1
163 if [ ! -f "$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${prog}${_SUFF_EXE}" ]; then
164 echo "$0: warning: The ${prog} program doesn't exist for this platform. ($PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${prog}${_SUFF_EXE})"
165 fi
166 done
167fi
168
169unset _SUFF_EXE
170unset _PATH_SEP
171
172# Execute command or spawn shell.
173if [ $# -eq 0 ]; then
174 echo "$0: info: Spawning work shell..."
175 if [ "$TERM" != 'dumb' ] && [ -n "$BASH" ]; then
176 export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
177 fi
178 $SHELL -i
179else
180 echo "$0: info: Executing command: $*"
181 $*
182fi
Note: See TracBrowser for help on using the repository browser.