File: acinclude.m4

package info (click to toggle)
sphinxsearch 2.0.4-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 12,520 kB
  • sloc: cpp: 66,189; xml: 28,399; sh: 9,079; php: 3,552; ansic: 2,679; java: 1,294; ruby: 1,280; yacc: 1,159; python: 900; pascal: 699; makefile: 195; perl: 191; lex: 151; sql: 77
file content (403 lines) | stat: -rw-r--r-- 12,135 bytes parent folder | download
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
dnl ---------------------------------------------------------------------------
dnl Macro: AC_CHECK_MYSQL
dnl Check for custom MySQL paths in --with-mysql-* options.
dnl If some paths are missing,  check if mysql_config exists. 
dnl ---------------------------------------------------------------------------

AC_DEFUN([AC_CHECK_MYSQL],[

mysqlconfig_locations="mysql_config /usr/bin/mysql_config /usr/local/bin/mysql_config /usr/local/mysql/bin/mysql_config /opt/mysql/bin/mysql_config /usr/pkg/bin/mysql_config"
user_mysql_includes=
user_mysql_libs=

# check explicit MySQL root for mysql_config, include, lib
if test [ x$1 != xyes -a x$1 != xno ]
then
	mysqlroot=`echo $1 | sed -e 's+/$++'`
	if test [ -x "$mysqlroot/bin/mysql_config" ]
	then
		# if there's mysql_config, that's the best route
		mysqlconfig_locations="$mysqlroot/bin/mysql_config"
	elif test [ -d "$mysqlroot/include" -a -d "$mysqlroot/lib" ]
	then
		# explicit root; do not check well-known paths
		mysqlconfig_locations=

		# includes
		if test [ -d "$mysqlroot/include/mysql" ]
		then
			user_mysql_includes="$mysqlroot/include/mysql"
		else
			user_mysql_includes="$mysqlroot/include"
		fi

		# libs
		if test [ -d "$mysqlroot/lib/mysql" ]
		then
			user_mysql_libs="$mysqlroot/lib/mysql"
		else
			user_mysql_libs="$mysqlroot/lib"
		fi
	else 
		AC_MSG_ERROR([invalid MySQL root directory '$mysqlroot'; neither bin/mysql_config, nor include/ and lib/ were found there])
	fi
fi


# try running mysql_config
AC_MSG_CHECKING([for mysql_config])
for mysqlconfig in $mysqlconfig_locations
do
	if test [ -n "$mysqlconfig" ]
	then
		MYSQL_CFLAGS=`${mysqlconfig} --cflags 2>/dev/null` 
		MYSQL_LIBS=`${mysqlconfig} --libs 2>/dev/null`

		if test [ $? -eq 0 ]
		then
			AC_MSG_RESULT([$mysqlconfig])
			mysqlconfig=
			break
		else
			MYSQL_CFLAGS=
			MYSQL_LIBS=
		fi
	fi
done
if test [ -n "$mysqlconfig" ]
then
	mysqlconfig_used=
	AC_MSG_RESULT([not found])
else
	mysqlconfig_used=yes
fi


# if there's nothing from mysql_config, check well-known include paths
# explicit overrides will be applied later
if test [ -z "$MYSQL_CFLAGS" ]
then
	for CANDIDATE in "$user_mysql_includes" "/usr/local/mysql/include" "/usr/local/mysql/include/mysql" \
		"/usr/include/mysql"
	do
		if test [ -n "$CANDIDATE" -a -r "$CANDIDATE/mysql.h" ]
		then
			MYSQL_CFLAGS="-I$CANDIDATE"
			break
		fi
	done
fi


# if there's nothing from mysql_config, check well-known library paths
# explicit overrides will be applied later
if test [ -z "$MYSQL_LIBS" ]
then
	for CANDIDATE in "$user_mysql_libs" "/usr/lib64/mysql" \
		"/usr/local/mysql/lib/mysql" "/usr/local/mysql/lib" \
		"/usr/local/lib/mysql" "/usr/lib/mysql" \
		"/opt/mysql/lib/mysql" "/usr/pkg/lib/mysql"
	do
		if test [ -n "$CANDIDATE" -a -d "$CANDIDATE" ]
		then
			MYSQL_LIBS="-L$CANDIDATE -lmysqlclient -lz"
			break
		fi
	done
fi


# apply explicit include path overrides
AC_ARG_WITH([mysql-includes],
	AC_HELP_STRING([--with-mysql-includes], [path to MySQL header files]),
	[ac_cv_mysql_includes=$withval])
if test [ -n "$ac_cv_mysql_includes" ]
then
	MYSQL_CFLAGS="-I$ac_cv_mysql_includes"
fi


# apply explicit lib path overrides
AC_ARG_WITH([mysql-libs], 
	AC_HELP_STRING([--with-mysql-libs], [path to MySQL libraries]),
	[ac_cv_mysql_libs=$withval])
if test [ -n "$ac_cv_mysql_libs" ]
then
	# Trim trailing '.libs' if user passed it in --with-mysql-libs option
	ac_cv_mysql_libs=`echo ${ac_cv_mysql_libs} | sed -e 's/.libs$//' \
		-e 's+.libs/$++'`
	MYSQL_LIBS="-L$ac_cv_mysql_libs -lmysqlclient -lz"
fi

# if we got options from mysqlconfig try to actually use them
if test [ -n "$mysqlconfig_used" -a -n "$MYSQL_CFLAGS" -a -n "$MYSQL_LIBS" ]
then
	_CFLAGS=$CFLAGS
	_LIBS=$LIBS
	
	CFLAGS="$CFLAGS $MYSQL_CFLAGS"
	LIBS="$LIBS $MYSQL_LIBS"
	
	AC_CHECK_FUNC(mysql_real_connect,[],
	[
		# if mysql binary was built using a different compiler and we
		# got options from mysql_config some of them might not work
		# with compiler we will be using
		
		# throw away everything that isn't one of -D -L -I -l and retry
		MYSQL_CFLAGS=`echo $MYSQL_CFLAGS | sed -e 's/-[[^DLIl]][[^ ]]*//g'`
		MYSQL_LIBS=`echo $MYSQL_LIBS | sed -e 's/-[[^DLIl]][[^ ]]*//g'`

		CFLAGS="$_CFLAGS $MYSQL_CFLAGS"
		LIBS="$_LIBS $MYSQL_LIBS"

		unset ac_cv_func_mysql_real_connect
		AC_CHECK_FUNC(mysql_real_connect,[],
		[
			# ... that didn't help
			# clear flags, the code below will complain
			MYSQL_CFLAGS=
			MYSQL_LIBS=
		])
	])
	CFLAGS=$_CFLAGS
	LIBS=$_LIBS
fi

# now that we did all we could, perform final checks
AC_MSG_CHECKING([MySQL include files])
if test [ -z "$MYSQL_CFLAGS" ]
then
	AC_MSG_ERROR([missing include files.

******************************************************************************
ERROR: cannot find MySQL include files.

Check that you do have MySQL include files installed.
The package name is typically 'mysql-devel'.

If include files are installed on your system, but you are still getting
this message, you should do one of the following:

1) either specify includes location explicitly, using --with-mysql-includes;
2) or specify MySQL installation root location explicitly, using --with-mysql;
3) or make sure that the path to 'mysql_config' program is listed in
   your PATH environment variable.

To disable MySQL support, use --without-mysql option.
******************************************************************************
])
else
	AC_MSG_RESULT([$MYSQL_CFLAGS])
