root/trunk/acinclude.m4

Revision 340, 8.0 KB (checked in by hsattler, 6 months ago)

add a system specific define for Irda (like for bluetooth), add the missing one for Windows

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1AC_DEFUN([AC_PROG_CC_PIE], [
2        AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
3                echo 'void f(){}' > conftest.c
4                if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
5                        ac_cv_prog_cc_pie=yes
6                else
7                        ac_cv_prog_cc_pie=no
8                fi
9                rm -rf conftest*
10        ])
11])
12
13AC_DEFUN([AC_INIT_OPENOBEX], [
14        AC_PREFIX_DEFAULT(/usr/local)
15
16        if (test "${CFLAGS}" = ""); then
17                CFLAGS="-Wall -O2"
18        fi
19
20        if (test "${prefix}" = "NONE"); then
21                dnl no prefix and no sysconfdir, so default to /etc
22                if (test "$sysconfdir" = '${prefix}/etc'); then
23                        AC_SUBST([sysconfdir], ['/etc'])
24                fi
25
26                dnl no prefix and no mandir, so use ${prefix}/share/man as default
27                if (test "$mandir" = '${prefix}/man'); then
28                        AC_SUBST([mandir], ['${prefix}/share/man'])
29                fi
30
31                prefix="${ac_default_prefix}"
32        fi
33
34        if (test "${libdir}" = '${exec_prefix}/lib'); then
35                libdir="${prefix}/lib"
36        fi
37
38        if (test "$sysconfdir" = '${prefix}/etc'); then
39                configdir="${prefix}/etc/openobex"
40        else
41                configdir="${sysconfdir}/openobex"
42        fi
43
44        AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", [Directory for the configuration files])
45])
46
47AC_DEFUN([AC_PATH_WIN32], [
48        case $host in
49        *-*-mingw32*)
50                EXTRA_LIBS="$EXTRA_LIBS -lws2_32"
51                ;;
52        esac
53        AC_SUBST(EXTRA_LIBS)
54])
55
56AC_DEFUN([AC_PATH_IRDA_LINUX], [
57        AC_CACHE_CHECK([for IrDA support], irda_found, [
58                AC_TRY_COMPILE([
59                                #include <sys/socket.h>
60                                #include "lib/irda.h"
61                        ], [
62                                struct irda_device_list l;
63                        ], irda_found=yes, irda_found=no)
64        ])
65        irda_linux=$irda_found
66])
67
68AC_DEFUN([AC_PATH_IRDA_WIN32], [
69        AC_CACHE_VAL(irda_found, [
70                AC_CHECK_HEADERS(af_irda.h, irda_found=yes, irda_found=no,
71                                 [
72                                  #include <winsock2.h>
73                ])
74        ])
75      irda_windows=$irda_found
76        AC_MSG_CHECKING([for IrDA support])
77        AC_MSG_RESULT([$irda_found])
78])
79
80AC_DEFUN([AC_PATH_IRDA], [
81        case $host in
82        *-*-linux*)
83                AC_PATH_IRDA_LINUX
84                ;;
85        *-*-mingw32*)
86                AC_PATH_IRDA_WIN32
87                ;;
88        *)
89                irda_found=no;
90                AC_MSG_CHECKING([for IrDA support])
91                AC_MSG_RESULT([$irda_found])
92                ;;
93        esac
94])
95
96AC_DEFUN([AC_PATH_WINBT], [
97        AC_CACHE_VAL(winbt_found,[
98               AC_CHECK_HEADERS(ws2bth.h, winbt_found=yes, winbt_found=no,
99                                [
100                                  #include <winsock2.h>
101               ])
102        ])
103        AC_MSG_CHECKING([for Windows Bluetooth support])
104        AC_MSG_RESULT([$winbt_found])
105])
106
107
108AC_DEFUN([AC_PATH_NETBSDBT], [
109        AC_CACHE_CHECK([for NetBSD Bluetooth support], netbsdbt_found, [
110                AC_TRY_COMPILE([
111                                #include <bluetooth.h>
112                        ], [
113                                struct sockaddr_bt *bt;
114                        ], netbsdbt_found=yes, netbsdbt_found=no)
115        ])
116])
117
118AC_DEFUN([AC_PATH_FREEBSDBT], [
119        AC_CACHE_CHECK([for FreeBSD Bluetooth support], freebsdbt_found, [
120                AC_TRY_COMPILE([
121                                #include <bluetooth.h>
122                        ], [
123                                struct sockaddr_rfcomm *rfcomm;
124                        ], freebsdbt_found=yes, freebsdbt_found=no)
125        ])
126])
127
128AC_DEFUN([AC_PATH_BLUEZ], [
129        PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no))
130])
131
132AC_DEFUN([AC_PATH_BLUETOOTH], [
133        case $host in
134        *-*-linux*)
135                AC_PATH_BLUEZ
136                ;;
137        *-*-freebsd*)
138                AC_PATH_FREEBSDBT
139                ;;
140        *-*-netbsd*)
141                AC_PATH_NETBSDBT
142                ;;
143        *-*-mingw32*)
144                AC_PATH_WINBT
145                ;;
146        esac
147        AC_SUBST(BLUETOOTH_CFLAGS)
148        AC_SUBST(BLUETOOTH_LIBS)
149])
150
151AC_DEFUN([AC_PATH_USB], [
152        usb_lib_found=no
153        case $host in
154        *-*-mingw32*)
155                USB_CFLAGS=""
156                USB_LIBS="-lusb"
157                usb_lib_found=yes
158                ;;
159        *)
160                PKG_CHECK_MODULES(USB, libusb, usb_lib_found=yes, AC_MSG_RESULT(no))
161                AC_CHECK_FILE(${prefix}/lib/pkgconfig/libusb.pc, REQUIRES="libusb")
162                ;;
163        esac
164        AC_SUBST(USB_CFLAGS)
165        AC_SUBST(USB_LIBS)
166
167        usb_get_busses=no
168        AC_CHECK_LIB(usb, usb_get_busses, usb_get_busses=yes, AC_DEFINE(NEED_USB_GET_BUSSES, 1, [Define to 1 if you need the usb_get_busses() function.]))
169
170        usb_interrupt_read=no
171        AC_CHECK_LIB(usb, usb_interrupt_read, usb_interrupt_read=yes, AC_DEFINE(NEED_USB_INTERRUPT_READ, 1, [Define to 1 if you need the usb_interrupt_read() function.]))
172
173        if (test "$usb_lib_found" = "yes" && test "$usb_get_busses" = "yes" && test "$usb_interrupt_read" = "yes"); then
174                usb_found=yes
175        else
176                usb_found=no
177        fi
178])
179
180AC_DEFUN([AC_PATH_GLIB], [
181        PKG_CHECK_MODULES(GLIB, glib-2.0 gobject-2.0 gthread-2.0, glib_found=yes, AC_MSG_RESULT(no))
182        AC_SUBST(GLIB_CFLAGS)
183        AC_SUBST(GLIB_LIBS)
184        GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
185        AC_SUBST(GLIB_GENMARSHAL)
186])
187
188AC_DEFUN([AC_VISIBILITY], [
189        case $host in
190        *-*-mingw32*)
191                AC_SUBST(CFLAG_VISIBILITY)
192                if (test "${enable_shared}" = "yes"); then
193                   OPENOBEX_CFLAGS="-DOPENOBEX_EXPORTS"
194                fi
195                AC_SUBST(OPENOBEX_CFLAGS)
196                ;;
197        *)
198                gl_VISIBILITY
199                ;;
200        esac
201])
202
203AC_DEFUN([AC_ARG_OPENOBEX], [
204        fortify_enable=yes
205        irda_enable=yes
206        bluetooth_enable=yes
207        usb_enable=yes
208        glib_enable=no
209        apps_enable=no
210        debug_enable=no
211        syslog_enable=no
212        dump_enable=no
213
214        AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
215                fortify_enable=${enableval}
216        ])
217
218        AC_ARG_ENABLE(irda, AC_HELP_STRING([--disable-irda], [disable IrDA support]), [
219                irda_enable=${enableval}
220        ])
221
222        AC_ARG_ENABLE(bluetooth, AC_HELP_STRING([--disable-bluetooth], [disable Bluetooth support]), [
223                bluetooth_enable=${enableval}
224        ])
225
226        AC_ARG_ENABLE(usb, AC_HELP_STRING([--disable-usb], [disable USB support]), [
227                usb_enable=${enableval}
228        ])
229
230        AC_ARG_ENABLE(glib, AC_HELP_STRING([--enable-glib], [enable GLib bindings]), [
231                glib_enable=${enableval}
232        ])
233
234        AC_ARG_ENABLE(apps, AC_HELP_STRING([--enable-apps], [enable test applications]), [
235                apps_enable=${enableval}
236        ])
237
238        AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
239                debug_enable=${enableval}
240        ])
241
242        AC_ARG_ENABLE(syslog, AC_HELP_STRING([--enable-syslog], [enable debugging to the system logger]), [
243                syslog_enable=${enableval}
244        ])
245
246        AC_ARG_ENABLE(dump, AC_HELP_STRING([--enable-dump], [enable protocol dumping for debugging]), [
247                dump_enable=${enableval}
248        ])
249
250        if (test "${fortify_enable}" = "yes"); then
251                CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
252        fi
253
254        REQUIRES=""
255
256        if (test "${irda_enable}" = "yes" && test "${irda_found}" = "yes"); then
257                AC_DEFINE(HAVE_IRDA, 1, [Define if system supports IrDA and it's enabled])
258            if (test "${irda_windows}" = "yes"); then
259                  AC_DEFINE(HAVE_IRDA_WINDOWS, 1, [Define if system supports IrDA stack for Windows])
260            elif (test "${irda_linux}" = "yes"); then
261                      AC_DEFINE(HAVE_IRDA_LINUX, 1, [Define if system supports IrDA stack for Linux])
262            fi
263        fi
264
265      if (test "${bluetooth_enable}" = "yes" && test "${winbt_found}" = "yes"); then
266            AC_DEFINE(HAVE_BLUETOOTH, 1, [Define if system supports Bluetooth and it's enabled])
267            AC_DEFINE(HAVE_BLUETOOTH_WINDOWS, 1, [Define if system supports Bluetooth stack for Windows])
268      fi
269
270        if (test "${bluetooth_enable}" = "yes" && test "${netbsdbt_found}" = "yes"); then
271                AC_DEFINE(HAVE_BLUETOOTH, 1, [Define if system supports Bluetooth and it's enabled])
272                AC_DEFINE(HAVE_BLUETOOTH_NETBSD, 1, [Define if system supports Bluetooth stack for NetBSD])
273        fi
274
275        if (test "${bluetooth_enable}" = "yes" && test "${freebsdbt_found}" = "yes"); then
276                AC_DEFINE(HAVE_BLUETOOTH, 1, [Define if system supports Bluetooth and it's enabled])
277                AC_DEFINE(HAVE_BLUETOOTH_FREEBSD, 1, [Define if system supports Bluetooth stack for FreeBSD])
278        fi
279
280        if (test "${bluetooth_enable}" = "yes" && test "${bluez_found}" = "yes"); then
281                AC_DEFINE(HAVE_BLUETOOTH, 1, [Define if system supports Bluetooth and it's enabled])
282                AC_DEFINE(HAVE_BLUETOOTH_LINUX, 1, [Define if system supports Bluetooth stack for Linux])
283        fi
284
285        if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then
286                AC_DEFINE(HAVE_USB, 1, [Define if system supports USB and it's enabled])
287        fi
288
289        AM_CONDITIONAL(GLIB, test "${glib_enable}" = "yes" && test "${glib_found}" = "yes")
290        AM_CONDITIONAL(APPS, test "${apps_enable}" = "yes")
291
292        if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
293                CFLAGS="$CFLAGS -g"
294                AC_DEFINE_UNQUOTED(OBEX_DEBUG, 1, [Enable debuggging])
295        fi
296
297        if (test "${syslog_enable}" = "yes"); then
298                AC_DEFINE_UNQUOTED(OBEX_SYSLOG, 1, [System logger debugging])
299        fi
300
301        if (test "${dump_enable}" = "yes"); then
302                AC_DEFINE_UNQUOTED(OBEX_DUMP, 1, [Protocol dumping])
303        fi
304
305        AC_SUBST(REQUIRES)
306])
Note: See TracBrowser for help on using the browser.