File: configure.in

package info (click to toggle)
qsf 1.2.7-1.3
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 1,392 kB
  • ctags: 599
  • sloc: ansic: 9,981; sh: 816; awk: 17; makefile: 4
file content (280 lines) | stat: -rw-r--r-- 7,389 bytes parent folder | download | duplicates (3)
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
dnl Process this file with autoconf to produce a configure script.
dnl

AC_INIT(src/main/version.c)

dnl We're using C.
dnl
AC_LANG_C

dnl Output a header file.
dnl
AC_CONFIG_HEADER(src/include/config.h:autoconf/header.in)

dnl Set directory to check for Configure scripts in.
dnl
AC_CONFIG_AUX_DIR(autoconf/scripts)

dnl Read in package details.
dnl
PACKAGE=`cat $srcdir/doc/PACKAGE`
VERSION=`cat $srcdir/doc/VERSION`
UCPACKAGE=`tr a-z A-Z < $srcdir/doc/PACKAGE`
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(UCPACKAGE)
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(PROGRAM_NAME, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")

dnl Database backends we can use.
dnl
canuse_obtree="yes"
canuse_btree="yes"
canuse_list="yes"
canuse_gdbm="yes"
canuse_mysql="yes"
canuse_sqlite="yes"

dnl Check for compile-time options.
dnl
AC_ARG_ENABLE(debugging,
  [  --enable-debugging      compile with debugging symbols],
  if test "$enable_debugging" = "yes"; then
  	CFLAGS="-g -Wall"
  fi
)
AC_ARG_ENABLE(profiling,
  [  --enable-profiling      compile with profiling support],
  if test "$enable_profiling" = "yes"; then
  	CFLAGS="-pg $CFLAGS"
  fi
)
AC_ARG_ENABLE(static,
  [  --enable-static         enable static linking],
)
AC_ARG_WITH(obtree,
  [  --without-obtree        omit old binary tree backend support],
  canuse_obtree="$with_obtree"
)
AC_ARG_WITH(btree,
  [  --without-btree         omit binary tree backend support],
  canuse_btree="$with_btree"
)
AC_ARG_WITH(list,
  [  --without-list          omit list backend support],
  canuse_list="$with_list"
)
AC_ARG_WITH(gdbm,
  [  --without-gdbm          omit GDBM backend support],
  canuse_gdbm="$with_gdbm"
)
AC_ARG_WITH(mysql,
  [  --without-mysql         omit MySQL backend support],
  canuse_mysql="$with_mysql"
)
AC_ARG_WITH(sqlite,
  [  --without-sqlite        omit SQLite v2.x backend support],
  canuse_sqlite="$with_sqlite"
)

dnl Check for various programs.
dnl
CFLAGS=${CFLAGS-"-O2 -Wall -s"}
AC_PROG_CC
AC_PROG_CPP
AC_CHECK_TOOL(LD, ld, libtool --mode=link gcc)
AC_SUBST(LD)
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_CHECK_PROG(DO_GZIP, gzip, gzip -f9, touch)

dnl Check for the maths library.
dnl
AC_SEARCH_LIBS(pow, m, , [AC_ERROR(maths library not found)])

dnl Check for various header files and set various other macros.
dnl
AC_DEFINE(HAVE_CONFIG_H)
AC_HEADER_STDC
AC_C_BIGENDIAN([AC_DEFINE(IS_BIG_ENDIAN)])
AC_CHECK_FUNCS(memcpy, , [AC_ERROR(the memcpy() function is required)])
AC_CHECK_FUNCS(fcntl getopt getopt_long mkstemp snprintf vsnprintf utime)
AC_CHECK_HEADERS(fcntl.h getopt.h limits.h sys/resource.h mcheck.h)
AC_FUNC_MMAP

dnl Check for backend databases and choose one.
dnl
PREVCFLAGS="$CFLAGS"
PREVCPPFLAGS="$CPPFLAGS"
PREVLIBS="$LIBS"
if test "x$canuse_mysql" = "xyes"; then
	dnl
	dnl First we try linking without the mysql_config libs, because on
	dnl some systems that'll give us a dynamic library - the
	dnl mysql_config libs often point us to static libraries.
	dnl
	dnl If static linking is enabled, we ONLY try the mysql_config libs.
	dnl
	CFLAGS=`mysql_config --cflags 2>/dev/null`
	CPPFLAGS=`mysql_config --include 2>/dev/null` || CPPFLAGS="$CFLAGS"
	LIBS=""
	if test "x$enable_static" != "xyes"; then
		AC_CHECK_HEADERS(mysql.h, [
		  AC_SEARCH_LIBS(mysql_real_connect, mysqlclient, [
		    AC_SEARCH_LIBS(mysql_real_escape_string, mysqlclient,  , canuse_mysql="no")
		  ], canuse_mysql="no")
		], canuse_mysql="no")
	fi
	if test "x$canuse_mysql" = "xno"; then
		canuse_mysql=yes
		LIBS=`mysql_config --libs 2>/dev/null`
		AC_CHECK_HEADERS(mysql.h, [
		  AC_SEARCH_LIBS(mysql_real_escape_string, mysqlclient,  , canuse_mysql="no")
		], canuse_mysql="no")
	fi
	if test "x$enable_static" = "xyes"; then
		LIBS=`mysql_config --libs 2>/dev/null`
		AC_CHECK_HEADERS(mysql.h, [
		  AC_SEARCH_LIBS(mysql_real_query, mysqlclient,  , canuse_mysql="no")
		], canuse_mysql="no")
	fi
	if test "x$canuse_mysql" = "xyes"; then
		AC_CHECK_FUNCS(mysql_autocommit)
	fi
	MYSQLCFLAGS="$CFLAGS"
	MYSQLLIBS="$LIBS"
	CFLAGS="$PREVCFLAGS"
	CPPFLAGS="$PREVCPPFLAGS"
	LIBS="$PREVLIBS"
fi
if test "x$canuse_gdbm" = "xyes"; then
	PREVLIBS="$LIBS"
	LIBS=""
	AC_CHECK_HEADERS(gdbm.h, [
	  AC_SEARCH_LIBS(gdbm_open, gdbm, [
	    AC_CHECK_FUNCS(gdbm_fdesc)
	  ], canuse_gdbm="no")
	], canuse_gdbm="no")

	dnl
	dnl This is a hideous hack to try and find ".a" (static)
	dnl library replacements if --enable-static is given.
	dnl

	if test "x$enable_static" = "xyes"; then
		LIBDIR=`echo "$LIBS" | tr ' ' '\n' | sed -n 's/^-L//p'`
		test -z "$LIBDIR" && LIBDIR=/usr/lib
		LIBLIST=`echo "$LIBS" | tr ' ' '\n' | sed -n "s,^-l,$LIBDIR/lib,p" | sed -e 's,$,.a,'`
		NEWLIBS=""
		for i in $LIBLIST; do
			test -e "$i" && NEWLIBS="$NEWLIBS $i"
		done
		test -n "$NEWLIBS" && LIBS="$NEWLIBS"
	fi

	GDBMLIBS="$LIBS"
	LIBS="$PREVLIBS"
fi
if test "x$canuse_sqlite" = "xyes"; then
	LIBS=""
	AC_CHECK_HEADERS(sqlite.h, [
	  AC_SEARCH_LIBS(sqlite_open, sqlite, , canuse_sqlite="no")
	], canuse_sqlite="no")

	dnl Hideous hack as above.

	if test "x$enable_static" = "xyes"; then
		LIBDIR=`echo "$LIBS" | tr ' ' '\n' | sed -n 's/^-L//p'`
		test -z "$LIBDIR" && LIBDIR=/usr/lib
		LIBLIST=`echo "$LIBS" | tr ' ' '\n' | sed -n "s,^-l,$LIBDIR/lib,p" | sed -e 's,$,.a,'`
		NEWLIBS=""
		for i in $LIBLIST; do
			test -e "$i" && NEWLIBS="$NEWLIBS $i"
		done
		test -n "$NEWLIBS" && LIBS="$NEWLIBS"
	fi

	SQLITELIBS="$LIBS"
	LIBS="$PREVLIBS"
fi
if test "x$canuse_list" = "xyes"; then
	AC_CHECK_HEADERS(search.h, [
	  AC_CHECK_FUNCS(bsearch qsort, [], canuse_list="no")
	], canuse_list="no")
fi

AC_MSG_CHECKING(which backend databases are available)
BACKENDS=""

if test "x$canuse_obtree" = "xyes"; then
	AC_DEFINE(USING_OBTREE)
	BACKENDS="$BACKENDS obtree"
fi
if test "x$canuse_btree" = "xyes"; then
	AC_DEFINE(USING_BTREE)
	BACKENDS="$BACKENDS btree"
fi
if test "x$canuse_list" = "xyes"; then
	AC_DEFINE(USING_LIST)
	BACKENDS="$BACKENDS list"
fi
if test "x$canuse_gdbm" = "xyes"; then
	AC_DEFINE(USING_GDBM)
	EXTRALIBS="$EXTRALIBS $GDBMLIBS"
	BACKENDS="$BACKENDS GDBM"
fi
if test "x$canuse_mysql" = "xyes"; then
	AC_DEFINE(USING_MYSQL)
	EXTRALIBS="$EXTRALIBS $MYSQLLIBS"
	CFLAGS="$CFLAGS $MYSQLCFLAGS"
	BACKENDS="$BACKENDS MySQL"
fi
if test "x$canuse_sqlite" = "xyes"; then
	AC_DEFINE(USING_SQLITE)
	EXTRALIBS="$EXTRALIBS $SQLITELIBS"
	CFLAGS="$CFLAGS $SQLITECFLAGS"
	BACKENDS="$BACKENDS SQLite2"
fi
if test "x$BACKENDS" = "x"; then
	AC_MSG_RESULT(none)
	AC_MSG_ERROR(no usable database libraries found)
else
	AC_MSG_RESULT($BACKENDS)
fi
LIBS="$LIBS $EXTRALIBS"

AC_DEFINE_UNQUOTED(BACKENDS, "$BACKENDS")
AC_SUBST(BACKENDS)

test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
AC_SUBST(INSTALL_DATA)

dnl Fudging for separate build directories.
dnl
subdirs=""
for i in `find $srcdir/src -type d -print | sed s,$srcdir/,,`; do
  subdirs="$subdirs $i"
done

dnl Stitch together the Makefile fragments.
dnl
mk_segments="autoconf/Makefile.in"
for i in vars.mk package.mk filelist.mk unreal.mk modules.mk \
         rules.mk link.mk depend.mk; do
	mk_segments="$mk_segments:autoconf/make/$i"
done

dnl Output files (and create build directory structure too).
dnl
AC_OUTPUT(Makefile:$mk_segments doc/lsm:doc/lsm.in
          doc/quickref.1:doc/quickref.1.in
          doc/$PACKAGE.spec:doc/spec.in
          src/.dummy:doc/NEWS,
  rm -f src/.dummy
  for i in $subdirs; do
  	test -d $i || mkdir $i
  done
, subdirs="$subdirs")

dnl EOF