4 # Author: Pekka Riikonen <priikone@silcnet.org>
6 # Copyright (C) 2007 Pekka Riikonen
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; version 2 of the License.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
18 # Function to check if system has SMP kernel.
19 # Usage: SILC_SYSTEM_IS_SMP([ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND])
20 AC_DEFUN([SILC_SYSTEM_IS_SMP],
22 AC_MSG_CHECKING(whether system has SMP kernel)
26 # Take data from Linux /proc
27 if test -f /proc/stat; then
28 cpucount=`grep "^cpu" /proc/stat -c 2> /dev/null`
29 if test $cpucount -gt 1; then
30 AC_DEFINE([SILC_SMP], [], [SILC_SMP])
32 ifelse([$1], , :, [$1])
35 ifelse([$2], , :, [$2])
39 ifelse([$2], , :, [$2])
44 # BSDs can have SMP info in sysctl 'kern.smp.cpus' variable
45 cpucount=`/sbin/sysctl kern.smp.cpus 2> /dev/null | \
46 cut -d'=' -f2 | cut -d' ' -f2`
47 if test $cpucount -gt 1; then
48 AC_DEFINE([SILC_SMP], [], [SILC_SMP])
50 ifelse([$1], , :, [$1])
53 ifelse([$2], , :, [$2])
59 ifelse([$2], , :, [$2])
64 # Function to check for CPU feature flags.
65 # Usage: SILC_CPU_FLAG(flag [, ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND])
66 AC_DEFUN([SILC_CPU_FLAG],
68 AC_MSG_CHECKING(whether CPU supports $1)
72 # Take data from Linux /proc
73 if test -f /proc/cpuinfo; then
74 cpuflags=`grep "^flags.*$1 " /proc/cpuinfo 2> /dev/null`
77 ifelse([$3], , :, [$3])
80 ifelse([$2], , :, [$2])
84 ifelse([$3], , :, [$3])
89 # BSDs have some flags in sysctl 'machdep' variable
90 cpuflags=`/sbin/sysctl machdep 2> /dev/null | grep "\.$1.*.1"`
93 ifelse([$3], , :, [$3])
96 ifelse([$2], , :, [$2])
102 ifelse([$3], , :, [$3])
107 # Function to check if compiler flag works
108 # Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
109 AC_DEFUN([SILC_ADD_CFLAGS],
110 [ tmp_CFLAGS="$CFLAGS"
112 AC_MSG_CHECKING(whether $CC accepts $1 flag)
113 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
119 # Function to check if compiler flag works, destination specifiable
120 # Usage: SILC_ADD_CC_FLAGS(VAR, FLAGS, [ACTION-IF-FAILED])
121 AC_DEFUN([SILC_ADD_CC_FLAGS],
122 [ tmp_CFLAGS="$1_CFLAGS"
123 $1_CFLAGS="${$1_CFLAGS} $2"
124 AC_MSG_CHECKING(whether $CC accepts $2 flag)
125 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
126 $1_CFLAGS="$tmp_CFLAGS"