Home | History | Annotate | Download | only in bluez
      1 AC_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 
     13 AC_DEFUN([COMPILER_FLAGS], [
     14 	if (test "${CFLAGS}" = ""); then
     15 		CFLAGS="-Wall -O2"
     16 	fi
     17 	if (test "$USE_MAINTAINER_MODE" = "yes"); then
     18 		CFLAGS+=" -Werror -Wextra"
     19 		CFLAGS+=" -Wno-unused-parameter"
     20 		CFLAGS+=" -Wno-missing-field-initializers"
     21 		CFLAGS+=" -Wdeclaration-after-statement"
     22 		CFLAGS+=" -Wmissing-declarations"
     23 		CFLAGS+=" -Wredundant-decls"
     24 		CFLAGS+=" -Wcast-align"
     25 	fi
     26 ])
     27 
     28 AC_DEFUN([AC_FUNC_PPOLL], [
     29 	AC_CHECK_FUNC(ppoll, dummy=yes, AC_DEFINE(NEED_PPOLL, 1,
     30 			[Define to 1 if you need the ppoll() function.]))
     31 ])
     32 
     33 AC_DEFUN([AC_INIT_BLUEZ], [
     34 	AC_PREFIX_DEFAULT(/usr/local)
     35 
     36 	if (test "${prefix}" = "NONE"); then
     37 		dnl no prefix and no sysconfdir, so default to /etc
     38 		if (test "$sysconfdir" = '${prefix}/etc'); then
     39 			AC_SUBST([sysconfdir], ['/etc'])
     40 		fi
     41 
     42 		dnl no prefix and no localstatedir, so default to /var
     43 		if (test "$localstatedir" = '${prefix}/var'); then
     44 			AC_SUBST([localstatedir], ['/var'])
     45 		fi
     46 
     47 		dnl no prefix and no libexecdir, so default to /lib
     48 		if (test "$libexecdir" = '${exec_prefix}/libexec'); then
     49 			AC_SUBST([libexecdir], ['/lib'])
     50 		fi
     51 
     52 		dnl no prefix and no mandir, so use ${prefix}/share/man as default
     53 		if (test "$mandir" = '${prefix}/man'); then
     54 			AC_SUBST([mandir], ['${prefix}/share/man'])
     55 		fi
     56 
     57 		prefix="${ac_default_prefix}"
     58 	fi
     59 
     60 	if (test "${libdir}" = '${exec_prefix}/lib'); then
     61 		libdir="${prefix}/lib"
     62 	fi
     63 
     64 	plugindir="${libdir}/bluetooth/plugins"
     65 
     66 	if (test "$sysconfdir" = '${prefix}/etc'); then
     67 		configdir="${prefix}/etc/bluetooth"
     68 	else
     69 		configdir="${sysconfdir}/bluetooth"
     70 	fi
     71 
     72 	if (test "$localstatedir" = '${prefix}/var'); then
     73 		storagedir="${prefix}/var/lib/bluetooth"
     74 	else
     75 		storagedir="${localstatedir}/lib/bluetooth"
     76 	fi
     77 
     78 	AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
     79 				[Directory for the configuration files])
     80 	AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
     81 				[Directory for the storage files])
     82 
     83 	AC_SUBST(CONFIGDIR, "${configdir}")
     84 	AC_SUBST(STORAGEDIR, "${storagedir}")
     85 
     86 	UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
     87 	if (test -z "${UDEV_DATADIR}"); then
     88 		UDEV_DATADIR="${sysconfdir}/udev/rules.d"
     89 	else
     90 		UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
     91 	fi
     92 	AC_SUBST(UDEV_DATADIR)
     93 ])
     94 
     95 AC_DEFUN([AC_PATH_DBUS], [
     96 	PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
     97 				AC_MSG_ERROR(D-Bus library is required))
     98 	AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
     99 		AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
    100 			[Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
    101 	AC_CHECK_LIB(dbus-1, dbus_connection_can_send_type, dummy=yes,
    102 		AC_DEFINE(NEED_DBUS_CONNECTION_CAN_SEND_TYPE, 1,
    103 			[Define to 1 if you need the dbus_connection_can_send_type() function.]
    104 ))
    105 	AC_SUBST(DBUS_CFLAGS)
    106 	AC_SUBST(DBUS_LIBS)
    107 ])
    108 
    109 AC_DEFUN([AC_PATH_GLIB], [
    110 	PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14, dummy=yes,
    111 				AC_MSG_ERROR(GLib library version 2.14 or later is required))
    112 	AC_SUBST(GLIB_CFLAGS)
    113 	AC_SUBST(GLIB_LIBS)
    114 ])
    115 
    116 AC_DEFUN([AC_PATH_GSTREAMER], [
    117 	PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 gstreamer-plugins-base-0.10, gstreamer_found=yes, gstreamer_found=no)
    118 	AC_SUBST(GSTREAMER_CFLAGS)
    119 	AC_SUBST(GSTREAMER_LIBS)
    120 	GSTREAMER_PLUGINSDIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-0.10`
    121 	AC_SUBST(GSTREAMER_PLUGINSDIR)
    122 ])
    123 
    124 AC_DEFUN([AC_PATH_PULSE], [
    125 	PKG_CHECK_MODULES(PULSE, libpulse, pulse_found=yes, pulse_found=no)
    126 	AC_SUBST(PULSE_CFLAGS)
    127 	AC_SUBST(PULSE_LIBS)
    128 ])
    129 
    130 AC_DEFUN([AC_PATH_ALSA], [
    131 	PKG_CHECK_MODULES(ALSA, alsa, alsa_found=yes, alsa_found=no)
    132 	AC_CHECK_LIB(rt, clock_gettime, ALSA_LIBS="$ALSA_LIBS -lrt", alsa_found=no)
    133 	AC_SUBST(ALSA_CFLAGS)
    134 	AC_SUBST(ALSA_LIBS)
    135 ])
    136 
    137 AC_DEFUN([AC_PATH_USB], [
    138 	PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
    139 	AC_SUBST(USB_CFLAGS)
    140 	AC_SUBST(USB_LIBS)
    141 	AC_CHECK_LIB(usb, usb_get_busses, dummy=yes,
    142 		AC_DEFINE(NEED_USB_GET_BUSSES, 1,
    143 			[Define to 1 if you need the usb_get_busses() function.]))
    144 	AC_CHECK_LIB(usb, usb_interrupt_read, dummy=yes,
    145 		AC_DEFINE(NEED_USB_INTERRUPT_READ, 1,
    146 			[Define to 1 if you need the usb_interrupt_read() function.]))
    147 ])
    148 
    149 AC_DEFUN([AC_PATH_SNDFILE], [
    150 	PKG_CHECK_MODULES(SNDFILE, sndfile, sndfile_found=yes, sndfile_found=no)
    151 	AC_SUBST(SNDFILE_CFLAGS)
    152 	AC_SUBST(SNDFILE_LIBS)
    153 ])
    154 
    155 AC_DEFUN([AC_ARG_BLUEZ], [
    156 	debug_enable=no
    157 	optimization_enable=yes
    158 	fortify_enable=yes
    159 	pie_enable=yes
    160 	sndfile_enable=${sndfile_found}
    161 	hal_enable=${hal_found}
    162 	usb_enable=${usb_found}
    163 	alsa_enable=${alsa_found}
    164 	gstreamer_enable=${gstreamer_found}
    165 	audio_enable=yes
    166 	input_enable=yes
    167 	serial_enable=yes
    168 	network_enable=yes
    169 	service_enable=yes
    170 	pnat_enable=no
    171 	tracer_enable=no
    172 	tools_enable=yes
    173 	hidd_enable=no
    174 	pand_enable=no
    175 	dund_enable=no
    176 	cups_enable=no
    177 	test_enable=no
    178 	bccmd_enable=no
    179 	pcmcia_enable=no
    180 	hid2hci_enable=no
    181 	dfutool_enable=no
    182 	udevrules_enable=yes
    183 	configfiles_enable=yes
    184 	telephony_driver=dummy
    185 	maemo6_enable=no
    186 
    187 	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
    188 		optimization_enable=${enableval}
    189 	])
    190 
    191 	AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
    192 		fortify_enable=${enableval}
    193 	])
    194 
    195 	AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
    196 		pie_enable=${enableval}
    197 	])
    198 
    199 	AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
    200 		network_enable=${enableval}
    201 	])
    202 
    203 	AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [disable serial plugin]), [
    204 		serial_enable=${enableval}
    205 	])
    206 
    207 	AC_ARG_ENABLE(input, AC_HELP_STRING([--disable-input], [disable input plugin]), [
    208 		input_enable=${enableval}
    209 	])
    210 
    211 	AC_ARG_ENABLE(audio, AC_HELP_STRING([--disable-audio], [disable audio plugin]), [
    212 		audio_enable=${enableval}
    213 	])
    214 
    215 	AC_ARG_ENABLE(service, AC_HELP_STRING([--disable-service], [disable service plugin]), [
    216 		service_enable=${enableval}
    217 	])
    218 
    219 	AC_ARG_ENABLE(pnat, AC_HELP_STRING([--enable-pnat], [enable pnat plugin]), [
    220 		pnat_enable=${enableval}
    221 	])
    222 
    223 	AC_ARG_ENABLE(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
    224 		gstreamer_enable=${enableval}
    225 	])
    226 
    227 	AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
    228 		alsa_enable=${enableval}
    229 	])
    230 
    231 	AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
    232 		usb_enable=${enableval}
    233 	])
    234 
    235 	AC_ARG_ENABLE(tracer, AC_HELP_STRING([--enable-tracer], [install Tracing daemon]), [
    236 		tracer_enable=${enableval}
    237 	])
    238 
    239 	AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
    240 		tools_enable=${enableval}
    241 	])
    242 
    243 	AC_ARG_ENABLE(bccmd, AC_HELP_STRING([--enable-bccmd], [install BCCMD interface utility]), [
    244 		bccmd_enable=${enableval}
    245 	])
    246 
    247 	AC_ARG_ENABLE(pcmcia, AC_HELP_STRING([--enable-pcmcia], [install PCMCIA serial script]), [
    248 		pcmcia_enable=${enableval}
    249 	])
    250 
    251 	AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
    252 		hid2hci_enable=${enableval}
    253 	])
    254 
    255 	AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
    256 		dfutool_enable=${enableval}
    257 	])
    258 
    259 	AC_ARG_ENABLE(hidd, AC_HELP_STRING([--enable-hidd], [install HID daemon]), [
    260 		hidd_enable=${enableval}
    261 	])
    262 
    263 	AC_ARG_ENABLE(pand, AC_HELP_STRING([--enable-pand], [install PAN daemon]), [
    264 		pand_enable=${enableval}
    265 	])
    266 
    267 	AC_ARG_ENABLE(dund, AC_HELP_STRING([--enable-dund], [install DUN daemon]), [
    268 		dund_enable=${enableval}
    269 	])
    270 
    271 	AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
    272 		cups_enable=${enableval}
    273 	])
    274 
    275 	AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
    276 		test_enable=${enableval}
    277 	])
    278 
    279 	AC_ARG_ENABLE(udevrules, AC_HELP_STRING([--enable-udevrules], [install Bluetooth udev rules]), [
    280 		udevrules_enable=${enableval}
    281 	])
    282 
    283 	AC_ARG_ENABLE(configfiles, AC_HELP_STRING([--enable-configfiles], [install Bluetooth configuration files]), [
    284 		configfiles_enable=${enableval}
    285 	])
    286 
    287 	AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
    288 		debug_enable=${enableval}
    289 	])
    290 
    291 	AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [
    292 		telephony_driver=${withval}
    293 	])
    294 
    295 	AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c])
    296 
    297 	AC_ARG_ENABLE(maemo6, AC_HELP_STRING([--enable-maemo6], [compile with maemo6 plugin]), [
    298 		maemo6_enable=${enableval}
    299 	])
    300 
    301 	if (test "${fortify_enable}" = "yes"); then
    302 		CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
    303 	fi
    304 
    305 	if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then
    306 		CFLAGS="$CFLAGS -fPIC"
    307 		LDFLAGS="$LDFLAGS -pie"
    308 	fi
    309 
    310 	if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
    311 		CFLAGS="$CFLAGS -g"
    312 	fi
    313 
    314 	if (test "${optimization_enable}" = "no"); then
    315 		CFLAGS="$CFLAGS -O0"
    316 	fi
    317 
    318 	if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then
    319 		AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
    320 	fi
    321 
    322 	AM_CONDITIONAL(SNDFILE, test "${sndfile_enable}" = "yes" && test "${sndfile_found}" = "yes")
    323 	AM_CONDITIONAL(USB, test "${usb_enable}" = "yes" && test "${usb_found}" = "yes")
    324 	AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes" ||
    325 									test "${test_enable}" = "yes")
    326 	AM_CONDITIONAL(ALSA, test "${alsa_enable}" = "yes" && test "${alsa_found}" = "yes")
    327 	AM_CONDITIONAL(GSTREAMER, test "${gstreamer_enable}" = "yes" && test "${gstreamer_found}" = "yes")
    328 	AM_CONDITIONAL(AUDIOPLUGIN, test "${audio_enable}" = "yes")
    329 	AM_CONDITIONAL(INPUTPLUGIN, test "${input_enable}" = "yes")
    330 	AM_CONDITIONAL(SERIALPLUGIN, test "${serial_enable}" = "yes")
    331 	AM_CONDITIONAL(NETWORKPLUGIN, test "${network_enable}" = "yes")
    332 	AM_CONDITIONAL(SERVICEPLUGIN, test "${service_enable}" = "yes")
    333 	AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes")
    334 	AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes")
    335 	AM_CONDITIONAL(TRACER, test "${tracer_enable}" = "yes")
    336 	AM_CONDITIONAL(HIDD, test "${hidd_enable}" = "yes")
    337 	AM_CONDITIONAL(PAND, test "${pand_enable}" = "yes")
    338 	AM_CONDITIONAL(DUND, test "${dund_enable}" = "yes")
    339 	AM_CONDITIONAL(CUPS, test "${cups_enable}" = "yes")
    340 	AM_CONDITIONAL(TEST, test "${test_enable}" = "yes")
    341 	AM_CONDITIONAL(TOOLS, test "${tools_enable}" = "yes")
    342 	AM_CONDITIONAL(BCCMD, test "${bccmd_enable}" = "yes")
    343 	AM_CONDITIONAL(PCMCIA, test "${pcmcia_enable}" = "yes")
    344 	AM_CONDITIONAL(HID2HCI, test "${hid2hci_enable}" = "yes" && test "${usb_found}" = "yes")
    345 	AM_CONDITIONAL(DFUTOOL, test "${dfutool_enable}" = "yes" && test "${usb_found}" = "yes")
    346 	AM_CONDITIONAL(UDEVRULES, test "${udevrules_enable}" = "yes")
    347 	AM_CONDITIONAL(CONFIGFILES, test "${configfiles_enable}" = "yes")
    348 	AM_CONDITIONAL(MAEMO6PLUGIN, test "${maemo6_enable}" = "yes")
    349 ])
    350