diff --git a/Makefile.am b/Makefile.am index c2a2d39..27bf656 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = hcore senseApis +SUBDIRS = hcore commonLibs ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS+= -I"$(top_srcdir)/hcore/include" diff --git a/commonLibs/Makefile.am b/commonLibs/Makefile.am new file mode 100644 index 0000000..8ab941b --- /dev/null +++ b/commonLibs/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = @COMMONLIBS_ENABLED@ diff --git a/senseApis/xcbXorg/Makefile.am b/commonLibs/xcbXorg/Makefile.am similarity index 100% rename from senseApis/xcbXorg/Makefile.am rename to commonLibs/xcbXorg/Makefile.am diff --git a/senseApis/xcbXorg/xcbXorg.cpp b/commonLibs/xcbXorg/xcbXorg.cpp similarity index 100% rename from senseApis/xcbXorg/xcbXorg.cpp rename to commonLibs/xcbXorg/xcbXorg.cpp diff --git a/senseApis/xcbXorg/xcbXorg.h b/commonLibs/xcbXorg/xcbXorg.h similarity index 100% rename from senseApis/xcbXorg/xcbXorg.h rename to commonLibs/xcbXorg/xcbXorg.h diff --git a/configure.ac b/configure.ac index 5a3f167..f68d0eb 100644 --- a/configure.ac +++ b/configure.ac @@ -64,16 +64,22 @@ AC_SUBST([AM_CPPFLAGS]) AC_SUBST([YACC]) AC_SUBST([LEX]) -m4_include([m4/sense_api_opts.m4]) +COMMONLIBS_ENABLED= +SENSEAPIS_ENABLED= +WILZORAPIS_ENABLED= +m4_include([m4/commonlibs-opts.m4]) +m4_include([m4/sense-wilzor-api-opts.m4]) +AC_SUBST([COMMONLIBS_ENABLED]) AC_SUBST([SENSEAPIS_ENABLED]) +AC_SUBST([WILZORAPIS_ENABLED]) AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_FILES([ Makefile hcore/Makefile hcore/deviceManager/Makefile hcore/senseApis/Makefile - senseApis/Makefile - senseApis/xcbXorg/Makefile + commonLibs/Makefile + commonLibs/xcbXorg/Makefile ]) AC_CONFIG_COMMANDS_POST([ diff --git a/m4/commonlibs-opts.m4 b/m4/commonlibs-opts.m4 new file mode 100644 index 0000000..802dcb6 --- /dev/null +++ b/m4/commonlibs-opts.m4 @@ -0,0 +1,70 @@ +dnl _HK_LIB_ENABLE_IMPL(name, description, config_define, enable_var, +dnl enabled_list, [commands], [unimplemented]) +dnl name - Name of the library (e.g., xcbXorg) +dnl description - Human readable description +dnl config_define - Configuration define name (e.g., CONFIG_XCBXORG_ENABLED) +dnl enable_var - Shell variable to track enabled status +dnl enabled_list - List variable to append name to (e.g., SENSEAPIS_ENABLED) +dnl commands - Optional: Shell commands to execute when enabling +dnl unimplemented - Optional: If "unimplemented", error out +AC_DEFUN([_HK_LIB_ENABLE_IMPL], [ + AS_IF([test "x[]m4_normalize($7)" = "xunimplemented"], [ + AC_MSG_ERROR([$1 is not yet implemented]) + ]) + AS_IF([test "x${$4_done}" != "xyes"], [ + $4_done=yes + AC_DEFINE([$3], [1], [Enable $2]) + $5="${$5} $1" + $6 + ]) +]) + +dnl _HK_LIB_ARG_ENABLE(dev_api_type, name, description, config_define, +dnl enabled_list, [commands], [unimplemented]) +dnl lib/api_type - Type of API ("senseapi", "wilzorapi", or "lib") +dnl name - Name of the library (e.g., xcbXorg) +dnl description - Human readable description +dnl config_define - Configuration define name (e.g., CONFIG_XCBXORG_ENABLED) +dnl enabled_list - List variable to append name to +dnl commands - Optional: Shell commands to execute when enabling +dnl unimplemented - Optional: If "unimplemented", error out +AC_DEFUN([_HK_LIB_ARG_ENABLE], [ + AC_ARG_ENABLE([$1-$2], + [AS_HELP_STRING([--enable-$1-$2], [Enable $3])], + [AS_IF([test "x$enable_$1_$2" != "xno"], [ + _HK_LIB_ENABLE_IMPL([$2], [$3], [$4], [enable_$1_$2], [$5], [$6], [$7]) + ])], + [enable_$1_$2=no] + ) +]) + +# Macro for enabling the XCB/Xorg Connection Mgr lib. Invoked by several other +# libs. +AC_DEFUN([_HK_LIB_XCBXORG_ENABLE], [ + _HK_LIB_ENABLE_IMPL([xcbXorg], [XCB/Xorg Connection Manager backend], + [CONFIG_LIB_XCBXORG_ENABLED], [enable_lib_xcbXorg], [COMMONLIBS_ENABLED], [ + PKG_CHECK_MODULES([XCB], [xcb], [], [ + AC_MSG_ERROR(m4_normalize([XCB library not found. Sense API + XCB/Xorg requires the XCB dev headers and shlib.])) + ]) + AC_SUBST([XCB_CFLAGS]) + AC_SUBST([XCB_LIBS]) + ] + ) +]) + +AC_DEFUN([_HK_LIB_ALSA_ENABLE], [ + _HK_LIB_ENABLE_IMPL([alsa], [ALSA Connection Manager backend], + [CONFIG_LIB_ALSA_ENABLED], [enable_lib_alsa], [COMMONLIBS_ENABLED], [ + PKG_CHECK_MODULES([ALSA], [alsa], [], [ + AC_MSG_ERROR(m4_normalize([ALSA library not found. Sense API + ALSA requires the ALSA dev headers and shlib.])) + ]) + AC_SUBST([ALSA_CFLAGS]) + AC_SUBST([ALSA_LIBS]) + ] + ) +]) + +# Temporary until we implement the xcbWindow SenseAPI. +_HK_LIB_XCBXORG_ENABLE \ No newline at end of file diff --git a/m4/sense-wilzor-api-opts.m4 b/m4/sense-wilzor-api-opts.m4 new file mode 100644 index 0000000..57c3e66 --- /dev/null +++ b/m4/sense-wilzor-api-opts.m4 @@ -0,0 +1,65 @@ + +dnl Wrapper macros for specific API types +AC_DEFUN([HK_SENSEAPI_ARG_ENABLE], [ + _HK_LIB_ARG_ENABLE([senseapi], [$1], [$2], [$3], + [SENSEAPIS_ENABLED], [$4], [$5]) +]) + +AC_DEFUN([HK_WILZORAPI_ARG_ENABLE], [ + _HK_LIB_ARG_ENABLE([wilzorapi], [$1], [$2], [$3], + [WILZORLIBS_ENABLED], [$4], [$5]) +]) + +HK_SENSEAPI_ARG_ENABLE([xcbWindow], + m4_normalize([XCB/Xorg Window Attaching SenseAPI backend: enables Harikoff + to see attached window contents. Useful for web learning]), + [CONFIG_XCBWINDOW_ENABLED], + [_HK_LIB_XCBXORG_ENABLE], + [unimplemented] +) + +HK_SENSEAPI_ARG_ENABLE([v4l], + m4_normalize([Video4Linux camera SenseAPI backend: enables Harikoff to + see via a V4L camera]), + [CONFIG_V4L_ENABLED], [ + PKG_CHECK_MODULES([V4L], [libv4l], [], [ + AC_MSG_ERROR(m4_normalize([libv4l not found. Sense API V4L + requires the libv4l dev headers and shlib.])) + ]) + AC_SUBST([V4L_CFLAGS]) + AC_SUBST([V4L_LIBS]) + ], + [unimplemented] +) + +HK_SENSEAPI_ARG_ENABLE([alsaMic], + m4_normalize([ALSA Microphone SenseAPI backend: enables Harikoff to + hear via an ALSA microphone]), + [CONFIG_ALSAMIC_ENABLED], + [_HK_LIB_ALSA_ENABLE], + [unimplemented] +) + +HK_WILZORAPI_ARG_ENABLE([xcbMouse], + m4_normalize([XCB/Xorg Mouse Wilzor API backend: enables Harikoff to + control a virtual mouse cursor via XCB/Xorg]), + [CONFIG_XCBMOUSE_ENABLED], + [_HK_LIB_XCBXORG_ENABLE], + [unimplemented] +) + +HK_WILZORAPI_ARG_ENABLE([xcbKeyboard], + m4_normalize([XCB/Xorg Keyboard Wilzor API backend: enables Harikoff to + control a virtual keyboard via XCB/Xorg]), + [CONFIG_XCBKEYBOARD_ENABLED], + [_HK_LIB_XCBXORG_ENABLE], + [unimplemented] +) + +HK_WILZORAPI_ARG_ENABLE([alsaVoice], + m4_normalize([ALSA Voice Wilzor API backend: enables Harikoff to + vocalize via an ALSA voice synthesizer]), + [CONFIG_ALSAVOICE_ENABLED], + [_HK_LIB_ALSA_ENABLE], + [unimplemented] +) diff --git a/m4/sense_api_opts.m4 b/m4/sense_api_opts.m4 deleted file mode 100644 index 79dadfd..0000000 --- a/m4/sense_api_opts.m4 +++ /dev/null @@ -1,22 +0,0 @@ -SENSEAPIS_ENABLED= - -AC_ARG_ENABLE([senseapi-xcbxorg], - [AS_HELP_STRING([--enable-senseapi-xcbxorg], - [Enable XCB/Xorg SenseAPI backend])], - [AS_CASE([$enableval], - [no], [enable_senseapi_xcbxorg=no], - [yes|""|*], [ - enable_senseapi_xcbxorg=yes - AC_DEFINE([XCBXORG_ENABLED], [1], - [Define to 1 if you have XCB/Xorg SenseAPI backend]) - SENSEAPIS_ENABLED="${SENSEAPIS_ENABLED} xcbXorg" - PKG_CHECK_MODULES([XCB], [xcb], [], [ - AC_MSG_ERROR(m4_normalize([XCB library not found. Sense API - XCB/Xorg requires the XCB dev headers and shlib.])) - ]) - AC_SUBST([XCB_CFLAGS]) - AC_SUBST([XCB_LIBS]) - ] - )], - [enable_senseapi_xcbxorg=no] -) diff --git a/senseApis/Makefile.am b/senseApis/Makefile.am deleted file mode 100644 index 3b259f2..0000000 --- a/senseApis/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = @SENSEAPIS_ENABLED@