summaryrefslogtreecommitdiffstats
path: root/acinclude.m4
blob: eafdc2f9d86af7545cc211a9fe484bc4ded70f8e (plain)
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
dnl
dnl  $Id$
dnl

AC_DEFUN([AC_PREFIX_BLUEZ], [
	AC_PREFIX_DEFAULT(/usr)

	if test "$prefix" = "NONE"; then
		dnl no prefix and no sysconfdir, so default to /etc
		if test "$sysconfdir" = '${prefix}/etc'; then
			AC_SUBST([sysconfdir], ['/etc'])
		fi

		dnl no prefix and no mandir, so use ${prefix}/share/man as default
		if test "$mandir" = '${prefix}/man'; then
			AC_SUBST([mandir], ['${prefix}/share/man'])
		fi

		bluez_prefix="$ac_default_prefix"
	else
		bluez_prefix="$prefix"
	fi
])

AC_DEFUN([AC_PATH_BLUEZ], [
	AC_ARG_WITH(bluez, [  --with-bluez=DIR        BlueZ library is installed in DIR], [
		if (test "$withval" = "yes"); then
			bluez_includes=$bluez_prefix/include
			bluez_libraries=$bluez_prefix/lib
		else
			bluez_includes=$withval/include
			bluez_libraries=$withval/lib
		fi
	])

	BLUEZ_INCLUDES=""
	BLUEZ_LDFLAGS=""
	BLUEZ_LIBS=""

	ac_save_CFLAGS=$CFLAGS
	test -n "$bluez_includes" && CFLAGS="$CFLAGS -I$bluez_includes"

	ac_save_LDFLAGS=$LDFLAGS
	test -n "$bluez_libraries" && LDFLAGS="$LDFLAGS -L$bluez_libraries"

	AC_CHECK_HEADER(bluetooth/bluetooth.h,,
		AC_MSG_ERROR(Bluetooth header files not found))

	AC_CHECK_LIB(bluetooth, hci_open_dev,
		BLUEZ_LIBS="$BLUEZ_LIBS -lbluetooth",
		AC_MSG_ERROR(Bluetooth library not found))

	AC_CHECK_LIB(sdp, sdp_connect,
		BLUEZ_LIBS="$BLUEZ_LIBS -lsdp")

	CFLAGS=$ac_save_CFLAGS
	test -n "$bluez_includes" && BLUEZ_INCLUDES="-I$bluez_includes"

	LDFLAGS=$ac_save_LDFLAGS
	test -n "$bluez_libraries" && BLUEZ_LDFLAGS="-L$bluez_libraries"
	test -n "$bluez_libraries" && BLUEZ_LIBS="-L$bluez_libraries $BLUEZ_LIBS"

	AC_SUBST(BLUEZ_INCLUDES)
	AC_SUBST(BLUEZ_LDFLAGS)
	AC_SUBST(BLUEZ_LIBS)
])

AC_DEFUN([AC_PATH_USB], [
	AC_ARG_WITH(usb, [  --with-usb=DIR          USB library is installed in DIR], [
		if (test "$withval" = "yes"); then
			usb_includes=/usr/include
			usb_libraries=/usr/lib
		else
			usb_includes=$withval/include
			usb_libraries=$withval/lib
		fi
	])

	USB_INCLUDES=""
	USB_LDFLAGS=""
	USB_LIBS=""

	ac_save_CFLAGS=$CFLAGS
	test -n "$usb_includes" && CFLAGS="$CFLAGS -I$usb_includes"

	ac_save_LDFLAGS=$LDFLAGS
	test -n "$usb_libraries" && LDFLAGS="$LDFLAGS -L$usb_libraries"

	AC_CHECK_HEADER(usb.h,,
		AC_MSG_ERROR(USB header files not found))

	AC_CHECK_LIB(usb, usb_open,
		USB_LIBS="$USB_LIBS -lusb",
		AC_MSG_ERROR(USB library not found))

	CFLAGS=$ac_save_CFLAGS
	test -n "$usb_includes" && USB_INCLUDES="-I$usb_includes"

	LDFLAGS=$ac_save_LDFLAGS
	test -n "$usb_libraries" && USB_LDFLAGS="-L$usb_libraries"
	test -n "$usb_libraries" && USB_LIBS="-L$usb_libraries $USB_LIBS"

	AC_SUBST(USB_INCLUDES)
	AC_SUBST(USB_LDFLAGS)
	AC_SUBST(USB_LIBS)
])

