-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsrt.m4
More file actions
176 lines (165 loc) · 4.87 KB
/
srt.m4
File metadata and controls
176 lines (165 loc) · 4.87 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#
# srt.m4
#
# Author: Pekka Riikonen <[email protected]>
#
# Copyright (C) 2007 - 2008 Pekka Riikonen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Function to check if system has SMP kernel.
#
# Usage: SILC_SYSTEM_IS_SMP([ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND]
# [, ACTION-IF-NOT-DETECTED])
#
# The ACTION-IF-NOT-DETECTED is called if we could not detect whether or
# not the system is SMP.
#
# x_is_smp variable is set to true or false as a result for calling this
# function. Caller may use the variable to check for the result in the
# code.
#
AC_DEFUN([SILC_SYSTEM_IS_SMP],
[
AC_MSG_CHECKING(whether system has SMP kernel)
x_is_smp=false
case "$target" in
*-*-linux*)
# Take data from Linux /proc
if test -f /proc/stat; then
cpucount=`grep "^cpu" /proc/stat -c 2> /dev/null`
if test $cpucount -gt 1; then
AC_DEFINE([SILC_SMP], [], [SILC_SMP])
AC_MSG_RESULT(yes)
x_is_smp=true
ifelse([$1], , :, [$1])
else
AC_MSG_RESULT(no)
ifelse([$2], , :, [$2])
fi
else
AC_MSG_RESULT(no)
ifelse([$2], , :, [$2])
fi
;;
*-*-*bsd*)
# BSDs can have SMP info in sysctl 'kern.smp.cpus' variable
sysctl="sysctl -n kern.smp.cpus"
cpucount=`(/sbin/$sysctl 2> /dev/null || \
/usr/sbin/$sysctl 2> /dev/null || echo -n 0)`
if test $cpucount -gt 1; then
AC_DEFINE([SILC_SMP], [], [SILC_SMP])
AC_MSG_RESULT(yes)
x_is_smp=true
ifelse([$1], , :, [$1])
else
AC_MSG_RESULT(no)
ifelse([$2], , :, [$2])
fi
;;
*)
AC_MSG_RESULT(cannot detect on this system)
ifelse([$3], , :, [$3])
;;
esac
])
# Function to check for CPU feature flags.
#
# Usage: SILC_CPU_FLAG(flag, enable, [, ACTION-IF-FOUND]
# [, ACTION-IF-NOT-FOUND])
#
# x_have_cpu_<flag> variable is set to true or false value as a result for
# calling this function for the <flag>. Caller may use the variable to
# check the result in the code. If <enable> is true this will add
# AC_ARG_ENABLE option for the <flag>.
#
AC_DEFUN([SILC_CPU_FLAG],
[
AC_MSG_CHECKING(whether CPU supports $1)
x_have_cpu_$1=false
if test x$2 = xtrue; then
AC_ARG_ENABLE($1,
[ --enable-$1 ],
[
AC_MSG_RESULT(yes - enabled by --enable-$1)
x_have_cpu_$1=true
])
fi
if test x$x_have_cpu_$1 = xfalse; then
case "$target" in
*-*-linux*)
# Take data from Linux /proc
if test -f /proc/cpuinfo; then
cpuflags=`grep "^flags.*$1 " /proc/cpuinfo 2> /dev/null`
if test $? != 0; then
AC_MSG_RESULT(no)
x_have_cpu_$1=false
ifelse([$4], , :, [$4])
else
AC_MSG_RESULT(yes)
x_have_cpu_$1=true
ifelse([$3], , :, [$3])
fi
else
AC_MSG_RESULT(no)
x_have_cpu_$1=false
ifelse([$4], , :, [$4])
fi
;;
*-*-*bsd*)
# BSDs have some flags in sysctl 'machdep' variable
cpuflags=`/sbin/sysctl machdep 2> /dev/null | grep "\.$1.*.1"`
if test $? != 0; then
AC_MSG_RESULT(no)
x_have_cpu_$1=false
ifelse([$4], , :, [$4])
else
AC_MSG_RESULT(yes)
x_have_cpu_$1=true
ifelse([$3], , :, [$3])
fi
;;
*)
AC_MSG_RESULT(no - cannot detect on this system)
x_have_cpu_$1=false
ifelse([$4], , :, [$4])
;;
esac
fi
])
# Function to check if compiler option works with the compiler. If you
# want the option added to some other than CFLAGS variable use the
# SILC_ADD_CC_FLAGS which supports to specifiable destination variable.
#
# Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
#
AC_DEFUN([SILC_ADD_CFLAGS],
[ tmp_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_MSG_CHECKING(whether $CC accepts $1 flag)
AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
CFLAGS="$tmp_CFLAGS"
$2])
unset tmp_CFLAGS
])
# Function to check if compiler option works with the compiler,
# destination variable specifiable
#
# Usage: SILC_ADD_CC_FLAGS(VAR, FLAGS, [ACTION-IF-FAILED])
#
AC_DEFUN([SILC_ADD_CC_FLAGS],
[ tmp_CFLAGS="$1_CFLAGS"
$1_CFLAGS="${$1_CFLAGS} $2"
AC_MSG_CHECKING(whether $CC accepts $2 flag)
AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
$1_CFLAGS="$tmp_CFLAGS"
$3])
unset tmp_CFLAGS
])