use two space indents

This commit is contained in:
Thomas Pöchtrager 2014-04-06 15:58:15 +02:00
parent 84377413a5
commit c0b2cf103d
7 changed files with 319 additions and 319 deletions

194
build.sh
View File

@ -7,60 +7,60 @@ source tools/tools.sh
# find sdk version to use # find sdk version to use
function guess_sdk_version() function guess_sdk_version()
{ {
tmp1= tmp1=
tmp2= tmp2=
tmp3= tmp3=
file= file=
sdk= sdk=
guess_sdk_version_result= guess_sdk_version_result=
sdkcount=`find tarballs/ -type f | grep MacOSX | wc -l` sdkcount=`find tarballs/ -type f | grep MacOSX | wc -l`
if [ $sdkcount -eq 0 ]; then if [ $sdkcount -eq 0 ]; then
echo no SDK found in 'tarballs/'. please see README.md echo no SDK found in 'tarballs/'. please see README.md
exit 1 exit 1
elif [ $sdkcount -gt 1 ]; then elif [ $sdkcount -gt 1 ]; then
sdks=`find tarballs/ | grep MacOSX` sdks=`find tarballs/ | grep MacOSX`
for sdk in $sdks; do echo $sdk; done for sdk in $sdks; do echo $sdk; done
echo 'more than one MacOSX SDK tarball found. please set' echo 'more than one MacOSX SDK tarball found. please set'
echo 'SDK_VERSION environment variable for the one you want' echo 'SDK_VERSION environment variable for the one you want'
echo '(for example: SDK_VERSION=10.x [OSX_VERSION_MIN=10.x] ./build.sh)' echo '(for example: SDK_VERSION=10.x [OSX_VERSION_MIN=10.x] ./build.sh)'
exit 1 exit 1
else else
sdk=`find tarballs/ | grep MacOSX` sdk=`find tarballs/ | grep MacOSX`
tmp2=`echo ${sdk/bz2/} | sed s/[^0-9.]//g` tmp2=`echo ${sdk/bz2/} | sed s/[^0-9.]//g`
tmp3=`echo $tmp2 | sed s/\\\.*$//g` tmp3=`echo $tmp2 | sed s/\\\.*$//g`
guess_sdk_version_result=$tmp3 guess_sdk_version_result=$tmp3
echo 'found SDK version' $guess_sdk_version_result 'at tarballs/'`basename $sdk` echo 'found SDK version' $guess_sdk_version_result 'at tarballs/'`basename $sdk`
fi
if [ $guess_sdk_version_result ]; then
if [ $guess_sdk_version_result = 10.4 ]; then
guess_sdk_version_result=10.4u
fi fi
if [ $guess_sdk_version_result ]; then fi
if [ $guess_sdk_version_result = 10.4 ]; then export guess_sdk_version_result
guess_sdk_version_result=10.4u
fi
fi
export guess_sdk_version_result
} }
# make sure there is actually a file with the given SDK_VERSION # make sure there is actually a file with the given SDK_VERSION
function verify_sdk_version() function verify_sdk_version()
{ {
sdkv=$1 sdkv=$1
for file in tarballs/*; do for file in tarballs/*; do
if [ `echo $file | grep OSX.*$sdkv` ]; then if [ `echo $file | grep OSX.*$sdkv` ]; then
echo "verified at "$file echo "verified at "$file
sdk=$file sdk=$file
fi
done
if [ ! $sdk ] ; then
echo cant find SDK for OSX $sdkv in tarballs. exiting
exit
fi fi
done
if [ ! $sdk ] ; then
echo cant find SDK for OSX $sdkv in tarballs. exiting
exit
fi
} }
if [ $SDK_VERSION ]; then if [ $SDK_VERSION ]; then
echo 'SDK VERSION set in environment variable:' $SDK_VERSION echo 'SDK VERSION set in environment variable:' $SDK_VERSION
test $SDK_VERSION = 10.4 && SDK_VERSION=10.4u test $SDK_VERSION = 10.4 && SDK_VERSION=10.4u
else else
guess_sdk_version guess_sdk_version
SDK_VERSION=$guess_sdk_version_result SDK_VERSION=$guess_sdk_version_result
fi fi
verify_sdk_version $SDK_VERSION verify_sdk_version $SDK_VERSION
@ -69,11 +69,11 @@ verify_sdk_version $SDK_VERSION
# You can comment this variable out, # You can comment this variable out,
# if you want to use the compiler's default value # if you want to use the compiler's default value
if [ -z "$OSX_VERSION_MIN" ]; then if [ -z "$OSX_VERSION_MIN" ]; then
if [ $SDK_VERSION = 10.4u ]; then if [ $SDK_VERSION = 10.4u ]; then
OSX_VERSION_MIN=10.4 OSX_VERSION_MIN=10.4
else else
OSX_VERSION_MIN=10.5 OSX_VERSION_MIN=10.5
fi fi
fi fi
# ld version # ld version
@ -89,17 +89,17 @@ PATCH_DIR=$BASE_DIR/patches
SDK_DIR=$TARGET_DIR/SDK SDK_DIR=$TARGET_DIR/SDK
if [ -z "$OSX_VERSION_MIN" ]; then if [ -z "$OSX_VERSION_MIN" ]; then
OSX_VERSION_MIN="default" OSX_VERSION_MIN="default"
fi fi
case $SDK_VERSION in case $SDK_VERSION in
10.4*) TARGET=darwin8 ;; 10.4*) TARGET=darwin8 ;;
10.5*) TARGET=darwin9 ;; 10.5*) TARGET=darwin9 ;;
10.6*) TARGET=darwin10 ;; 10.6*) TARGET=darwin10 ;;
10.7*) TARGET=darwin11 ;; 10.7*) TARGET=darwin11 ;;
10.8*) TARGET=darwin12 ;; 10.8*) TARGET=darwin12 ;;
10.9*) TARGET=darwin13 ;; 10.9*) TARGET=darwin13 ;;
*) echo "Invalid SDK Version" && exit 1 ;; *) echo "Invalid SDK Version" && exit 1 ;;
esac esac
echo "" echo ""
@ -138,16 +138,16 @@ pushd $BUILD_DIR &>/dev/null
function remove_locks() function remove_locks()
{ {
rm -rf $BUILD_DIR/have_cctools* rm -rf $BUILD_DIR/have_cctools*
} }
source $BASE_DIR/tools/trap_exit.sh source $BASE_DIR/tools/trap_exit.sh
if [ "`ls $TARBALL_DIR/cctools*.tar.* | wc -l | tr -d ' '`" != "1" ]; then if [ "`ls $TARBALL_DIR/cctools*.tar.* | wc -l | tr -d ' '`" != "1" ]; then
echo "" echo ""
echo "There should only be one cctools*.tar.* archive in the tarballs directory" echo "There should only be one cctools*.tar.* archive in the tarballs directory"
echo "" echo ""
exit 1 exit 1
fi fi
CCTOOLS_REVHASH=`ls $TARBALL_DIR/cctools*.tar.* | tr '_' ' ' | tr '.' ' ' | awk '{print $3}'` CCTOOLS_REVHASH=`ls $TARBALL_DIR/cctools*.tar.* | tr '_' ' ' | tr '.' ' ' | awk '{print $3}'`
@ -183,8 +183,8 @@ pushd $TARGET_DIR/bin &>/dev/null
CCTOOLS=`find . -name "x86_64-apple-darwin*"` CCTOOLS=`find . -name "x86_64-apple-darwin*"`
CCTOOLS=($CCTOOLS) CCTOOLS=($CCTOOLS)
for CCTOOL in ${CCTOOLS[@]}; do for CCTOOL in ${CCTOOLS[@]}; do
CCTOOL_I386=`echo "$CCTOOL" | sed 's/x86_64/i386/g'` CCTOOL_I386=`echo "$CCTOOL" | sed 's/x86_64/i386/g'`
ln -sf $CCTOOL $CCTOOL_I386 ln -sf $CCTOOL $CCTOOL_I386
done done
popd &>/dev/null popd &>/dev/null
@ -239,12 +239,12 @@ if [ ! -f "have_cctools_$TARGET" ]; then
function check_cctools() function check_cctools()
{ {
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-lipo" ] || exit 1 [ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-lipo" ] || exit 1
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ld" ] || exit 1 [ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ld" ] || exit 1
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-nm" ] || exit 1 [ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-nm" ] || exit 1
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ar" ] || exit 1 [ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ar" ] || exit 1
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ranlib" ] || exit 1 [ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ranlib" ] || exit 1
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-strip" ] || exit 1 [ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-strip" ] || exit 1
} }
check_cctools i386 check_cctools i386
@ -260,15 +260,15 @@ set +e
ls $TARBALL_DIR/MacOSX$SDK_VERSION* &>/dev/null ls $TARBALL_DIR/MacOSX$SDK_VERSION* &>/dev/null
while [ $? -ne 0 ] while [ $? -ne 0 ]
do do
echo "" echo ""
echo "Get the MacOSX$SDK_VERSION SDK and move it into $TARBALL_DIR" echo "Get the MacOSX$SDK_VERSION SDK and move it into $TARBALL_DIR"
echo "(see README for SDK download links)" echo "(see README for SDK download links)"
echo "" echo ""
echo "You can press ctrl-c to break the build process," echo "You can press ctrl-c to break the build process,"
echo "if you restart ./build.sh then we will continue from here" echo "if you restart ./build.sh then we will continue from here"
echo "" echo ""
read -p "Press enter to continue" read -p "Press enter to continue"
ls $TARBALL_DIR/MacOSX$SDK_VERSION* &>/dev/null ls $TARBALL_DIR/MacOSX$SDK_VERSION* &>/dev/null
done done
set -e set -e
@ -277,9 +277,9 @@ extract $SDK 1 1
rm -rf $SDK_DIR/MacOSX$SDK_VERSION* 2>/dev/null rm -rf $SDK_DIR/MacOSX$SDK_VERSION* 2>/dev/null
if [ "`ls -l SDKs/*$SDK_VERSION* 2>/dev/null | wc -l | tr -d ' '`" != "0" ]; then if [ "`ls -l SDKs/*$SDK_VERSION* 2>/dev/null | wc -l | tr -d ' '`" != "0" ]; then
mv -f SDKs/*$SDK_VERSION* $SDK_DIR mv -f SDKs/*$SDK_VERSION* $SDK_DIR
else else
mv -f *OSX*$SDK_VERSION*sdk* $SDK_DIR mv -f *OSX*$SDK_VERSION*sdk* $SDK_DIR
fi fi
pushd $SDK_DIR/MacOSX$SDK_VERSION.sdk &>/dev/null pushd $SDK_DIR/MacOSX$SDK_VERSION.sdk &>/dev/null
@ -372,20 +372,20 @@ echo ""
if [ -n $OSX_VERSION_MIN ]; then if [ -n $OSX_VERSION_MIN ]; then
if [ `echo "${SDK_VERSION/u/}<$OSX_VERSION_MIN" | bc -l` -eq 1 ]; then if [ `echo "${SDK_VERSION/u/}<$OSX_VERSION_MIN" | bc -l` -eq 1 ]; then
echo "OSX_VERSION_MIN must be <= SDK_VERSION" echo "OSX_VERSION_MIN must be <= SDK_VERSION"
trap "" EXIT trap "" EXIT
exit 1 exit 1
elif [ `echo "$OSX_VERSION_MIN<10.4" | bc -l` -eq 1 ]; then elif [ `echo "$OSX_VERSION_MIN<10.4" | bc -l` -eq 1 ]; then
echo "OSX_VERSION_MIN must be >= 10.4" echo "OSX_VERSION_MIN must be >= 10.4"
trap "" EXIT trap "" EXIT
exit 1 exit 1
fi fi
if [ `echo "${SDK_VERSION/u/}>=10.9" | bc -l` -eq 1 ] && ( [ $OSX_VERSION_MIN == "default" ] || if [ `echo "${SDK_VERSION/u/}>=10.9" | bc -l` -eq 1 ] && ( [ $OSX_VERSION_MIN == "default" ] ||
[ `echo "$OSX_VERSION_MIN>=10.9" | bc -l` -eq 1 ] ); [ `echo "$OSX_VERSION_MIN>=10.9" | bc -l` -eq 1 ] );
then then
export SCRIPT=`basename $0` export SCRIPT=`basename $0`
./build_libcxx.sh || exit 0 ./build_libcxx.sh || exit 0
fi fi
fi # OSX_VERSION_MIN set fi # OSX_VERSION_MIN set
@ -396,16 +396,16 @@ test_compiler o32-clang++ $BASE_DIR/oclang/test.cpp
test_compiler o64-clang++ $BASE_DIR/oclang/test.cpp test_compiler o64-clang++ $BASE_DIR/oclang/test.cpp
if [ `echo "${SDK_VERSION/u/}>=10.7" | bc -l` -eq 1 ]; then if [ `echo "${SDK_VERSION/u/}>=10.7" | bc -l` -eq 1 ]; then
if [ ! -d "$SDK_DIR/MacOSX$SDK_VERSION.sdk/usr/include/c++/v1" ]; then if [ ! -d "$SDK_DIR/MacOSX$SDK_VERSION.sdk/usr/include/c++/v1" ]; then
echo ""
echo -n "Given SDK does not contain libc++ headers "
echo "(-stdlib=libc++ test may fail)"
echo -n "You may want to re-package your SDK using "
echo "'tools/gen_sdk_package.sh' on OS X"
fi
echo "" echo ""
test_compiler_cxx11 o32-clang++ $BASE_DIR/oclang/test_libcxx.cpp echo -n "Given SDK does not contain libc++ headers "
test_compiler_cxx11 o64-clang++ $BASE_DIR/oclang/test_libcxx.cpp echo "(-stdlib=libc++ test may fail)"
echo -n "You may want to re-package your SDK using "
echo "'tools/gen_sdk_package.sh' on OS X"
fi
echo ""
test_compiler_cxx11 o32-clang++ $BASE_DIR/oclang/test_libcxx.cpp
test_compiler_cxx11 o64-clang++ $BASE_DIR/oclang/test_libcxx.cpp
fi fi
echo "" echo ""

View File

@ -22,7 +22,7 @@ pushd $OSXCROSS_BUILD_DIR &>/dev/null
function remove_locks() function remove_locks()
{ {
rm -rf $OSXCROSS_BUILD_DIR/have_gcc* rm -rf $OSXCROSS_BUILD_DIR/have_gcc*
} }
source $BASE_DIR/tools/trap_exit.sh source $BASE_DIR/tools/trap_exit.sh
@ -48,23 +48,23 @@ mkdir -p build
pushd build &>/dev/null pushd build &>/dev/null
if [[ "`uname -s`" == *BSD ]]; then if [[ "`uname -s`" == *BSD ]]; then
export CPATH="/usr/local/include:/usr/pkg/include:$CPATH" export CPATH="/usr/local/include:/usr/pkg/include:$CPATH"
export LDFLAGS="-L/usr/local/lib -L/usr/pkg/lib $LDFLAGS" export LDFLAGS="-L/usr/local/lib -L/usr/pkg/lib $LDFLAGS"
export LD_LIBRARY_PATH="/usr/local/lib:/usr/pkg/lib:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="/usr/local/lib:/usr/pkg/lib:$LD_LIBRARY_PATH"
fi fi
../configure \ ../configure \
--target=x86_64-apple-$OSXCROSS_TARGET \ --target=x86_64-apple-$OSXCROSS_TARGET \
--with-ld=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-ld \ --with-ld=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-ld \
--with-as=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-as \ --with-as=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-as \
--with-sysroot=$OSXCROSS_SDK \ --with-sysroot=$OSXCROSS_SDK \
--disable-nls \ --disable-nls \
--enable-languages=c,c++,objc,obj-c++ \ --enable-languages=c,c++,objc,obj-c++ \
--without-headers \ --without-headers \
--enable-multilib \ --enable-multilib \
--enable-lto \ --enable-lto \
--enable-checking=release \ --enable-checking=release \
--prefix=$OSXCROSS_TARGET_DIR --prefix=$OSXCROSS_TARGET_DIR
$MAKE -j$JOBS $MAKE -j$JOBS
$MAKE install -j$JOBS $MAKE install -j$JOBS
@ -87,11 +87,11 @@ WRAPPER_DIR=`dirname $WRAPPER`
pushd $WRAPPER_DIR &>/dev/null pushd $WRAPPER_DIR &>/dev/null
if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
mv x86_64-apple-$OSXCROSS_TARGET-gcc x86_64-apple-$OSXCROSS_TARGET-base-gcc mv x86_64-apple-$OSXCROSS_TARGET-gcc x86_64-apple-$OSXCROSS_TARGET-base-gcc
mv x86_64-apple-$OSXCROSS_TARGET-g++ x86_64-apple-$OSXCROSS_TARGET-base-g++ mv x86_64-apple-$OSXCROSS_TARGET-g++ x86_64-apple-$OSXCROSS_TARGET-base-g++
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-gcc i386-apple-$OSXCROSS_TARGET-base-gcc ln -sf x86_64-apple-$OSXCROSS_TARGET-base-gcc i386-apple-$OSXCROSS_TARGET-base-gcc
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-g++ i386-apple-$OSXCROSS_TARGET-base-g++ ln -sf x86_64-apple-$OSXCROSS_TARGET-base-g++ i386-apple-$OSXCROSS_TARGET-base-g++
fi fi
ln -sf $WRAPPER_SCRIPT o32-gcc ln -sf $WRAPPER_SCRIPT o32-gcc

View File

@ -5,10 +5,10 @@ set -ex
test -z "$COMPRESSLEVEL" && COMPRESSLEVEL=9 test -z "$COMPRESSLEVEL" && COMPRESSLEVEL=9
if [ -n "$BINARYPACKAGE" ]; then if [ -n "$BINARYPACKAGE" ]; then
SUFFIX="" SUFFIX=""
else else
SUFFIX="_src" SUFFIX="_src"
BINARYPACKAGE="0" BINARYPACKAGE="0"
fi fi
TMPDIR=`mktemp -d` TMPDIR=`mktemp -d`
@ -24,40 +24,40 @@ mkdir osxcross
pushd osxcross pushd osxcross
if [ $BINARYPACKAGE != "1" ]; then if [ $BINARYPACKAGE != "1" ]; then
cp -r $BASEDIR/tarballs . cp -r $BASEDIR/tarballs .
cp -r $BASEDIR/patches . cp -r $BASEDIR/patches .
cp -r $BASEDIR/tools . cp -r $BASEDIR/tools .
cp -r $BASEDIR/oclang . cp -r $BASEDIR/oclang .
cp -r $BASEDIR/ogcc . cp -r $BASEDIR/ogcc .
else else
ldd `ls $BASEDIR/target/bin/x86_64-apple-darwin*-ld | head -n1` | grep "libLTO.so" &>/dev/null && \ ldd `ls $BASEDIR/target/bin/x86_64-apple-darwin*-ld | head -n1` | grep "libLTO.so" &>/dev/null && \
echo "-->> WARNING: ld is linked dynamically against libLTO.so! Consider recompiling with DISABLE_LTO_SUPPORT=1 <<--" && \ echo "-->> WARNING: ld is linked dynamically against libLTO.so! Consider recompiling with DISABLE_LTO_SUPPORT=1 <<--" && \
sleep 5 sleep 5
cp -r $BASEDIR/target/* . cp -r $BASEDIR/target/* .
cp $BASEDIR/build/cctools*/cctools/APPLE_LICENSE CCTOOLS.LICENSE cp $BASEDIR/build/cctools*/cctools/APPLE_LICENSE CCTOOLS.LICENSE
cp $BASEDIR/oclang/find_intrinsic_headers.sh bin/osxcross-fix-intrinsic-headers cp $BASEDIR/oclang/find_intrinsic_headers.sh bin/osxcross-fix-intrinsic-headers
READMEINSTALL="README_INSTALL" READMEINSTALL="README_INSTALL"
echo "- BINARY INSTALLATION INSTRUCTIONS -" > $READMEINSTALL echo "- BINARY INSTALLATION INSTRUCTIONS -" > $READMEINSTALL
echo "" >> $READMEINSTALL echo "" >> $READMEINSTALL
echo "Add " >> $READMEINSTALL echo "Add " >> $READMEINSTALL
echo "" >> $READMEINSTALL echo "" >> $READMEINSTALL
echo " \`<absolute path>/bin/osxcross-env\`" >> $READMEINSTALL echo " \`<absolute path>/bin/osxcross-env\`" >> $READMEINSTALL
echo "" >> $READMEINSTALL echo "" >> $READMEINSTALL
echo "To your ~/.profile or ~/.bashrc," >> $READMEINSTALL echo "To your ~/.profile or ~/.bashrc," >> $READMEINSTALL
echo "then restart your shell session." >> $READMEINSTALL echo "then restart your shell session." >> $READMEINSTALL
echo "" >> $READMEINSTALL echo "" >> $READMEINSTALL
echo "That's it." >> $READMEINSTALL echo "That's it." >> $READMEINSTALL
echo "" >> $READMEINSTALL echo "" >> $READMEINSTALL
fi fi
find $BASEDIR -maxdepth 1 -type f -print0 | xargs -0 -i cp {} . find $BASEDIR -maxdepth 1 -type f -print0 | xargs -0 -i cp {} .
if [ $BINARYPACKAGE == "1" ]; then if [ $BINARYPACKAGE == "1" ]; then
rm -f *.sh rm -f *.sh
rm -f TODO rm -f TODO
fi fi
rm -rf tarballs/gcc* rm -rf tarballs/gcc*

View File

@ -1,39 +1,43 @@
/* /***********************************************************************
* Copyright (C) 2012 by Thomas Poechtrager * OSXCross *
* t.poechtrager@gmail.com * Copyright (C) 2013, 2014 by Thomas Poechtrager *
* * t.poechtrager@gmail.com *
* OSXCross is free software: you can redistribute it and/or modify * *
* it under the terms of the GNU General Public License as published by * This program is free software; you can redistribute it and/or *
* the Free Software Foundation, either version 2 of the License, or * modify it under the terms of the GNU General Public License *
* (at your option) any later version. * as published by the Free Software Foundation; either version 2 *
* * of the License, or (at your option) any later version. *
* OSXCross is distributed in the hope that it will be useful, * *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful, *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* * GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License * *
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License *
*/ * along with this program; if not, write to the Free Software *
* Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***********************************************************************/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef __CYGWIN__ #ifdef __CYGWIN__
#define WIN32 #define WIN32
#endif //__CYGWIN__ #endif /* __CYGWIN__ */
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
#endif //WIN32 #endif /* WIN32 */
#ifdef __linux__ #ifdef __linux__
#define __USE_GNU #define __USE_GNU
#include <sched.h> #include <sched.h>
#undef __USE_GNU #undef __USE_GNU
#endif //__linux__ #endif /* __linux__ */
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) #if defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__) || defined(__APPLE__)
#include <unistd.h> #include <unistd.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
@ -41,59 +45,56 @@
#ifndef HW_AVAILCPU #ifndef HW_AVAILCPU
#define HW_AVAILCPU 25 #define HW_AVAILCPU 25
#endif //HW_AVAILCPU #endif /* HW_AVAILCPU */
#endif //BSD #endif /* BSD */
int getcpucount() int getcpucount() {
{
#ifdef WIN32 #ifdef WIN32
SYSTEM_INFO sysinfo; SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo); GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors; return sysinfo.dwNumberOfProcessors;
#else #else
#ifdef __linux__ #ifdef __linux__
cpu_set_t cs; cpu_set_t cs;
int i, cpucount = 0; int i, cpucount = 0;
CPU_ZERO(&cs); CPU_ZERO(&cs);
sched_getaffinity(0, sizeof(cs), &cs); sched_getaffinity(0, sizeof(cs), &cs);
for(i = 0; i < 128; i++) for (i = 0; i < 128; i++) {
{ if (CPU_ISSET(i, &cs))
if(CPU_ISSET(i, &cs)) cpucount++;
cpucount++; }
}
return cpucount ? cpucount : 1; return cpucount ? cpucount : 1;
#else #else
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) #if defined(__FreeBSD__) || defined(__NetBSD__) || \
int cpucount = 0; defined(__OpenBSD__) || defined(__APPLE__)
int mib[4]; int cpucount = 0;
size_t len = sizeof(cpucount); int mib[4];
size_t len = sizeof(cpucount);
mib[0] = CTL_HW; mib[0] = CTL_HW;
mib[1] = HW_AVAILCPU; mib[1] = HW_AVAILCPU;
sysctl(mib, 2, &cpucount, &len, NULL, 0);
if (cpucount < 1) {
mib[1] = HW_NCPU;
sysctl(mib, 2, &cpucount, &len, NULL, 0); sysctl(mib, 2, &cpucount, &len, NULL, 0);
}
if(cpucount < 1) return cpucount ? cpucount : 1;
{
mib[1] = HW_NCPU;
sysctl(mib, 2, &cpucount, &len, NULL, 0);
}
return cpucount ? cpucount : 1;
#else #else
#warning unknown platform #warning unknown platform
return 1; return 1;
#endif //BSD #endif /* BSD */
#endif //__linux__ #endif /* __linux__ */
#endif //WIN32 #endif /* WIN32 */
} }
int main() int main(void) {
{ printf("%d\n", getcpucount());
printf("%d\n", getcpucount()); return 0;
return 0;
} }

