forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsah_select_bitness.m4
56 lines (53 loc) · 1.37 KB
/
sah_select_bitness.m4
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
AC_DEFUN([SAH_DEFAULT_BITNESS],[
if test -z "${COMPILER_MODEL_BITS}"
then
AC_MSG_CHECKING(default bitness of compiler)
echo "int main() { return 0; }" >conftest.c
${CC} ${CFLAGS} -c conftest.c >&5
COMPILER_MODEL_BITS=32
if test -f conftest.${OBJEXT} ; then
if test -n "`file conftest.${OBJEXT} | grep -i 64-bit`"
then
COMPILER_MODEL_BITS=64
else
if test -n "`file conftest.${OBJEXT} | grep -i 16-bit`"
then
COMPILER_MODEL_BITS=16
fi
fi
fi
/bin/rm conftest.c
AC_MSG_RESULT($COMPILER_MODEL_BITS)
fi
])
AC_DEFUN([SAH_SELECT_BITNESS],[
AC_LANG_PUSH(C)
SAH_DEFAULT_BITNESS
AC_MSG_CHECKING(Selecting $1 bit model)
echo "int main() { return 0; }" >conftest.$ac_ext
if test "$1" != "${COMPILER_MODEL_BITS}"
then
${CC} ${CFLAGS} ${CPPFLAGS} -m$1 -c conftest.$ac_ext >&5
if test -f conftest.${OBJEXT} ; then
if test -n "`file conftest.${OBJEXT} | grep -i $1-bit`"
then
CFLAGS="${CFLAGS} -m$1"
AC_MSG_RESULT(-m$1)
COMPILER_MODEL_BITS=$1
fi
AC_MSG_RESULT(failed)
fi
else
AC_MSG_RESULT(ok)
fi
AC_LANG_POP(C)
])
AC_DEFUN([SAH_OPTION_BITNESS],[
AC_ARG_ENABLE(bitness,
AC_HELP_STRING([--enable-bitness=(32,64)],
[enable 32 or 64 bit object/executable files]
),
[SAH_SELECT_BITNESS(${enableval})],
[SAH_DEFAULT_BITNESS]
)
])