|
| 1 | +#!/bin/sh |
| 2 | +set -e |
| 3 | +set -x |
| 4 | + |
| 5 | +info() |
| 6 | +{ |
| 7 | + local green="\033[1;32m" |
| 8 | + local normal="\033[0m" |
| 9 | + echo "[${green}build${normal}] $1" |
| 10 | +} |
| 11 | + |
| 12 | +ARCH="x86_64" |
| 13 | +MINIMAL_OSX_VERSION="10.6" |
| 14 | +OSX_VERSION=$(xcodebuild -showsdks | grep macosx | sort | tail -n 1 | awk '{print substr($NF,7)}') |
| 15 | +SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk |
| 16 | +BUILD_MODE="release" |
| 17 | + |
| 18 | +# TODO: configure to compile specify 3rd party libraries |
| 19 | +OPTIONS="" |
| 20 | + |
| 21 | +usage() |
| 22 | +{ |
| 23 | +cat << EOF |
| 24 | +usage: $0 [options] |
| 25 | +Build cocos2d-x 3rd party libraries for mac |
| 26 | +OPTIONS: |
| 27 | + -h Show some help |
| 28 | + -q Be quiet |
| 29 | + -k <sdk> Use the specified sdk (default: $SDKROOT) |
| 30 | + -a <arch> Use the specified arch (default: $ARCH) |
| 31 | + -l <libname> Use the specified library name |
| 32 | + -m <build mode> Build on debug or release mode(default: release) |
| 33 | +EOF |
| 34 | +} |
| 35 | + |
| 36 | +spushd() |
| 37 | +{ |
| 38 | + pushd "$1" > /dev/null |
| 39 | +} |
| 40 | + |
| 41 | +spopd() |
| 42 | +{ |
| 43 | + popd > /dev/null |
| 44 | +} |
| 45 | + |
| 46 | +while getopts "hvk:a:l:m:" OPTION |
| 47 | +do |
| 48 | + case $OPTION in |
| 49 | + h) |
| 50 | + usage |
| 51 | + exit 1 |
| 52 | + ;; |
| 53 | + q) |
| 54 | + set +x |
| 55 | + QUIET="yes" |
| 56 | + ;; |
| 57 | + a) |
| 58 | + ARCH=$OPTARG |
| 59 | + ;; |
| 60 | + l) |
| 61 | + OPTIONS=--enable-$OPTARG |
| 62 | + ;; |
| 63 | + k) |
| 64 | + SDKROOT=$OPTARG |
| 65 | + ;; |
| 66 | + m) |
| 67 | + BUILD_MODE=$OPTARG |
| 68 | + ;; |
| 69 | + esac |
| 70 | +done |
| 71 | + |
| 72 | +if test -z "$OPTIONS" |
| 73 | +then |
| 74 | + echo "You must specify a OPTIONS parameter." |
| 75 | + usage |
| 76 | + exit 1 |
| 77 | +fi |
| 78 | + |
| 79 | +shift $(($OPTIND - 1)) |
| 80 | + |
| 81 | +if [ "x$1" != "x" ]; then |
| 82 | + usage |
| 83 | + exit 1 |
| 84 | +fi |
| 85 | + |
| 86 | +if [ $BUILD_MODE = "release" ]; then |
| 87 | + OPTIM="-O3 -DNDEBUG" |
| 88 | +fi |
| 89 | + |
| 90 | +if [ $BUILD_MODE = "debug" ]; then |
| 91 | + OPTIM="-O0 -g -DDEBUG" |
| 92 | +fi |
| 93 | +# |
| 94 | +# Various initialization |
| 95 | +# |
| 96 | +out="/dev/stdout" |
| 97 | +if [ "$QUIET" = "yes" ]; then |
| 98 | + out="/dev/null" |
| 99 | +fi |
| 100 | + |
| 101 | +info "Building 3rd party libraries for the Mac OS X" |
| 102 | +cocos_root=`pwd`/../.. |
| 103 | + |
| 104 | +# FIXME: on MacOSX, we don't need to set the CC/CXX compiler indicators |
| 105 | +# export CC="xcrun clang" |
| 106 | +# export CXX="xcrun clang++" |
| 107 | +# export OBJC="xcrun clang" |
| 108 | +export OSX_VERSION |
| 109 | +export SDKROOT |
| 110 | +export PATH="${cocos_root}/extras/tools/bin:$PATH" |
| 111 | +PREFIX="${cocos_root}/contrib/install-mac/${ARCH}" |
| 112 | + |
| 113 | +# |
| 114 | +# build 3rd party libraries |
| 115 | +# |
| 116 | +info "Building static libraries" |
| 117 | +spushd "${cocos_root}/contrib" |
| 118 | +mkdir -p "mac-${ARCH}" && cd "mac-${ARCH}" |
| 119 | +../bootstrap ${OPTIONS} --host=${ARCH}-apple-darwin --prefix=${PREFIX} > $out |
| 120 | + |
| 121 | +echo "OPTIM := ${OPTIM}" >> config.mak |
| 122 | +echo "MAC_ARCH := ${ARCH}" >> config.mak |
| 123 | +# |
| 124 | +# make |
| 125 | +# |
| 126 | +# FIXME: Can't use parallax make, |
| 127 | +# core_count=`sysctl -n machdep.cpu.core_count` |
| 128 | +# let jobs=$core_count+1 |
| 129 | +# info "Running make -j$jobs" |
| 130 | +make fetch |
| 131 | +make list |
| 132 | +make |
0 commit comments