fi


AC_MSG_CHECKING([MySQL libraries])
if test [ -z "$MYSQL_LIBS" ]
then
	AC_MSG_ERROR([missing libraries.

******************************************************************************
ERROR: cannot find MySQL libraries.

Check that you do have MySQL libraries installed.
The package name is typically 'mysql-devel'.

If libraries are installed on your system, but you are still getting
this message, you should do one of the following:

1) either specify libraries location explicitly, using --with-mysql-libs;
2) or specify MySQL installation root location explicitly, using --with-mysql;
3) or make sure that the path to 'mysql_config' program is listed in
   your PATH environment variable.

To disable MySQL support, use --without-mysql option.
******************************************************************************
])
else
	AC_MSG_RESULT([$MYSQL_LIBS])
fi


])

dnl ---------------------------------------------------------------------------
dnl Macro: AC_CHECK_PGSQL
dnl First check for custom PostgreSQL paths in --with-pgsql-* options.
dnl If some paths are missing,  check if pg_config exists. 
dnl ---------------------------------------------------------------------------

AC_DEFUN([AC_CHECK_PGSQL],[

# Check for custom includes path
if test [ -z "$ac_cv_pgsql_includes" ] 
then 
	AC_ARG_WITH([pgsql-includes], 
		AC_HELP_STRING([--with-pgsql-includes], [path to PostgreSQL header files]),
		[ac_cv_pgsql_includes=$withval])
fi
if test [ -n "$ac_cv_pgsql_includes" ]
then
	AC_CACHE_CHECK([PostgreSQL includes], [ac_cv_pgsql_includes], [ac_cv_pgsql_includes=""])
	PGSQL_CFLAGS="-I$ac_cv_pgsql_includes"
fi

# Check for custom library path
if test [ -z "$ac_cv_pgsql_libs" ]
then
	AC_ARG_WITH([pgsql-libs], 
		AC_HELP_STRING([--with-pgsql-libs], [path to PostgreSQL libraries]),
		[ac_cv_pgsql_libs=$withval])
fi
if test [ -n "$ac_cv_pgsql_libs" ]
then
	AC_CACHE_CHECK([PostgreSQL libraries], [ac_cv_pgsql_libs], [ac_cv_pgsql_libs=""])
	PGSQL_LIBS="-L$ac_cv_pgsql_libs -lpq"
fi

# If some path is missing, try to autodetermine with pgsql_config
if test [ -z "$ac_cv_pgsql_includes" -o -z "$ac_cv_pgsql_libs" ]
then
    if test [ -z "$pgconfig" ]
    then 
        AC_PATH_PROG(pgconfig,pg_config)
    fi
    if test [ -z "$pgconfig" ]
    then
        AC_MSG_ERROR([pg_config executable not found
********************************************************************************
ERROR: cannot find PostgreSQL libraries. If you want to compile with PosgregSQL support,
       you must either specify file locations explicitly using 
       --with-pgsql-includes and --with-pgsql-libs options, or make sure path to 
       pg_config is listed in your PATH environment variable. If you want to 
       disable PostgreSQL support, use --without-pgsql option.
********************************************************************************
])
    else
        if test [ -z "$ac_cv_pgsql_includes" ]
        then
            AC_MSG_CHECKING(PostgreSQL C flags)
            PGSQL_CFLAGS="-I`${pgconfig} --includedir`"
            AC_MSG_RESULT($PGSQL_CFLAGS)
        fi
        if test [ -z "$ac_cv_pgsql_libs" ]
        then
            AC_MSG_CHECKING(PostgreSQL linker flags)
            PGSQL_LIBS="-L`${pgconfig} --libdir` -lpq"
            AC_MSG_RESULT($PGSQL_LIBS)
        fi
    fi
fi
])

