summaryrefslogtreecommitdiffstats
path: root/config.tests/unix/arch.test
blob: 3efd6f4f253d29f6de258f64f22109510548d7e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

QMKSPEC=$1
VERBOSE=$2
SRCDIR=$3
OUTDIR=$4
RESULTFILE=$5
TARGET=$6
shift 6

if [ "$TARGET" = "host" ]; then
    VARPREFIX="CFG_HOST"
    PROSUFFIX="_host"
else
    VARPREFIX="CFG"
    PROSUFFIX=""
fi

LFLAGS="$SYSROOT_FLAG"
CXXFLAGS="$SYSROOT_FLAG"

# debuggery
[ "$VERBOSE" = "yes" ] && echo "Determining architecture... ($*)"

# build a test program but don't run it
test -d "$OUTDIR/config.tests/arch" || mkdir -p "$OUTDIR/config.tests/arch"
cd "$OUTDIR/config.tests/arch"
[ -f Makefile ] && $MAKE distclean >/dev/null 2>&1
OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2


ARCH=""
[ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1

if [ -f ./arch.exe ]; then
    binary=./arch.exe
elif [ -f ./arch ]; then
    binary=./arch
elif [ -f ./libarch.so ]; then
    binary=./libarch.so
else
    [ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!"
    exit 2
fi

if strings - $binary 2>/dev/null | \
    awk -F: '/\=\=Qt\=magic\=Qt\=\= Architecture/ { print "'$VARPREFIX'_ARCH=\"" $2 "\"" }
             /\=\=Qt\=magic\=Qt\=\= Sub-architecture/ { print "'$VARPREFIX'_CPUFEATURES=\"" $2 "\"" }' > "$RESULTFILE"
then
    [ "$VERBOSE" = "yes" ] && echo "    Found architecture in binary" && \
        cat "$RESULTFILE"
else
    [ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!"
    exit 2
fi

$MAKE distclean >/dev/null 2>&1