blob: a593dc79c16ab03d787af8a9cef73d7a2388adbf [file] [log] [blame]
r.c.ladan@gmail.comec238db2014-06-02 20:39:42 +00001#!/usr/bin/env bash
evan@chromium.org5b834912012-01-13 23:33:35 +00002
scottmg@chromium.orgc7bf35f2012-04-13 20:17:29 +00003# Copyright (c) 2012 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
thakis@chromium.orgdf0fcd62012-01-14 01:37:46 +00007OS="$(uname -s)"
thakis@chromium.orgfdf5ca82012-11-01 21:50:26 +00008THIS_DIR="$(dirname "${0}")"
thakis@chromium.orgdf0fcd62012-01-14 01:37:46 +00009
thakis@chromium.orga5957db2012-12-11 22:15:40 +000010function print_help() {
11cat <<-EOF
12No prebuilt ninja binary was found for this system.
13Try building your own binary by doing:
14 cd ~
Takuto Ikutaa21a7c52018-12-03 12:24:53 +000015 git clone https://github.com/ninja-build/ninja.git -b v1.8.2
thakis@chromium.orgbf216bf2014-11-24 21:19:14 +000016 cd ninja && ./configure.py --bootstrap
thakis@chromium.orga5957db2012-12-11 22:15:40 +000017Then add ~/ninja/ to your PATH.
18EOF
19}
20
tony@chromium.org5f522232012-12-11 18:00:15 +000021case "$OS" in
22 Linux)
sbc@chromium.orga9f824d2013-10-08 18:29:50 +000023 MACHINE=$(uname -m)
tony@chromium.org5f522232012-12-11 18:00:15 +000024 case "$MACHINE" in
sbc@chromium.orga9f824d2013-10-08 18:29:50 +000025 i?86|x86_64)
26 LONG_BIT=$(getconf LONG_BIT)
27 # We know we are on x86 but we need to use getconf to determine
Quinten Yearsley442fb642016-12-15 15:38:27 -080028 # bittage of the userspace install (e.g. when running 32-bit userspace
sbc@chromium.orga9f824d2013-10-08 18:29:50 +000029 # on x86_64 kernel)
30 exec "${THIS_DIR}/ninja-linux${LONG_BIT}" "$@";;
31 *)
32 echo Unknown architecture \($MACHINE\) -- unable to run ninja.
33 print_help
34 exit 1;;
tony@chromium.org5f522232012-12-11 18:00:15 +000035 esac
36 ;;
37 Darwin) exec "${THIS_DIR}/ninja-mac" "$@";;
38 CYGWIN*) exec cmd.exe /c $(cygpath -t windows $0).exe "$@";;
primiano@chromium.org1019fe72016-01-28 19:56:39 +000039 MINGW*) cmd.exe //c $0.exe "$@";;
tony@chromium.org5f522232012-12-11 18:00:15 +000040 *) echo "Unsupported OS ${OS}"
thakis@chromium.orga5957db2012-12-11 22:15:40 +000041 print_help
tony@chromium.org5f522232012-12-11 18:00:15 +000042 exit 1;;
43esac