-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.in
219 lines (196 loc) · 7.25 KB
/
configure.in
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#
# Rated 0.9.0 configure.in
#
AC_INIT
AC_CONFIG_SRCDIR([src/rated.h])
AC_CONFIG_AUX_DIR(config)
AC_SUBST(ac_aux_dir)
AM_INIT_AUTOMAKE(rated, 0.9.0)
AC_SUBST(VERSION)
AC_CONFIG_HEADERS([config/config.h])
AC_CANONICAL_HOST
AC_PREFIX_DEFAULT(/usr/local/rated)
dnl Compilation Setup
AC_ARG_WITH(mysql,
[ --with-mysql=PATH MySQL path [default=/usr/local]],,[with_mysql=check])
AC_ARG_WITH(pgsql,
[ --with-pgsql=PATH Postgres path [default=/usr/local]],,[with_pgsql=check])
AC_ARG_WITH(snmp,
[ --with-snmp=PATH SNMP path [default=/usr/local]],,[with_snmp=check])
dnl substitute them in all the files listed in AC_OUTPUT
AC_SUBST(RATED_HOME)
dnl if host_alias is empty, ac_cv_host_alias may still have the info
if test -z "$host_alias"; then
host_alias=$ac_cv_host_alias
fi
dnl Platform-specific tweaks
case $host_alias in
*solaris*)
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS";;
*freebsd*)
LIBS="$LIBS -pthread"
AC_DEFINE(HAVE_LIBPTHREAD, 1);;
esac
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CC_C99
AC_PROG_INSTALL
AC_PROG_LN_S
AC_DISABLE_STATIC
ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL])
AC_PROG_YACC
AM_PROG_LEX
dnl need this for per-file compilation flags
AC_PROG_CC_C_O
AM_PROG_CC_C_O
AC_MSG_CHECKING([whether to enable -Wall])
AC_ARG_ENABLE(warnings,
[ --enable-warnings Enable -Wall if using gcc.],
[ if test -n "$GCC"; then
AC_MSG_RESULT(adding -Wall to CFLAGS.)
CFLAGS="$CFLAGS -Wall"
fi],AC_MSG_RESULT(no))
dnl Checks for libraries.
AC_CHECK_LIB(kstat, kstat_lookup)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, socket)
dnl AC_CHECK_LIB(m, floor)
AC_CHECK_LIB(pthread, pthread_exit)
AC_CHECK_LIB(rt, clock_gettime)
dnl AC_CHECK_LIB(z, deflate)
dnl AC_CHECK_LIB(des, CRYPTO_free,[],[])
AC_CHECK_LIB(ltdl, lt_dlopen,[],[AC_MSG_ERROR(Cannot link with libtool libs! (libltdl))])
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(ltdl.h)
AC_CHECK_HEADERS(malloc.h math.h syslog.h ctype.h sys/time.h netinet/in.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_TYPES([unsigned long long, long long])
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(asprintf gettimeofday strerror strtoull)
dnl Determine RATED home installation path for script substitution
if test "x$prefix" != "xNONE"; then
RATED_HOME=$prefix
else
RATED_HOME=/usr/local/rated
fi
AC_DEFINE_UNQUOTED(RATED_HOME, "$RATED_HOME", RATED root installation prefix)
dnl ****************** Begin SNMP checking ***********************
AC_MSG_CHECKING(snmp)
AS_IF([test "x$with_snmp" != "xcheck"],
[CPPFLAGS="$CPPFLAGS -I${with_snmp}/include/net-snmp"
LDFLAGS="$LDFLAGS -L${with_snmp}/lib"
AC_SUBST(rated_LDADD, "-L${with_snmp}/lib")
AC_SUBST(SNMP_LIB, "${with_snmp}/lib")]
)
dnl this is a prereq for the other headers
AC_CHECK_HEADER([net-snmp/net-snmp-config.h],
[AC_CHECK_HEADERS([net-snmp/net-snmp-includes.h net-snmp/config_api.h net-snmp/session_api.h],
[AC_CHECK_LIB(netsnmp, snmp_sess_open,
[AC_SUBST(rated_LDADD, "${rated_LDADD} -lnetsnmp")],
[AC_MSG_ERROR(["Cannot link with net-snmp libs! (libnetsnmp). Use --with-snmp to specify non-default path."])]
)],
[AC_MSG_ERROR(["Cannot find net-snmp headers. Use --with-snmp to specify non-default path."])],
[#include <net-snmp/net-snmp-config.h>]
)],
[AC_MSG_ERROR(["Cannot find net-snmp headers. Use --with-snmp to specify non-default path."])]
)
dnl ****************** End SNMP checking ***********************
AC_CHECK_LIB(crypto, CRYPTO_free,
[AC_SUBST(rated_LDADD, "${rated_LDADD} -lcrypto")],
[AC_MSG_ERROR(libcrypto not found!)]
)
dnl ****************** Begin Postgres checking ***********************
AC_MSG_CHECKING(pgsql)
AS_IF([test "x$with_pgsql" != "xno"],
[if test "x$with_pgsql" != "xcheck"; then
AC_PATH_PROG(PG_CONFIG, pg_config, [], "${with_pgsql}/bin")
else
dnl look for the pg_config helper
AC_PATH_PROG(PG_CONFIG, pg_config)
fi
if test -n $PG_CONFIG; then
PGSQL_INC_DIR=`${PG_CONFIG} --includedir`
OLD_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I${PGSQL_INC_DIR}"
AC_CHECK_HEADER(libpq-fe.h,
[ AC_CHECK_LIB(pq, PQconnectdb,
[ AC_SUBST(libratedpgsql_la_LIBADD, "-lpq")
AC_SUBST(libratedpgsql_la_CPPFLAGS, "-I${PGSQL_INC_DIR}")
ltlibraries="libratedpgsql.la $ltlibraries" ],
[ if test "x$with_pgsql" != "xcheck"; then
AC_MSG_ERROR(Cannot link with Postgres libs! (libpq))
else
AC_MSG_WARN(Cannot link with Postgres libs! (libpq))
fi ]
)],
[ if test "x$with_pgsql" != "xcheck"; then
AC_MSG_ERROR([Cannot find Postgres headers in ${PGSQL_DIR}])
else
AC_MSG_WARN([Cannot find Postgres headers in ${PGSQL_DIR}. Use --with-pgsql to specify non-default path.])
fi
]
)
CPPFLAGS=$OLD_CPPFLAGS
fi
],
[AC_MSG_RESULT(no)]
)
dnl ****************** End Postgres checking ***********************
dnl ****************** Begin MySQL checking ***********************
AC_MSG_CHECKING(mysql)
AS_IF([test "x$with_mysql" != "xno"],
[if test "x$with_mysql" != "xcheck"; then
MYSQL_DIR=$with_mysql
else
dnl try some standard locations
for i in /usr /usr/local /usr/local/mysql; do
test -f $i/bin/mysql_config && MYSQL_DIR=$i && break
done
fi
if test -n "$MYSQL_DIR" -a -x "${MYSQL_DIR}/bin/mysql_config"; then
MYSQL_CPPFLAGS=`${MYSQL_DIR}/bin/mysql_config --include`
OLD_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $MYSQL_CPPFLAGS"
AC_CHECK_HEADER(mysql.h,
[ CPPFLAGS=$OLD_CPPFLAGS
MYSQL_LIB=`${MYSQL_DIR}/bin/mysql_config --libs_r`
OLD_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $MYSQL_LIB"
AC_CHECK_LIB(mysqlclient_r, my_thread_init,
[ LDFLAGS=$OLD_LDFLAGS
AC_SUBST(MYSQL_LIB)
AC_SUBST(MYSQL_CPPFLAGS)
ltlibraries="libratedmysql.la $ltlibraries" ],
[ LDFLAGS=$OLD_LDFLAGS
if test "x$with_mysql" != "xcheck"; then
AC_MSG_ERROR(Cannot link with thread-safe MySQL lib (libmysqlclient_r))
else
AC_MSG_WARN(Cannot link with thread-safe MySQL lib (libmysqlclient_r))
fi ]) ],
[ CPPFLAGS=$OLD_CPPFLAGS
if test "x$with_mysql" != "xcheck"; then
AC_MSG_ERROR([Cannot find MySQL headers in ${MYSQL_CPPFLAGS}])
else
AC_MSG_WARN([Cannot find MySQL headers in ${MYSQL_CPPFLAGS}. Use --with-mysql to specify non-default path.])
fi ])
else
AC_MSG_WARN([mysql not found. Use --with-mysql to specify non-default path.])
fi
],
[AC_MSG_RESULT(no)]
)
dnl ****************** End MySQL checking ***********************
AC_SUBST(ltlibraries)
AC_CONFIG_FILES([Makefile \
src/Makefile \
etc/createdb \
man/rtgpoll.1])
AC_OUTPUT