AC_DEFUN([AC_PATH_DBUS], [
	AC_ARG_ENABLE(dbus, [  --enable-dbus           enable D-BUS support], [
		dbus_enable=$enableval
	])

	AC_ARG_WITH(dbus, [  --with-dbus=DIR         D-BUS library is installed in DIR], [
		if (test "$withval" = "yes"); then
			dbus_includes=$bluez_prefix/include
			dbus_libraries=$bluez_prefix/lib
		else
			dbus_includes=$withval/include
			dbus_libraries=$withval/lib
		fi
		dbus_enable=yes
	])

	DBUS_INCLUDES=""
	DBUS_LDFLAGS=""
	DBUS_LIBS=""

	ac_save_CFLAGS=$CFLAGS
	if test -n "$dbus_includes"; then 
		CFLAGS="$CFLAGS -I$dbus_includes -I$dbus_includes/dbus-1.0"
	else
		CFLAGS="$CFLAGS -I$bluez_prefix/include/dbus-1.0 -I/usr/include/dbus-1.0"
	fi
	CFLAGS="$CFLAGS -DDBUS_API_SUBJECT_TO_CHANGE"

	ac_save_LDFLAGS=$LDFLAGS
	if test -n "$dbus_libraries"; then
		CFLAGS="$CFLAGS -I$dbus_libraries/dbus-1.0/include"
		LDFLAGS="$LDFLAGS -L$dbus_libraries"
	else
		CFLAGS="$CFLAGS -I$bluez_prefix/include/dbus-1.0 -I/usr/lib/dbus-1.0/include"
	fi

	if test "$dbus_enable" = "yes"; then
		AC_CHECK_HEADER(dbus/dbus.h,,
			dbus_enable=no)

		AC_CHECK_LIB(dbus-1, dbus_error_init,
			DBUS_LIBS="$DBUS_LIBS -ldbus-1",
			dbus_enable=no)
	fi

	CFLAGS=$ac_save_CFLAGS
	if test -n "$dbus_includes"; then
		DBUS_INCLUDES="-I$dbus_includes -I$dbus_includes/dbus-1.0"
	else
		DBUS_INCLUDES="-I$bluez_prefix/include/dbus-1.0 -I/usr/include/dbus-1.0"
	fi

	LDFLAGS=$ac_save_LDFLAGS
	if test -n "$dbus_libraries"; then
		DBUS_INCLUDES="$DBUS_INCLUDES -I$dbus_libraries/dbus-1.0/include"
		DBUS_LDFLAGS="-L$dbus_libraries"
		DBUS_LIBS="-L$dbus_libraries $DBUS_LIBS"
	else
		DBUS_INCLUDES="$DBUS_INCLUDES -I$bluez_prefix/include/dbus-1.0 -I/usr/lib/dbus-1.0/include"
	fi

	AC_SUBST(DBUS_INCLUDES)
	AC_SUBST(DBUS_LDFLAGS)
	AC_SUBST(DBUS_LIBS)

	AM_CONDITIONAL(DBUS, test "$dbus_enable" = "yes")
])

AC_DEFUN([AC_PATH_CUPS], [
	AC_ARG_ENABLE(cups, [  --enable-cups           enable CUPS support], [
		cups_enable=$enableval
		cups_prefix=/usr
	])

	AC_ARG_WITH(cups, [  --with-cups=DIR         CUPS is installed in DIR], [
		if (test "$withval" = "yes"); then
			cups_prefix=/usr
		else
			cups_prefix=$withval
		fi
		cups_enable=yes
	])

	CUPS_BACKEND_DIR=""

	if test "$cups_enable" = "yes"; then
		AC_MSG_CHECKING(for CUPS backend directory)

		if (test -d "$cups_prefix/lib/cups/backend"); then
			CUPS_BACKEND_DIR="$cups_prefix/lib/cups/backend"
		elif (test -d "$libdir/cups/backend"); then
			CUPS_BACKEND_DIR="$libdir/cups/backend"
		else
			cups_enable=no
		fi

		if test "$cups_enable" = "yes"; then
			AC_MSG_RESULT($CUPS_BACKEND_DIR)
		else
			AC_MSG_RESULT($cups_enable)
		fi
	fi

	AC_SUBST(CUPS_BACKEND_DIR)

	AM_CONDITIONAL(CUPS, test "$cups_enable" = "yes")
])