82
tools/gen_sdk_package.sh Normal file → Executable file
View File

@ -4,22 +4,22 @@
# This script must be run on OS X # This script must be run on OS X
# #
if [ `uname -s` != "Darwin" ]; then if [ $(uname -s) != "Darwin" ]; then
echo "This script must be run on OS X" echo "This script must be run on OS X"
exit 1 exit 1
fi fi
XCODEDIR=$(ls /Volumes | grep Xcode | head -n1) XCODEDIR=$(ls /Volumes | grep Xcode | head -n1)
if [ -z "$XCODEDIR" ]; then if [ -z "$XCODEDIR" ]; then
if [ -d "/Applications/Xcode.app" ]; then if [ -d "/Applications/Xcode.app" ]; then
XCODEDIR="/Applications/Xcode.app" XCODEDIR="/Applications/Xcode.app"
else else
echo "please mount Xcode.dmg" echo "please mount Xcode.dmg"
exit 1 exit 1
fi fi
else else
XCODEDIR="/Volumes/$XCODEDIR/Xcode.app" XCODEDIR="/Volumes/$XCODEDIR/Xcode.app"
fi fi
[ ! -d $XCODEDIR ] && exit 1 [ ! -d $XCODEDIR ] && exit 1
@ -30,36 +30,36 @@ WDIR=$(pwd)
which gnutar &>/dev/null which gnutar &>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
TAR=gnutar TAR=gnutar
else else
TAR=tar TAR=tar
fi fi
which xz &>/dev/null which xz &>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
COMPRESSOR=xz COMPRESSOR=xz
PKGEXT="tar.xz" PKGEXT="tar.xz"
else else
COMPRESSOR=bzip2 COMPRESSOR=bzip2
PKGEXT="tar.bz2" PKGEXT="tar.bz2"
fi fi
set -e set -e
pushd $XCODEDIR &>/dev/null pushd $XCODEDIR &>/dev/null
pushd "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" &>/dev/null || { pushd "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" &>/dev/null || {
echo "Xcode (or this script) is out of date" echo "Xcode (or this script) is out of date"
echo "trying some magic to find the SDKs anyway ..." echo "trying some magic to find the SDKs anyway ..."
SDKDIR=$(find . -name SDKs -type d | grep MacOSX | head -n1) SDKDIR=$(find . -name SDKs -type d | grep MacOSX | head -n1)
if [ -z "$SDKDIR" ]; then if [ -z "$SDKDIR" ]; then
echo "cannot find SDKs!" echo "cannot find SDKs!"
exit 1 exit 1
fi fi
pushd $SDKDIR &>/dev/null pushd $SDKDIR &>/dev/null
} }
SDKS=$(ls | grep MacOSX) SDKS=$(ls | grep MacOSX)
@ -72,30 +72,30 @@ fi
LIBCXXDIR="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1" LIBCXXDIR="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1"
for SDK in $SDKS; do for SDK in $SDKS; do
echo "packaging ${SDK/.sdk/} SDK (this may take several minutes) ..." echo "packaging ${SDK/.sdk/} SDK (this may take several minutes) ..."
if [[ $SDK == *.pkg ]]; then if [[ $SDK == *.pkg ]]; then
cp $SDK $WDIR cp $SDK $WDIR
continue continue
fi fi
TMP=$(mktemp -d /tmp/XXXXXXXXXXX) TMP=$(mktemp -d /tmp/XXXXXXXXXXX)
cp -r $SDK $TMP &>/dev/null || true cp -r $SDK $TMP &>/dev/null || true
pushd $XCODEDIR &>/dev/null pushd $XCODEDIR &>/dev/null
# libc++ headers for C++11/C++14 # libc++ headers for C++11/C++14
if [ -d $LIBCXXDIR ]; then if [ -d $LIBCXXDIR ]; then
cp -rf $LIBCXXDIR "$TMP/$SDK/usr/include/c++" cp -rf $LIBCXXDIR "$TMP/$SDK/usr/include/c++"
fi fi
popd &>/dev/null popd &>/dev/null
pushd $TMP &>/dev/null pushd $TMP &>/dev/null
$TAR -cf - * | $COMPRESSOR -9 -c - > "$WDIR/$SDK.$PKGEXT" $TAR -cf - * | $COMPRESSOR -9 -c - > "$WDIR/$SDK.$PKGEXT"
popd &>/dev/null popd &>/dev/null
rm -rf $TMP rm -rf $TMP
done done
popd &>/dev/null popd &>/dev/null

