[Replicant] [libsamsung-ipc] [PATCH 12/21] Autotools: Add --enable-samsung-ipc-device=[DEVICE] option

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Fri Jun 17 16:15:44 UTC 2022


In the Android.mk we have the following:
    ifneq ($(TARGET_DEVICE),)
    libsamsung_local_cflags += -DIPC_DEVICE_NAME=\"$(ipc_device_name)\"
    endif # ifneq ($(TARGET_DEVICE),)

This makes libsamsung-ipc assume that it runs on a specific device.

It can for instance be useful to test libsamsung-ipc on a device very
similar to one that is already supported, or during development.

The issue is that, with autotools and without this patch, this feature
is not easy to use as to force the i9300 device we would have to run
configure in this way:
    ./configure CFLAGS='-DIPC_DEVICE_NAME=\"i9300\"'
And we had no feedback that could indicate if it worked or not.

Note that even now, the only feedback we have is the output of
./configure because the autodetection of the device is done in
ipc_device_detect.

And ipc_device_detect is called by ipc_transport_client_create which
setups the ipc_client struct. And without a valid ipc_client struct,
we cannot use ipc_client_log, so we can't print in ipc_device_detect.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 configure.ac            | 19 +++++++++++++++++++
 samsung-ipc/Makefile.am |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/configure.ac b/configure.ac
index 32f285b..596b5d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,10 @@ AC_SUBST(STRICT_CFLAGS)
 # valgrind
 AC_SUBST(VALGRIND)
 
+#------------------------------------------------------------------------------
+# ipc device name
+AC_SUBST([IPC_DEVICE_NAME], [all])
+
 #------------------------------------------------------------------------------
 # libcurl
 PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED)
@@ -71,6 +75,19 @@ AS_IF([test x"$valgrind_tests" = x"yes"],
      [AC_MSG_ERROR(
        [valgrind tests are enabled but valgrind was not found in PATH ($PATH)])])])
 #------------------------------------------------------------------------------
+AC_ARG_ENABLE(samsung-ipc-device,
+  [  --enable-samsung-ipc-device=[DEVICE]
+                          make libsamsung-ipc assumes that it runs on DEVICE
+                          DEVICE={all,aries,crespo,galaxys2,herolte,i9300,maguro,n5100,n7100,piranha} (default=all)],
+  [AS_CASE([$enableval],
+            [aries|crespo|galaxys2|herolte|i9300|maguro|n5100|n7100|piranha],
+            [IPC_DEVICE_NAME=$enableval],
+            [AC_MSG_ERROR([Unnown device $enableval])])],
+  [IPC_DEVICE_NAME="all"])
+
+AM_CONDITIONAL( [WANT_IPC_DEVICE_NAME], [test x"$IPC_DEVICE_NAME" != x"all"])
+#------------------------------------------------------------------------------
+
 AC_CONFIG_FILES([
     Makefile
     samsung-ipc.pc
@@ -117,6 +134,8 @@ echo "Configuration Options:"
 echo
 echo "  debug build.............: $debug"
 echo
+echo "  device(s)...............: $IPC_DEVICE_NAME"
+echo
 echo "  prefix..................: $prefix"
 echo
 echo "  valgrind tests..........: $valgrind_tests"
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am
index 95f4954..47484e5 100644
--- a/samsung-ipc/Makefile.am
+++ b/samsung-ipc/Makefile.am
@@ -14,6 +14,10 @@ if WANT_DEBUG
 AM_CFLAGS += -DDEBUG
 endif
 
+if WANT_IPC_DEVICE_NAME
+AM_CFLAGS += -DIPC_DEVICE_NAME=\"$(IPC_DEVICE_NAME)\"
+endif
+
 lib_LTLIBRARIES = \
 	libsamsung-ipc.la \
 	$(NULL)
-- 
2.36.1



More information about the Replicant mailing list