Support non-standard Python executable names
[platform/upstream/ninja.git] / bootstrap.sh
1 #!/bin/sh
2
3 # Copyright 2011 Google Inc. All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -e
18
19 SYSTEMNAME=`uname -s`
20
21 # Compute system-specific CFLAGS/LDFLAGS as used in both in the below
22 # g++ call as well as in the later configure.py.
23 if [ "${SYSTEMNAME}" = "Linux" ]; then
24     export CFLAGS="${CFLAGS}"
25     export LDFLAGS="${LDFLAGS}"
26 elif [ "${SYSTEMNAME}" = "FreeBSD" ]; then
27     export CFLAGS="${CFLAGS} -I/usr/local/include"
28     export LDFLAGS="${LDFLAGS} -L/usr/local/lib"
29 fi
30
31 echo "Building ninja manually..."
32 mkdir -p build
33 ./src/inline.sh kBrowsePy < src/browse.py > build/browse_py.h
34
35 pattern='test\.cc$\|\.in\.cc$'
36 case "$SYSTEMNAME" in
37   MINGW32*)
38     pattern="$pattern"'\|/browse\.cc$\|/subprocess\.cc$'
39     ;;
40   *)
41     pattern="$pattern"'\|-win32\.cc$'
42     ;;
43 esac
44 srcs=$(ls src/*.cc | grep -v "$pattern")
45
46 ${CXX:-g++} -Wno-deprecated ${CFLAGS} ${LDFLAGS} -o ninja.bootstrap $srcs
47
48 echo "Building ninja using itself..."
49 python ./configure.py
50 ./ninja.bootstrap
51 rm ninja.bootstrap
52
53 echo "Done!"