dnl ---------------------------------------------------------------------------
dnl Macro: AC_CHECK_LIBSTEMMER
dnl Author: Adam Golebiowski <adamg@pld-linux.org>
dnl First check for custom libstemmer include path in --with-libstemmer=* option
dnl If not given, try to guess.
dnl ---------------------------------------------------------------------------

AC_DEFUN([AC_CHECK_LIBSTEMMER],[

# cflags and libs
LIBSTEMMER_CFLAGS=
LIBSTEMMER_LIBS=

# possible includedir paths
includedirs="/usr/include /usr/include/libstemmer /usr/include/libstemmer_c"

# possible libdirs -- 64bit first in case of multiarch environments
libdirs="/usr/lib/$(/usr/bin/dpkg-architecture -qDEB_HOST_MULTIARCH) /usr/lib64 /usr/local/lib64 /usr/lib /usr/local/lib"

# possible libnames -- shared one first, then static one
libnames="stemmer stemmer_c"

# was (include) path explicitely given?
if test [ -n "$ac_cv_use_libstemmer" -a x$ac_cv_use_libstemmer != xyes]; then
       includedirs=$ac_cv_use_libstemmer
fi

# try to find header files
for includedir in $includedirs
do
       if test [ -f $includedir/libstemmer.h ]; then
               LIBSTEMMER_CFLAGS="-I$includedir"
               break
       fi
done

# try to find shared library
for libname in $libnames
do
       for libdir in $libdirs
       do
               if test [ -f $libdir/lib${libname}.so ]; then
                       LIBSTEMMER_LIBS="-L$libdir -l$libname"
                       break 2
               fi
       done
done

# if not found, check static libs
if test [ -z "$LIBSTEMMER_LIBS" ]; then
       for libname in $libnames
       do
               for libdir in $libdirs
               do
                       if test [ -f $libdir/lib${libname}.a ]; then
                               LIBSTEMMER_LIBS="$libdir/lib${libname}.a"
                               break 2
                       fi
               done
       done
fi

# if LIBSTEMMER_LIBS is not set at this moment,
# our last chanceis to check for existance of internal copy of libstemmer_c
# in case it doesn't exist -- we lost
if test [ -z "$LIBSTEMMER_LIBS" ]; then
       if test [ -d ./libstemmer_c ]; then
               ac_cv_use_internal_libstemmer=1
               LIBSTEMMER_LIBS="\$(top_srcdir)/libstemmer_c/libstemmer.a"
               LIBSTEMMER_CFLAGS="-I\$(top_srcdir)/libstemmer_c/include"
       else
               AC_MSG_ERROR([not found])
       fi
fi

])

dnl ---------------------------------------------------------------------------
dnl Macro: SPHINX_CONFIGURE_PART
dnl
dnl Tells what stage is ./configure running now, nicely formatted
dnl ---------------------------------------------------------------------------

dnl SPHINX_CONFIGURE_PART(MESSAGE)
AC_DEFUN([SPHINX_CONFIGURE_PART],[
	AC_MSG_RESULT()
	AC_MSG_RESULT([$1])
	TMP=`echo $1 | sed -e sX.X-Xg`
	AC_MSG_RESULT([$TMP])
	AC_MSG_RESULT()
])

dnl ---------------------------------------------------------------------------
dnl Macro: SPHINX_CHECK_DEFINE
dnl
dnl Checks if this symbol is defined in that header file
dnl ---------------------------------------------------------------------------

AC_DEFUN([SPHINX_CHECK_DEFINE],[
	AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
		AC_EGREP_CPP(YES_IS_DEFINED, [
#include <$2>
#ifdef $1
YES_IS_DEFINED
#endif
		], ac_cv_define_$1=yes, ac_cv_define_$1=no)
	])
	if test "$ac_cv_define_$1" = "yes"; then
		AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined in $2])
	fi
])