-#!/bin/bash
+#!/bin/sh
# Copyright 2011 Google Inc. All Rights Reserved.
#
set -e
+SYSTEMNAME=`uname -s`
+
+if [ "${SYSTEMNAME}" = "Linux" ]; then
+ EXTRA_CFLAGS=
+ EXTRA_LDFLAGS=
+elif [ "${SYSTEMNAME}" = "FreeBSD" ]; then
+ EXTRA_CFLAGS="-I/usr/local/include"
+ EXTRA_LDFLAGS="-L/usr/local/lib -lexecinfo"
+fi
+
cat >config.ninja <<EOT
# This file is generated by bootstrap.sh.
-conf_cflags = -O2
-conf_ldflags = -s
+conf_cflags = -O2 ${EXTRA_CFLAGS}
+conf_ldflags = -s ${EXTRA_LDFLAGS}
# When developing:
-# conf_cflags = -g -Wall
-# conf_ldlags =
+# conf_cflags = -g -Wall ${EXTRA_CFLAGS}
+# conf_ldlags = ${EXTRA_LDFLAGS}
EOT
echo "Building ninja manually..."
srcs=$(ls src/*.cc | grep -v test)
-g++ -Wno-deprecated -o ninja.bootstrap $srcs
+if [ "${SYSTEMNAME}" = "Linux" ]; then
+ g++ -Wno-deprecated -o ninja.bootstrap $srcs
+elif [ "${SYSTEMNAME}" = "FreeBSD" ]; then
+ g++ -Wno-deprecated ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o ninja.bootstrap $srcs
+fi
echo "Building ninja using itself..."
./ninja.bootstrap ninja