diff options
Diffstat (limited to 'config.tests/mac')
-rwxr-xr-x | config.tests/mac/crc.test | 71 | ||||
-rw-r--r-- | config.tests/mac/crc/crc.pro | 2 | ||||
-rw-r--r-- | config.tests/mac/crc/main.cpp | 67 | ||||
-rwxr-xr-x | config.tests/mac/defaultarch.test | 33 | ||||
-rwxr-xr-x | config.tests/mac/dwarf2.test | 42 | ||||
-rwxr-xr-x | config.tests/mac/xarch.test | 26 | ||||
-rw-r--r-- | config.tests/mac/xcodeversion.cpp | 58 |
7 files changed, 299 insertions, 0 deletions
diff --git a/config.tests/mac/crc.test b/config.tests/mac/crc.test new file mode 100755 index 0000000..1a16204 --- /dev/null +++ b/config.tests/mac/crc.test @@ -0,0 +1,71 @@ +#!/bin/sh + +SUCCESS=no +QMKSPEC=$1 +XPLATFORM=`basename "$1"` +QMAKE_CONFIG=$2 +VERBOSE=$3 +SRCDIR=$4 +OUTDIR=$5 +TEST=$6 +EXE=`basename "$6"` +ARG=$7 +shift 7 +LFLAGS="" +INCLUDEPATH="" +CXXFLAGS="" +while [ "$#" -gt 0 ]; do + PARAM=$1 + case $PARAM in + -framework) + LFLAGS="$LFLAGS -framework \"$2\"" + shift + ;; + -F*|-m*|-x*) + LFLAGS="$LFLAGS $PARAM" + CXXFLAGS="$CXXFLAGS $PARAM" + ;; + -L*|-l*|-pthread) + LFLAGS="$LFLAGS $PARAM" + ;; + -I*) + INC=`echo $PARAM | sed -e 's/^-I//'` + INCLUDEPATH="$INCLUDEPATH $INC" + ;; + -f*|-D*) + CXXFLAGS="$CXXFLAGS $PARAM" + ;; + -Qoption) + # Two-argument form for the Sun Compiler + CXXFLAGS="$CXXFLAGS $PARAM \"$2\"" + shift + ;; + *) ;; + esac + shift +done + +# debuggery +[ "$VERBOSE" = "yes" ] && echo "$DESCRIPTION auto-detection... ($*)" + +test -d "$OUTDIR/$TEST" || mkdir -p "$OUTDIR/$TEST" + +cd "$OUTDIR/$TEST" + +make distclean >/dev/null 2>&1 +"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "LIBS*=$LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile" + +if [ "$VERBOSE" = "yes" ]; then + make +else + make >/dev/null 2>&1 +fi + + +if [ -x "$EXE" ]; then + foo=`$OUTDIR/$TEST/$EXE $ARG` + echo "$foo" +else + echo "'CUTE'" #1129665605 # == 'CUTE' +fi + diff --git a/config.tests/mac/crc/crc.pro b/config.tests/mac/crc/crc.pro new file mode 100644 index 0000000..c3abf15 --- /dev/null +++ b/config.tests/mac/crc/crc.pro @@ -0,0 +1,2 @@ +SOURCES = main.cpp +CONFIG -= app_bundle qt diff --git a/config.tests/mac/crc/main.cpp b/config.tests/mac/crc/main.cpp new file mode 100644 index 0000000..2ac10b3 --- /dev/null +++ b/config.tests/mac/crc/main.cpp @@ -0,0 +1,67 @@ +#include <iostream> +#include <cstdlib> +#include <cstring> + + +class CCRC32 +{ +public: + CCRC32() { initialize(); } + + unsigned long FullCRC(const unsigned char *sData, unsigned long ulDataLength) + { + unsigned long ulCRC = 0xffffffff; + PartialCRC(&ulCRC, sData, ulDataLength); + return(ulCRC ^ 0xffffffff); + } + + void PartialCRC(unsigned long *ulCRC, const unsigned char *sData, unsigned long ulDataLength) + { + while(ulDataLength--) { + *ulCRC = (*ulCRC >> 8) ^ ulTable[(*ulCRC & 0xFF) ^ *sData++]; + } + } + +private: + void initialize(void) + { + unsigned long ulPolynomial = 0x04C11DB7; + memset(&ulTable, 0, sizeof(ulTable)); + for(int iCodes = 0; iCodes <= 0xFF; iCodes++) { + ulTable[iCodes] = Reflect(iCodes, 8) << 24; + for(int iPos = 0; iPos < 8; iPos++) { + ulTable[iCodes] = (ulTable[iCodes] << 1) + ^ ((ulTable[iCodes] & (1 << 31)) ? ulPolynomial : 0); + } + + ulTable[iCodes] = Reflect(ulTable[iCodes], 32); + } + } + unsigned long Reflect(unsigned long ulReflect, const char cChar) + { + unsigned long ulValue = 0; + // Swap bit 0 for bit 7, bit 1 For bit 6, etc.... + for(int iPos = 1; iPos < (cChar + 1); iPos++) { + if(ulReflect & 1) { + ulValue |= (1 << (cChar - iPos)); + } + ulReflect >>= 1; + } + return ulValue; + } + unsigned long ulTable[256]; // CRC lookup table array. +}; + + +int main(int argc, char **argv) +{ + CCRC32 crc; + char *name; + if (argc < 2) { + std::cerr << "usage: crc <string>\n"; + return 0; + } else { + name = argv[1]; + } + std::cout << crc.FullCRC((unsigned char *)name, strlen(name)) << std::endl; +} diff --git a/config.tests/mac/defaultarch.test b/config.tests/mac/defaultarch.test new file mode 100755 index 0000000..4502af7 --- /dev/null +++ b/config.tests/mac/defaultarch.test @@ -0,0 +1,33 @@ +#!/bin/sh + +COMPILER=$1 +VERBOSE=$2 +WORKDIR=$3 +QT_MAC_DEFUALT_ARCH= + +touch defaultarch.c + +# compile something and run 'file' on it. +if "$COMPILER" -c defaultarch.c 2>/dev/null 1>&2; then + FIlE_OUTPUT=`file defaultarch.o` + [ "$VERBOSE" = "yes" ] && echo "'file' reports compiler ($COMPILER) default architechture as: $FIlE_OUTPUT" + +fi +rm -f defaultarch.c defaultarch.o + +# detect our known archs. +if echo "$FIlE_OUTPUT" | grep '\<i386\>' > /dev/null 2>&1; then + QT_MAC_DEFUALT_ARCH=x86 # configure knows it as "x86" not "i386" +fi +if echo "$FIlE_OUTPUT" | grep '\<x86_64\>' > /dev/null 2>&1; then + QT_MAC_DEFUALT_ARCH=x86_64 +fi +if echo "$FIlE_OUTPUT" | grep '\<ppc\>' > /dev/null 2>&1; then + QT_MAC_DEFUALT_ARCH=ppc +fi +if echo "$FIlE_OUTPUT" | grep '\<ppc64\>' > /dev/null 2>&1; then + QT_MAC_DEFUALT_ARCH=ppc64 +fi + +[ "$VERBOSE" = "yes" ] && echo "setting QT_MAC_DEFUALT_ARCH to \"$QT_MAC_DEFUALT_ARCH\"" +export QT_MAC_DEFUALT_ARCH diff --git a/config.tests/mac/dwarf2.test b/config.tests/mac/dwarf2.test new file mode 100755 index 0000000..a640b11 --- /dev/null +++ b/config.tests/mac/dwarf2.test @@ -0,0 +1,42 @@ +#!/bin/sh + +DWARF2_SUPPORT=no +DWARF2_SUPPORT_BROKEN=no +COMPILER=$1 +VERBOSE=$2 +WORKDIR=$3 + +touch dwarf2.c + +if "$COMPILER" -c dwarf2.c -Werror -gdwarf-2 2>/dev/null 1>&2; then + if "$COMPILER" -c dwarf2.c -Werror -gdwarf-2 2>&1 | grep "unsupported" >/dev/null ; then + true + else + DWARF2_SUPPORT=yes + fi +fi +rm -f dwarf2.c dwarf2.o + +# Test for xcode 2.4.0, which has a broken implementation of DWARF +"$COMPILER" $WORKDIR/xcodeversion.cpp -o xcodeversion -framework Carbon; +./xcodeversion + +if [ "$?" == "1" ]; then + DWARF2_SUPPORT_BROKEN=yes +fi + +rm xcodeversion + +# done +if [ "$DWARF2_SUPPORT" != "yes" ]; then + [ "$VERBOSE" = "yes" ] && echo "DWARF2 debug symbols disabled." + exit 0 +else + if [ "$DWARF2_SUPPORT_BROKEN" == "yes" ]; then + [ "$VERBOSE" = "yes" ] && echo "DWARF2 debug symbols disabled." + exit 0 + else + [ "$VERBOSE" = "yes" ] && echo "DWARF2 debug symbols enabled." + exit 1 + fi +fi diff --git a/config.tests/mac/xarch.test b/config.tests/mac/xarch.test new file mode 100755 index 0000000..08322a9 --- /dev/null +++ b/config.tests/mac/xarch.test @@ -0,0 +1,26 @@ +#!/bin/sh + +XARCH_SUPPORT=no +COMPILER=$1 +VERBOSE=$2 +WORKDIR=$3 + +touch xarch.c + +if "$COMPILER" -c xarch.c -Xarch_i386 -mmmx 2>/dev/null 1>&2; then + if "$COMPILER" -c xarch.c -Xarch_i386 -mmmx 2>&1 | grep "unrecognized" >/dev/null ; then + true + else + XARCH_SUPPORT=yes + fi +fi +rm -f xarch.c xarch.o + +# done +if [ "$XARCH_SUPPORT" != "yes" ]; then + [ "$VERBOSE" = "yes" ] && echo "Xarch is not supported" + exit 0 +else + [ "$VERBOSE" = "yes" ] && echo "Xarch support detected" + exit 1 +fi diff --git a/config.tests/mac/xcodeversion.cpp b/config.tests/mac/xcodeversion.cpp new file mode 100644 index 0000000..e613cc5 --- /dev/null +++ b/config.tests/mac/xcodeversion.cpp @@ -0,0 +1,58 @@ +#include <stdlib.h> +#include <stdio.h> +#include <CoreFoundation/CoreFoundation.h> +#include <Carbon/Carbon.h> + +int success = 0; +int fail = 1; +int internal_error = success; // enable dwarf on internal errors + +int main(int argc, const char **argv) +{ + CFURLRef cfurl; + OSStatus err = LSFindApplicationForInfo(0, CFSTR("com.apple.Xcode"), 0, 0, &cfurl); + if (err != noErr) + return internal_error; + + CFBundleRef bundle = CFBundleCreate(0, cfurl); + if (bundle == 0) + return internal_error; + + CFStringRef str = CFStringRef(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("CFBundleShortVersionString"))); + const char * ptr = CFStringGetCStringPtr(str, 0); + if (ptr == 0) + return internal_error; + + // self-test + const char * fail1 = "2.4"; + const char * fail2 = "2.4.0"; + const char * fail3 ="2.3"; + const char * ok1 = "2.4.1"; + const char * ok2 ="2.5"; + const char * ok3 ="3.0"; +// ptr = fail1; +// printf ("string: %s\n", ptr); + + int length = strlen(ptr); + if (length < 3) // expect "x.y" at least + return internal_error; + + // fail on 2.4 and below (2.4.1 is ok) + + if (ptr[0] < '2') + return fail; + + if (ptr[0] >= '3') + return success; + + if (ptr[2] < '4') + return fail; + + if (length < 5) + return fail; + + if (ptr[4] < '1') + return fail; + + return success; +}
\ No newline at end of file |