@@ -172,6 +172,9 @@ m4_define([DUMMY_ADAPTER],
172172m4_define ( [ OPTIONAL_LIBRARIES] ,
173173 [ [ [ capstone] , [ Use Capstone disassembly framework] , [ ] ] ] )
174174
175+ m4_define ( [ COVERAGE] ,
176+ [ [ [ gcov] , [ Collect coverage using gcov] , [ ] ] ] )
177+
175178AC_ARG_ENABLE ( [ doxygen-html] ,
176179 AS_HELP_STRING ( [ --disable-doxygen-html] ,
177180 [ Disable building Doxygen manual as HTML.] ) ,
@@ -200,6 +203,19 @@ AC_ARG_ENABLE([werror],
200203 AS_HELP_STRING ( [ --disable-werror] , [ Do not treat warnings as errors] ) ,
201204 [ gcc_werror=$enableval] , [ gcc_werror=$gcc_warnings] )
202205
206+ AC_ARG_ENABLE ( [ gcov] ,
207+ AS_HELP_STRING ( [ --enable-gcov] , [ Enable runtime coverage collection via gcov] ) ,
208+ [ enable_gcov=$enableval] , [ enable_gcov=no] )
209+
210+ AS_IF ( [ test "x$enable_gcov" = "xyes"] , [
211+ AC_DEFINE ( [ USE_GCOV] , [ 1] , [ 1 to enable coverage collection using gcov.] )
212+ dnl When collecting coverage, disable optimizations.
213+ dnl This overrides the "-O2" that autoconf uses by default:
214+ CFLAGS+=" -O0"
215+ ] , [
216+ AC_DEFINE ( [ USE_GCOV] , [ 0] , [ 0 to leave coverage collection disabled.] )
217+ ] )
218+
203219# set default verbose options, overridden by following options
204220debug_usb_io=no
205221debug_usb_comms=no
@@ -257,9 +273,13 @@ AC_ARG_ENABLE([dmem],
257273m4_define ( [ AC_ARG_ADAPTERS] , [
258274 m4_foreach ( [ adapter] , [ $1 ] ,
259275 [ AC_ARG_ENABLE ( ADAPTER_OPT ( [ adapter] ) ,
260- AS_HELP_STRING ( [ --enable-ADAPTER_OPT([ adapter] )] ,
276+ AS_HELP_STRING ( [ --enable-ADAPTER_OPT([ adapter] )[ [ [ =yes/no/auto ] ] ] ] ,
261277 [ Enable building support for the ] ADAPTER_DESC ( [ adapter] ) [ (default is $2 )] ) ,
262- [ ] , [ ADAPTER_VAR([ adapter] )=$2 ] )
278+ [ case "${enableval}" in
279+ yes|no|auto) ;;
280+ *) AC_MSG_ERROR ( [ Option --enable-ADAPTER_OPT([ adapter] ) has invalid value "${enableval}".] ) ;;
281+ esac] ,
282+ [ ADAPTER_VAR([ adapter] )=$2 ] )
263283 ] )
264284] )
265285
@@ -268,7 +288,7 @@ AC_ARG_ADAPTERS([
268288 HIDAPI_ADAPTERS,
269289 HIDAPI_USB1_ADAPTERS,
270290 LIBFTDI_ADAPTERS,
271- LIBFTDI_USB1_ADAPTERS
291+ LIBFTDI_USB1_ADAPTERS,
272292 LIBGPIOD_ADAPTERS,
273293 SERIAL_PORT_ADAPTERS,
274294 PCIE_ADAPTERS,
@@ -357,10 +377,6 @@ AS_CASE([$host_os],
357377 AC_MSG_ERROR ( [ sysfsgpio is only available on linux] )
358378 ] )
359379
360- AS_IF ( [ test "x$enable_linuxgpiod" = "xyes"] , [
361- AC_MSG_ERROR ( [ linuxgpiod is only available on linux] )
362- ] )
363-
364380 AS_CASE ( [ $host_os] , [ freebsd*] , [ ] ,
365381 [
366382 AS_IF ( [ test "x$build_rshim" = "xyes"] , [
@@ -399,6 +415,8 @@ AS_CASE(["${host_cpu}"],
399415 parport_use_ppdev=yes
400416] )
401417
418+ can_build_buspirate=yes
419+
402420AS_CASE ( [ $host] ,
403421 [ *-cygwin*] , [
404422 is_win32=yes
@@ -430,12 +448,12 @@ AS_CASE([$host],
430448 ] )
431449 parport_use_giveio=yes
432450
433- AS_IF ( [ test "x$enable_buspirate " = "xyes"] , [
434- AC_MSG_ERROR ( [ buspirate currently not supported by MinGW32 hosts] )
451+ AS_IF ( [ test "x$ADAPTER_VAR( [ buspirate ] ) " = "xyes"] , [
452+ AC_MSG_ERROR ( [ The Bus Pirate adapter is currently not supported by MinGW32 hosts. ] )
435453 ] )
436454
437455 # In case enable_buspirate=auto, make sure it will not be built.
438- enable_buspirate =no
456+ can_build_buspirate =no
439457
440458 AC_SUBST ( [ HOST_CPPFLAGS] , [ "-D__USE_MINGW_ANSI_STDIO -DFD_SETSIZE=128"] )
441459 ] ,
@@ -579,12 +597,6 @@ AS_IF([test "x$build_gw16012" = "xyes"], [
579597 AC_DEFINE ( [ BUILD_GW16012] , [ 0] , [ 0 if you don't want the Gateworks GW16012 driver.] )
580598] )
581599
582- AS_IF ( [ test "x$enable_buspirate" != "xno"] , [
583- AC_DEFINE ( [ BUILD_BUSPIRATE] , [ 1] , [ 1 if you want the Buspirate JTAG driver.] )
584- ] , [
585- AC_DEFINE ( [ BUILD_BUSPIRATE] , [ 0] , [ 0 if you don't want the Buspirate JTAG driver.] )
586- ] )
587-
588600AS_IF ( [ test "x$use_internal_jimtcl" = "xyes"] , [
589601 AS_IF ( [ test -f "$srcdir/jimtcl/configure"] , [
590602 AS_IF ( [ test "x$use_internal_jimtcl_maintainer" = "xyes"] , [
@@ -697,7 +709,7 @@ m4_define([PROCESS_ADAPTERS], [
697709 ] )
698710 ] , [
699711 AS_IF ( [ test "x$ADAPTER_VAR([ adapter] )" = "xyes"] , [
700- AC_MSG_ERROR ( [ $3 is required for [ adapter] ADAPTER_DESC([ adapter] ).] )
712+ AC_MSG_ERROR ( [ $3 is required for [ adapter] " ADAPTER_DESC([ adapter] )" .] )
701713 ] )
702714 ADAPTER_VAR([ adapter] )=no
703715 AC_DEFINE ( [ BUILD_] ADAPTER_SYM ( [ adapter] ) , [ 0] , [ 0 if you do not want the ] ADAPTER_DESC ( [ adapter] ) . )
@@ -711,9 +723,11 @@ PROCESS_ADAPTERS([HIDAPI_ADAPTERS], ["x$use_hidapi" = "xyes"], [hidapi])
711723PROCESS_ADAPTERS([ HIDAPI_USB1_ADAPTERS] , [ "x$use_hidapi" = "xyes" -a "x$use_libusb1" = "xyes"] , [ hidapi and libusb-1.x] )
712724PROCESS_ADAPTERS([ LIBFTDI_ADAPTERS] , [ "x$use_libftdi" = "xyes"] , [ libftdi] )
713725PROCESS_ADAPTERS([ LIBFTDI_USB1_ADAPTERS] , [ "x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"] , [ libftdi and libusb-1.x] )
714- PROCESS_ADAPTERS([ LIBGPIOD_ADAPTERS] , [ "x$use_libgpiod" = "xyes"] , [ libgpiod] )
726+ PROCESS_ADAPTERS([ LIBGPIOD_ADAPTERS] , [ "x$use_libgpiod" = "xyes"] , [ Linux libgpiod] )
715727PROCESS_ADAPTERS([ LIBJAYLINK_ADAPTERS] , [ "x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"] , [ libjaylink-0.2] )
716728PROCESS_ADAPTERS([ PCIE_ADAPTERS] , [ "x$is_linux" = "xyes"] , [ Linux build] )
729+ PROCESS_ADAPTERS([ SERIAL_PORT_ADAPTERS] , [ "x$can_build_buspirate" = "xyes"] ,
730+ [ internal error: validation should happen beforehand] )
717731PROCESS_ADAPTERS([ DUMMY_ADAPTER] , [ true] , [ unused] )
718732
719733AS_IF ( [ test "x$enable_linuxgpiod" != "xno"] , [
@@ -768,7 +782,6 @@ AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x
768782AM_CONDITIONAL([ AMTJTAGACCEL] , [ test "x$build_amtjtagaccel" = "xyes"] )
769783AM_CONDITIONAL([ GW16012] , [ test "x$build_gw16012" = "xyes"] )
770784AM_CONDITIONAL([ REMOTE_BITBANG] , [ test "x$build_remote_bitbang" = "xyes"] )
771- AM_CONDITIONAL([ BUSPIRATE] , [ test "x$enable_buspirate" != "xno"] )
772785AM_CONDITIONAL([ SYSFSGPIO] , [ test "x$build_sysfsgpio" = "xyes"] )
773786AM_CONDITIONAL([ USE_LIBUSB1] , [ test "x$use_libusb1" = "xyes"] )
774787AM_CONDITIONAL([ IS_CYGWIN] , [ test "x$is_cygwin" = "xyes"] )
@@ -788,6 +801,8 @@ AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
788801AM_CONDITIONAL([ HAVE_JIMTCL_PKG_CONFIG] , [ test "x$have_jimtcl_pkg_config" = "xyes"] )
789802AM_CONDITIONAL([ INTERNAL_LIBJAYLINK] , [ test "x$use_internal_libjaylink" = "xyes"] )
790803
804+ AM_CONDITIONAL([ USE_GCOV] , [ test "x$enable_gcov" = "xyes"] )
805+
791806# Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
792807AC_MSG_CHECKING ( [ for environ in unistd.h and stdlib.h] )
793808AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
@@ -863,7 +878,8 @@ m4_foreach([adapter], [USB1_ADAPTERS,
863878 LIBGPIOD_ADAPTERS,
864879 LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
865880 DUMMY_ADAPTER,
866- OPTIONAL_LIBRARIES] ,
881+ OPTIONAL_LIBRARIES,
882+ COVERAGE] ,
867883 [ s=m4_format ( [ "%-40s"] , ADAPTER_DESC ( [ adapter] ))
868884 AS_CASE ( [ $ADAPTER_VAR([ adapter] )] ,
869885 [ auto] , [
@@ -874,6 +890,11 @@ m4_foreach([adapter], [USB1_ADAPTERS,
874890 ] ,
875891 [ no] , [
876892 echo "$s"no
893+ ] ,
894+ [
895+ AC_MSG_ERROR ( m4_normalize ( [
896+ Error in [ adapter] "ADAPTER_ARG([ adapter] )": Variable "ADAPTER_VAR([ adapter] )"
897+ has invalid value "$ADAPTER_VAR([ adapter] )".] ) )
877898 ] )
878899] )
879900echo
0 commit comments