Advertisement
trojanfoe

setenv.sh

Oct 18th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.72 KB | None | 0 0
  1. # Set build environment variables for iOS development.
  2. #
  3. # This script should be sourced:
  4. #
  5. # . setenv.sh arch [sdk-version]
  6. #
  7. # Where 'arch' is one of armv6, armv7 or i386 (simulator)
  8. #
  9. # The environment variable $VALIDENV will be 0 is the environment is
  10. # invalid, or 1 if valid.
  11.  
  12. export VALIDENV=0
  13. if [ $# -gt 0 ]; then
  14.     SDKVER=5.0
  15.  
  16.     if [ $# -eq 1 ]; then
  17.         ARCH=$1
  18.     elif [ $# -eq 2 ]; then
  19.         ARCH=$1
  20.         SDKVER=$2
  21.     fi
  22.    
  23.     case $ARCH in
  24.     armv6)
  25.         PLATFORM=iPhoneOS
  26.         ;;
  27.     armv7)
  28.         PLATFORM=iPhoneOS
  29.         ;;
  30.     i386)
  31.         PLATFORM=iPhoneSimulator
  32.         ;;
  33.     esac
  34.     export ARCH PLATFORM SDKVER
  35.    
  36.     # Developer and SDK root directories
  37.     export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
  38.     export SDKROOT=$DEVROOT/SDKs/${PLATFORM}${SDKVER}.sdk
  39.     export TOOLROOT=$DEVROOT/usr/bin
  40.    
  41.     # Full path to tools
  42.     export CC=$TOOLROOT/clang
  43.     export CXX=$TOOLROOT/clang++
  44.     export LD=$TOOLROOT/ld
  45.     export AR=$TOOLROOT/ar
  46.     export RANLIB=$TOOLROOT/ranlib
  47.     export NM=$TOOLROOT/nm
  48.     export STRIP=$TOOLROOT/strip
  49.  
  50.     # Some fundamental compiler/linker flags
  51.     export CFLAGS="-arch $ARCH -isysroot $SDKROOT"
  52.     export CXXFLAGS="$CFLAGS"
  53.     export LDFLAGS="$CFLAGS -Wl,-syslibroot $SDKROOT"
  54.    
  55.     # Where local libraries are installed
  56.     export LOCAL_IOS_LIBS=/opt/local/ioslibs
  57.  
  58.     # Check if the environment is valid
  59.     [   -d $DEVROOT -a \
  60.         -d $SDKROOT -a \
  61.         -d $TOOLROOT -a \
  62.         -d $LOCAL_IOS_LIBS -a \
  63.         -x $CC -a \
  64.         -x $CXX -a \
  65.         -x $LD -a \
  66.         -x $AR ] && VALIDENV=1
  67. fi
  68.  
  69. if [ $VALIDENV = 0 ]; then
  70.     echo Invalid environment!
  71. fi
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement