aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac18
-rw-r--r--samsung-ipc/tests/Makefile.am3
-rw-r--r--scripts/guix.scm70
-rw-r--r--tools/Makefile.am6
-rw-r--r--tools/ipc-modem/Makefile.am2
5 files changed, 91 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index 8d84140..f164c53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,10 @@ AC_SUBST(OPENSSL_LIBS)
AC_SUBST(STRICT_CFLAGS)
#------------------------------------------------------------------------------
+# Static build of test utilities
+AC_SUBST(ALL_STATIC_LDFLAGS)
+
+#------------------------------------------------------------------------------
# python
AC_SUBST(PYTHON3)
AC_CHECK_PROG([PYTHON3], [python3], [python3])
@@ -58,6 +62,14 @@ AC_ARG_ENABLE(debug,
AM_CONDITIONAL( [WANT_DEBUG], [test x"$debug" = x"yes"])
#------------------------------------------------------------------------------
+
+AC_ARG_ENABLE(static-progs,
+ [AS_HELP_STRING([--enable-static-progs],
+ [Build static (test) tools (default=disabled)])],
+ [static_progs=$enableval],
+ [static_progs="no"])
+
+#------------------------------------------------------------------------------
AC_ARG_ENABLE(strict-cflags,
[AS_HELP_STRING([--enable-strict-cflags],
[Build with strict cflags (default=disabled)])],
@@ -132,6 +144,9 @@ AC_CONFIG_FILES([
#------------------------------------------------------------------------------
+AS_IF([test x"$static_progs" = x"yes"],
+ [ALL_STATIC_LDFLAGS=-all-static], [])
+
AS_IF([test x"$strict_cflags" = x"yes"],
[STRICT_CFLAGS=`$srcdir/strict-cflags.sh`], [])
@@ -153,6 +168,7 @@ AC_PROG_LIBTOOL
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
+AC_SUBST(ALL_STATIC_LDFLAGS)
AC_OUTPUT
#------------------------------------------------------------------------------
@@ -165,7 +181,7 @@ echo
echo "Compiler flags:"
echo
echo " CFLAGS..................: $CFLAGS $STRICT_CFLAGS"
-echo " LDFLAGS.................: $LDFLAGS"
+echo " LDFLAGS.................: $LDFLAGS $ALL_STATIC_LDFLAGS"
echo
echo
echo "Interpreters paths:"
diff --git a/samsung-ipc/tests/Makefile.am b/samsung-ipc/tests/Makefile.am
index 494be9a..ad4280e 100644
--- a/samsung-ipc/tests/Makefile.am
+++ b/samsung-ipc/tests/Makefile.am
@@ -7,6 +7,8 @@ AM_CFLAGS = \
$(OPENSSL_CFLAGS) \
$(NULL)
+AM_LDFLAGS = $(ALL_STATIC_LDFLAGS)
+
if WANT_STRICT_CFLAGS
AM_CFLAGS += $(STRICT_CFLAGS)
endif
@@ -24,7 +26,6 @@ libsamsung_ipc_test_SOURCES = \
$(NULL)
libsamsung_ipc_test_LDADD = $(top_builddir)/samsung-ipc/libsamsung-ipc.la
-libsamsung_ipc_test_LDFLAGS =
# TODO: Find a way to make test more modular and represent each run of
# libsamsung-ipc-test in TEST while having it implemented in a single
diff --git a/scripts/guix.scm b/scripts/guix.scm
index b908571..bc2f7c3 100644
--- a/scripts/guix.scm
+++ b/scripts/guix.scm
@@ -196,6 +196,72 @@ found in many Samsung smartphones and tablets.")
(home-page "https://www.replicant.us")
(license license:gpl2+)))
+(define is-file-static
+ #~(lambda (readelf path)
+ ;; str is also eof if the file doesn't exist
+ (if (not (file-exists? tool)) #f
+ (let* ((port (open-input-pipe (string-append readelf " --dyn-syms "
+ path)))
+ (str (read-line port)))
+ (close-pipe port)
+ (eof-object? str)))))
+
+(define-public libsamsung-ipc-static
+ (package
+ (inherit libsamsung-ipc)
+ (name "libsamsung-ipc-static")
+ (native-inputs (list autoconf
+ automake
+ binutils
+ ddrescue
+ libtool
+ pkg-config
+ python
+ python-sh))
+ (inputs (list curl openssl
+ `(,(canonical-package openssl) "static")))
+ (arguments
+ (list #:modules '((ice-9 popen)
+ (ice-9 rdelim)
+ (guix build utils)
+ (guix build gnu-build-system))
+ #:tests? #f
+ #:phases #~(modify-phases %standard-phases
+ ;; https-send-sms depends on curl and Guix doesn't have
+ ;; a static libcurl.
+ (add-after 'unpack 'remove-https-send-sms
+ (lambda _
+ (substitute* "tools/Makefile.am"
+ (("https-send-sms \\\\")
+ "\\"))))
+ (add-after 'compress-documentation 'check-static-files
+ (lambda _
+ (display "Checking static files:\n")
+ (map-in-order (lambda (tool)
+ (if (#$is-file-static
+ (string-append #$(this-package-native-input
+ "binutils")
+ "/bin/readelf") tool)
+ (display (string-append
+ "[ OK ] "
+ (basename tool) ": "
+ tool "\n"))
+ ((lambda _
+ (display (string-append
+ "[ !! ] "
+ (basename tool)
+ ": " tool "\n"))
+ (#f)))))
+ (list
+ "samsung-ipc/tests/libsamsung-ipc-test"
+ "tools/ipc-test"
+ "tools/nv_data-imei"
+ "tools/nv_data-md5"
+ "tools/ipc-modem/ipc-modem")))))
+ #:configure-flags #~(list "--enable-debug" "--enable-static=yes"
+ "--enable-shared=no"
+ "--enable-static-progs")))))
+
(define-public libsamsung-ipc-gcc-android
(package
(inherit libsamsung-ipc)
@@ -262,6 +328,8 @@ found in many Samsung smartphones and tablets.")
;; +--------------------------------+----------+----------+--------------+--------------+
(list libsamsung-ipc
+ libsamsung-ipc-static
(with-fixed-android-make-stub libsamsung-ipc-clang-android)
(with-fixed-android-make-stub libsamsung-ipc-gcc-android)
- libsamsung-ipc-clang-autotools libsamsung-ipc-gcc-autotools)
+ libsamsung-ipc-clang-autotools
+ libsamsung-ipc-gcc-autotools)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 911ea30..024df50 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -6,6 +6,8 @@ AM_CFLAGS = \
$(LIBCURL_CFLAGS) \
$(NULL)
+AM_LDFLAGS = $(ALL_STATIC_LDFLAGS)
+
if WANT_STRICT_CFLAGS
AM_CFLAGS += $(STRICT_CFLAGS)
endif
@@ -31,16 +33,12 @@ EXTRA_DIST += $(TESTS)
https_send_sms_SOURCES = https-send-sms.c
https_send_sms_LDADD = $(LIBCURL_LIBS)
-https_send_sms_LDFLAGS =
ipc_test_SOURCES = ipc-test.c
ipc_test_LDADD = $(top_builddir)/samsung-ipc/libsamsung-ipc.la
-ipc_test_LDFLAGS =
nv_data_md5_SOURCES = nv_data-md5.c
nv_data_md5_LDADD = $(top_builddir)/samsung-ipc/libsamsung-ipc.la
-nv_data_md5_LDFLAGS =
nv_data_imei_SOURCES = nv_data-imei.c nv_data-imei.h
nv_data_imei_LDADD = $(top_builddir)/samsung-ipc/libsamsung-ipc.la
-nv_data_imei_LDFLAGS =
diff --git a/tools/ipc-modem/Makefile.am b/tools/ipc-modem/Makefile.am
index efced7e..64cde49 100644
--- a/tools/ipc-modem/Makefile.am
+++ b/tools/ipc-modem/Makefile.am
@@ -25,4 +25,4 @@ ipc-modem-log.c \
ipc-modem-log.h
ipc_modem_LDADD = $(top_builddir)/samsung-ipc/libsamsung-ipc.la
-ipc_modem_LDFLAGS = -lpthread
+ipc_modem_LDFLAGS = -lpthread $(ALL_STATIC_LDFLAGS)