View File

@ -13,91 +13,91 @@ test -n "$OCDEBUG" && set -x
JOBS=`tools/get_cpu_count.sh` JOBS=`tools/get_cpu_count.sh`
if [ "`basename $0`" != "build.sh" ]; then if [ "`basename $0`" != "build.sh" ]; then
`tools/osxcross_conf.sh` `tools/osxcross_conf.sh`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "you need to complete ./build.sh first, before you can start building $DESC" echo "you need to complete ./build.sh first, before you can start building $DESC"
exit 1 exit 1
fi fi
fi fi
function require() function require()
{ {
set +e set +e
which $1 &>/dev/null
while [ $? -ne 0 ]
do
echo ""
read -p "Please install $1 then press enter"
which $1 &>/dev/null which $1 &>/dev/null
while [ $? -ne 0 ] done
do set -e
echo ""
read -p "Please install $1 then press enter"
which $1 &>/dev/null
done
set -e
} }
if [[ "`uname -s`" == *BSD ]]; then if [[ "`uname -s`" == *BSD ]]; then
MAKE=gmake MAKE=gmake
else else
MAKE=make MAKE=make
fi fi
require $MAKE require $MAKE
function extract() function extract()
{ {
test $# -ge 2 -a $# -lt 4 && test $2 -eq 2 && echo "" test $# -ge 2 -a $# -lt 4 && test $2 -eq 2 && echo ""
echo "extracting `basename $1` ..." echo "extracting `basename $1` ..."
local tarflags local tarflags
tarflags="xf" tarflags="xf"
test -n "$OCDEBUG" && tarflags+="v" test -n "$OCDEBUG" && tarflags+="v"
case $1 in case $1 in
*.pkg) *.pkg)
which xar &>/dev/null || exit 1 which xar &>/dev/null || exit 1
xar -xf $1 xar -xf $1
cat Payload | gunzip -dc | cpio -i 2>/dev/null && rm Payload cat Payload | gunzip -dc | cpio -i 2>/dev/null && rm Payload
;; ;;
*.tar.xz) *.tar.xz)
xz -dc $1 | tar $tarflags - xz -dc $1 | tar $tarflags -
;; ;;
*.tar.gz) *.tar.gz)
gunzip -dc $1 | tar $tarflags - gunzip -dc $1 | tar $tarflags -
;; ;;
*.tar.bz2) *.tar.bz2)
bzip2 -dc $1 | tar $tarflags - bzip2 -dc $1 | tar $tarflags -
;; ;;
*) *)
echo "Unhandled archive type" echo "Unhandled archive type"
exit 1 exit 1
;; ;;
esac esac
if [ $# -eq 2 -o $# -eq 4 ]; then if [ $# -eq 2 -o $# -eq 4 ]; then
echo "" echo ""
fi fi
} }
function test_compiler() function test_compiler()
{ {
echo -ne "testing $1 ... " echo -ne "testing $1 ... "
$1 $2 -O2 -Wall -o test $1 $2 -O2 -Wall -o test
rm test rm test
echo "works" echo "works"
} }
function test_compiler_cxx11() function test_compiler_cxx11()
{ {
set +e set +e
echo -ne "testing $1 -stdlib=libc++ -std=c++11 ... " echo -ne "testing $1 -stdlib=libc++ -std=c++11 ... "
$1 $2 -O2 -stdlib=libc++ -std=c++11 -Wall -o test &>/dev/null $1 $2 -O2 -stdlib=libc++ -std=c++11 -Wall -o test &>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rm test rm test
echo "works" echo "works"
else else
echo "failed (ignored)" echo "failed (ignored)"
fi fi
set -e set -e
} }
# exit on error # exit on error

