Build: Support common+sense+wilzor API libs; Move xcbXorg into commonLibs

xcbXorg is a connection manager lib that'll be used in common by all of
the xcb API frontends: xcbMouse, xcbWindow and xcbKeyboard. We moved
it into commonLibs to make it make more sense.

We also cleaned up the M4 scripting around AC_ARG_VAR-ing new common
libs as well as sense/wilzor libs.
This commit is contained in:
2025-01-28 04:57:07 -04:00
parent 29a1e1ecf2
commit e201b5e695
10 changed files with 146 additions and 27 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
SUBDIRS = hcore senseApis SUBDIRS = hcore commonLibs
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS+= -I"$(top_srcdir)/hcore/include" AM_CPPFLAGS+= -I"$(top_srcdir)/hcore/include"
+1
View File
@@ -0,0 +1 @@
SUBDIRS = @COMMONLIBS_ENABLED@
+9 -3
View File
@@ -64,16 +64,22 @@ AC_SUBST([AM_CPPFLAGS])
AC_SUBST([YACC]) AC_SUBST([YACC])
AC_SUBST([LEX]) 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([SENSEAPIS_ENABLED])
AC_SUBST([WILZORAPIS_ENABLED])
AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile hcore/Makefile Makefile hcore/Makefile
hcore/deviceManager/Makefile hcore/deviceManager/Makefile
hcore/senseApis/Makefile hcore/senseApis/Makefile
senseApis/Makefile commonLibs/Makefile
senseApis/xcbXorg/Makefile commonLibs/xcbXorg/Makefile
]) ])
AC_CONFIG_COMMANDS_POST([ AC_CONFIG_COMMANDS_POST([
+70
View File
@@ -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
+65
View File
@@ -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]
)
-22
View File
@@ -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]
)
-1
View File
@@ -1 +0,0 @@
SUBDIRS = @SENSEAPIS_ENABLED@