-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure.ac
315 lines (264 loc) · 8.38 KB
/
configure.ac
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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(scanbd, 1.92, [email protected])
# allow check that we are really in the source directory
AC_CONFIG_SRCDIR([src/scanbd/scanbd.c])
AC_CONFIG_MACRO_DIR([m4])
# Do not enforce GNU file conventions like ChangeLog README etc.
AM_INIT_AUTOMAKE( foreign )
# Do not automatically rebuild autoconf stuff
AM_MAINTAINER_MODE
# Initialize libtool support
LT_INIT([disable-static])
# Determine host information
AC_CANONICAL_HOST
# Check for programs
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_CXX
AM_PROG_CC_C_O
AC_PROG_LN_S
# Find path to saned
AC_PATH_PROG(SANED_PATH,[saned],
[AC_MSG_ERROR([Saned not found!]) ],
[$PATH:/usr/libexec:/usr/sbin:/usr/local/libexec:/usr/local/sbin])
# autoscan complains about this being missing, but autoreconf thinks it is superfluous
# AC_PROG_RANLIB
# The dlopen() function is in the C library for *BSD and in
# libdl on GLIBC-based systems
AC_SEARCH_LIBS([dlopen], [dl dld], [], [
AC_MSG_ERROR([unable to find the dlopen() function])
])
AC_SEARCH_LIBS([pthread_create], [pthread], [], [
AC_MSG_ERROR([unable to find the pthread_create() function])
])
# Check for required functions
AC_CHECK_FUNCS([alarm dup2 ftruncate getcwd memset putenv regcomp strdup strerror],
[], AC_MSG_ERROR([Required function is missing ]))
# Check for required header files
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h sys/socket.h sys/time.h syslog.h pthread.h],
[], AC_MSG_ERROR([Required header file is missing ]))
# check for required types
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_TYPE_PID_T
# We define these to make autoscan happy, but we do not use the results
AC_FUNC_CHOWN
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_HEADER_STDBOOL
OS_CFLAGS="-Wall -Wextra -std=c99 -g"
dnl check for optional headers
AC_CHECK_HEADERS(linux/limits.h \
utmp.h \
utmpx.h)
# check for enable-hal
AC_ARG_ENABLE(hal,
AC_HELP_STRING([--enable-hal], [force to use hal]),
[disable_hal_udev_autodetect=yes])
# check for enable-udev
AC_ARG_ENABLE(udev,
AC_HELP_STRING([--enable-udev], [force to use udev]),
[disable_hal_udev_autodetect=yes])
# check for mandatory dependencies
#=================================
# check for libconfuse
PKG_CHECK_MODULES([CONFUSE], [libconfuse])
# check for dbus
PKG_CHECK_MODULES([DBUS], [dbus-1])
if test x"${disable_hal_udev_autodetect}" == "xyes"
then
AC_MSG_NOTICE([disabling autodetecting hal or udev])
if test x"${enable_hal}" == x"yes"
then
PKG_CHECK_MODULES([HAL], [hal],[AC_DEFINE([USE_HAL], [1], [Use HAL])])
fi
if test x"${enable_udev}" == x"yes"
then
PKG_CHECK_MODULES([UDEV],[libudev],[AC_DEFINE([USE_LIBUDEV], [1], [Use UDEV])])
fi
else
dnl Check for udev and if we do not have it, check for hal
PKG_CHECK_MODULES([UDEV],[libudev],
[AC_DEFINE([USE_LIBUDEV], [1], [Use UDEV])],
[PKG_CHECK_MODULES([HAL], [hal],
[AC_DEFINE([USE_HAL], [1], [Use HAL])],
[AC_MSG_WARN([Neither Udev nor Hal are found, automatic dynamic detection of scanners is not supported! Use SIGHUP instead.])]
)]
)
fi
# check configuration options
#============================
# scanbd configurationdir
AC_ARG_WITH(scanbdconfdir,
AC_HELP_STRING([--with-scanbdconfdir=DIR],
[scanbd configuration directory (PREFIX/etc/scanbd)]),
[SCANBD_CFG_DIR="${withval}"],
[SCANBD_CFG_DIR="${sysconfdir}/scanbd"])
AC_SUBST(SCANBD_CFG_DIR)
# scanbuttond configurationdir
AC_ARG_WITH(scanbuttondlibdir,
AC_HELP_STRING([--with-scanbuttondlibdir=DIR],
[ scanbuttond backend configuration directory (LIBDIR/scanbd/scanbuttond/backends)]),
[SCANBUTTOND_LIB_DIR="${withval}"],
[SCANBUTTOND_LIB_DIR="${libdir}/scanbd/scanbuttond/backends"])
AC_SUBST(SCANBUTTOND_LIB_DIR)
# check for Werror
EXTRA_CFLAGS=""
AC_ARG_ENABLE(Werror,
AC_HELP_STRING([--disable-Werror], [don't use gcc's -Werror option when building]))
if test x"${enable_Werror}" != "xno"
then
EXTRA_CFLAGS=$EXTRA_CFLAGS" -Werror"
fi
# shall we set NDEBUG?
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--disable-debug], [disable debugging code (NDEBUG)]))
if test "x${enable_debug}" == "xno"
then
EXTRA_CFLAGS=$EXTRA_CFLAGS" -DNDEBUG"
fi
# Do we have systemd?
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
if test "x$with_systemdsystemunitdir" != "xno"; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
AC_DEFINE(HAVE_SYSTEMD, [1], [Do we use systemd on this system?])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "x")
# TODO: add check for udev
# TODO: add check for HAL
# check for enable-scanbuttond
AC_ARG_ENABLE(scanbuttond,
AC_HELP_STRING([--enable-scanbuttond], [Use scanbuttond instead of Sane]))
if test x"${enable_scanbuttond}" == "xyes"
then
use_scanbuttond=yes
# Check for libusb except for FreeBSD that does not have libusb.pc
if test `uname` == "FreeBSD"
then
if test x"${LIBUSB_CFLAGS}" == "x"
then
LIBUSB_CFLAGS="-I/usr/include "
fi
if test x"${LIBUSB_LIBS}" == "x"
then
LIBUSB_LIBS="-L/usr/lib -lusb "
fi
AC_SUBST(LIBUSB_CFLAGS)
AC_SUBST(LIBUSB_LIBS)
else
PKG_CHECK_MODULES([LIBUSB], [libusb])
fi
SCANNER_CFLAGS="-DUSE_SCANBUTTOND"
AC_DEFINE([USE_SCANBUTTOND], [1], ["Use scanbuttond"])
else
use_sane=yes
AC_DEFINE([USE_SANE], [1], [Use Sane])
PKG_CHECK_MODULES([SANE], [sane-backends >= 1.0],
[test_sane_config=no],
[test_sane_config=yes])
fi
# fallback to usage of sane-config if pkg-config fails
if test x"${use_sane}" == "xyes" -a x"${test_sane_config}" == "xyes"
then
if test x"${SANE_LIBS}" == "x" -a x"${SANE_CFLAGS}" = "x"
then
AC_CHECK_PROG([SANE_CONFIG], [sane-config], sane-config, no)
if test x"${SANE_CONFIG}" = "xno"
then
AC_MSG_ERROR([Cannot find configuration for sane using pkg-config and sane-config does not exist])
fi
SANE_LIBS=`sane-config --libs`
SANE_CFLAGS=`sane-config --cflags`
fi
fi
# user setting
AC_ARG_WITH( user,
AC_HELP_STRING([--with-user=USER],
[userid to run as (guess)]),
[SCANBD_USER="${withval}"],
[
if test "x${UDEV_LIBS}" != "x"; then
if ! grep saned: /etc/passwd > /dev/null; then
AC_MSG_NOTICE([For scanbd with udev we assume that user saned is available on your system!])
fi
SCANBD_USER=saned
else
case ${host_os} in
*-*-openbsd* | *-*-freebsd* | *-*-netbsd*)
SCANBD_USER=root
;;
*-*-linux* | linux-*)
SCANBD_USER=saned
AC_MSG_NOTICE([On linux we use user saned, plase make sure you add it!])
;;
*)
AC_MSG_ERROR([Target OS ${host_os} not known, please set option --with-user for configure!])
;;
esac
fi
]
)
AC_MSG_NOTICE([Using user: ${SCANBD_USER}])
AC_SUBST(SCANBD_USER)
# group setting
AC_ARG_WITH( group,
AC_HELP_STRING([--with-group=GROUP],
[Groupid to run as (guess)]),
[SCANBD_GROUP="${withval}"],
[
if test "x${UDEV_LIBS}" != "x"; then
if ! grep saned /etc/group > /dev/null; then
AC_MSG_NOTICE([For scanbd with udev we assume that group saned is available on your system!])
fi
SCANBD_GROUP=saned
else
case ${host_os} in
*-*-openbsd* | *-*-freebsd* | *-*-netbsd*)
SCANBD_GROUP=daemon
;;
*-*-linux* | linux-*)
if grep scanner: /etc/group > /dev/null; then
SCANBD_GROUP=scanner
else
SCANBD_GROUP=lp
fi
;;
*)
AC_MSG_ERROR([Target OS ${host_os} not known, please set option --with-group for configure!])
;;
esac
fi
]
)
AC_MSG_NOTICE([Using group: ${SCANBD_GROUP}])
AC_SUBST(SCANBD_GROUP)
AM_CONDITIONAL(USE_SANE, test "x$use_sane" == "xyes")
AM_CONDITIONAL(USE_SCANBUTTOND, test "x$use_scanbuttond" == xyes)
# define substitutions to be applied in the output
AC_SUBST([OS_CFLAGS])
AC_SUBST([OS_CPPFLAGS])
AC_SUBST([EXTRA_CFLAGS])
# header file that contains output from configure
# We do not use it now, so all flags are set as -D on the compiler command line
# AC_CONFIG_HEADERS([config.h])
# Generate the output files
AC_OUTPUT([
Makefile
src/scanbd/Makefile
src/scanbuttond/Makefile
src/scanbuttond/backends/Makefile
src/scanbuttond/interface/Makefile
src/scanbuttond/include/Makefile
integration/Makefile
contrib/Makefile
doc/Makefile
conf/Makefile
scripts/Makefile
])