View File

@ -2,29 +2,28 @@
function check_for_bug_1242300() function check_for_bug_1242300()
{ {
if [ -e /etc/issue ]; then if [ -e /etc/issue ]; then
if [ "`grep -i ubuntu.13.10 /etc/issue`" ]; then if [ "`grep -i ubuntu.13.10 /etc/issue`" ]; then
echo "Ubuntu 13.10 detected. if there was a 'configure:' error" echo "Ubuntu 13.10 detected. if there was a 'configure:' error"
echo "please see https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1242300" echo "please see https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1242300"
fi
fi fi
fi
} }
function _exit() function _exit()
{ {
EC=$? EC=$?
if [ $EC -ne 0 ]; then if [ $EC -ne 0 ]; then
test -z "$SCRIPT" && SCRIPT=`basename $0` test -z "$SCRIPT" && SCRIPT=`basename $0`
echo "" echo ""
echo "exiting with abnormal exit code ($EC)" echo "exiting with abnormal exit code ($EC)"
test -n "$OCDEBUG" || echo "run 'OCDEBUG=1 ./$SCRIPT' to enable debug messages" test -n "$OCDEBUG" || echo "run 'OCDEBUG=1 ./$SCRIPT' to enable debug messages"
echo "removing stale locks..." echo "removing stale locks..."
remove_locks remove_locks
echo "if it is happening the first time, then just re-run the script" echo "if it is happening the first time, then just re-run the script"
echo "" echo ""
test $SCRIPT = "build.sh" && check_for_bug_1242300 test $SCRIPT = "build.sh" && check_for_bug_1242300
fi fi
} }
trap _exit EXIT trap _exit EXIT