7742f0d00aeebe949b216eb95a86b845d7147d21~suv#!/bin/sh
7742f0d00aeebe949b216eb95a86b845d7147d21~suvCOMPILER='@@@'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvSUFFIX='---'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvPREFIX='&&&'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvOUTPUT_O='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvOUTPUT=''
7742f0d00aeebe949b216eb95a86b845d7147d21~suvNAMED_OUTPUT=''
7742f0d00aeebe949b216eb95a86b845d7147d21~suvLASTFILE=''
7742f0d00aeebe949b216eb95a86b845d7147d21~suvINTEL='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvSIZE32='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvSIZE64='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suvNEWARGS=''
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvSKIP='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvfor arg in $@
7742f0d00aeebe949b216eb95a86b845d7147d21~suvdo
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $SKIP = 'ARCH' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # intercept -arch option and set SIZEXX
7742f0d00aeebe949b216eb95a86b845d7147d21~suv SKIP='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $arg = 'x86_64' ] || [ $arg = 'ppc64' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv SIZE64='YES'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv SIZE32='YES'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # which architecture are we compiling for?
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $arg = 'x86_64' ] || [ $arg = 'i386' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv INTEL='YES'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv elif [ $arg = '-arch' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv SKIP='ARCH'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv elif [ $arg = '--version' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv ${COMPILER} --version
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 0
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv NEWARGS+="$arg "
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # if the -c option is given, the output is .o
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $arg = '-c' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv OUTPUT_O='YES'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # if the output file is given by a -o option, record it
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $SKIP = 'O' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv SKIP='NO'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv NAMED_OUTPUT=$arg
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $arg = '-o' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv SKIP='O'
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # Note each file ending by ${SUFFIX} and remember the last one
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # Transform them in .o
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if `echo $arg | grep -q "${SUFFIX}$"`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv LASTFILE=$arg
7742f0d00aeebe949b216eb95a86b845d7147d21~suv OUTPUT+=`echo $arg | sed "s/${SUFFIX}/\.o/"`
7742f0d00aeebe949b216eb95a86b845d7147d21~suv OUTPUT+=' '
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suvdone
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv# What is the output?
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvif [ ${NAMED_OUTPUT}"X" != "X" ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv OUTPUT=$NAMED_OUTPUT
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvelif [ $OUTPUT_O = 'NO' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # It is an executable whose is name is the LASTFILE without suffix
7742f0d00aeebe949b216eb95a86b845d7147d21~suv OUTPUT=`echo ${LASTFILE} | sed "s/${SUFFIX}//"`
7742f0d00aeebe949b216eb95a86b845d7147d21~suvfi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv# Othewise, the output is just the ${OUTPUT} variable as computed before
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv# For some reason, -dynamiclib and -lpython2.6 are missing when linking
7742f0d00aeebe949b216eb95a86b845d7147d21~suv# .so files. Add them, except if -bundle is set (incompatible switches)
7742f0d00aeebe949b216eb95a86b845d7147d21~suvif [ `echo $OUTPUT | sed -E 's|.*\.||'` = "so" ] && \
7742f0d00aeebe949b216eb95a86b845d7147d21~suv ! `echo $NEWARGS | grep -q bundle`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv NEWARGS="${NEWARGS} ${PREFIX}/lib/libpython2.6.dylib -dynamiclib"
7742f0d00aeebe949b216eb95a86b845d7147d21~suvfi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv# Now, compile
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvif [ $SIZE32 = 'NO' ] && [ $SIZE64 = 'NO' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # No size indication given, just proceed with default
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if `${COMPILER} $NEWARGS`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 0
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 1
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvelif [ $SIZE32 = 'YES' ] && [ $SIZE64 = 'NO' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # 32-bit
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if `${COMPILER} -m32 $NEWARGS`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 0
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 1
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvelif [ $SIZE32 = 'NO' ] && [ $SIZE64 = 'YES' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # 64-bit
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if `${COMPILER} -m64 $NEWARGS`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 0
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 1
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suvelse
7742f0d00aeebe949b216eb95a86b845d7147d21~suv # Universal case
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if `${COMPILER} -m32 $NEWARGS`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv for filename in ${OUTPUT}
7742f0d00aeebe949b216eb95a86b845d7147d21~suv do
7742f0d00aeebe949b216eb95a86b845d7147d21~suv mv ${filename} ${filename}.32
7742f0d00aeebe949b216eb95a86b845d7147d21~suv done
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if `${COMPILER} -m64 $NEWARGS`; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv for filename in ${OUTPUT}
7742f0d00aeebe949b216eb95a86b845d7147d21~suv do
7742f0d00aeebe949b216eb95a86b845d7147d21~suv mv ${filename} ${filename}.64
7742f0d00aeebe949b216eb95a86b845d7147d21~suv if [ $INTEL = 'YES' ]; then
7742f0d00aeebe949b216eb95a86b845d7147d21~suv lipo -create -arch x86_64 ${filename}.64 \
7742f0d00aeebe949b216eb95a86b845d7147d21~suv -arch i386 ${filename}.32 \
7742f0d00aeebe949b216eb95a86b845d7147d21~suv -output ${filename}
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv lipo -create -arch ppc64 ${filename}.64 \
7742f0d00aeebe949b216eb95a86b845d7147d21~suv -arch ppc ${filename}.32 \
7742f0d00aeebe949b216eb95a86b845d7147d21~suv -output ${filename}
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv
7742f0d00aeebe949b216eb95a86b845d7147d21~suv rm -f ${filename}.32 ${filename}.64
7742f0d00aeebe949b216eb95a86b845d7147d21~suv done
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 1
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suv else
7742f0d00aeebe949b216eb95a86b845d7147d21~suv exit 1
7742f0d00aeebe949b216eb95a86b845d7147d21~suv fi
7742f0d00aeebe949b216eb95a86b845d7147d21~suvfi
7742f0d00aeebe949b216eb95a86b845d7147d21~suvexit 0