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