aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-06-10 22:45:17 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-07-22 18:46:34 +0200
commite4840993bbc77d640cb2d4c866e8e60e2deb27a9 (patch)
treede10681e3e7c3bd1d152d00fe428071065a5187c
parent217209ce8f494788d03fe8dc4d28c07d47eaeffd (diff)
downloadhardware_replicant_libsamsung-ipc-e4840993bbc77d640cb2d4c866e8e60e2deb27a9.tar.gz
hardware_replicant_libsamsung-ipc-e4840993bbc77d640cb2d4c866e8e60e2deb27a9.tar.bz2
hardware_replicant_libsamsung-ipc-e4840993bbc77d640cb2d4c866e8e60e2deb27a9.zip
configure.ac: Add an option to use scripts/guix.scm's strict CFLAGS
The CFLAGS that are in the %common-strict-cflags in scripts/guix.scm have been validated with both GCC and CLANG and they are useful to find potential issues in the code or code that won't compile on Android. However while the scripts/guix.scm script is really useful to test commits once they are ready, it is less convenient to use it when fixing issues in commits that are still being worked on. This is because it is not as fast as building libsamsung-ipc directly because: - it requires a clean source directory to work (this can be done with make distclean) so we can't reuse the current build output - libsamsung-ipc source code is copied and built 5 times (in different configurations) As for the implementation, AM_CFLAGS was used instead of appending to the default CFLAGS as CFLAGS is meant to be a variable for users. The effect is that both are independent, so if users don't want strict CFLAGS, they would need to not use --enable-strict-cflags. And it was implemented as a shell script to at the same time: - Enable to have comments, and good formating of the flags. - Enable to share the cflags between guix.scm and the autotools. - Keep the complexity low to keep it working in most situations. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac18
-rw-r--r--samsung-ipc/Makefile.am4
-rw-r--r--samsung-ipc/tests/Makefile.am4
-rw-r--r--scripts/guix.scm19
-rwxr-xr-xstrict-cflags.sh35
-rw-r--r--tools/Makefile.am4
-rw-r--r--tools/ipc-modem/Makefile.am4
8 files changed, 74 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index 0073e4c..ce62682 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,6 +14,8 @@ pkgconfig_DATA = samsung-ipc.pc
EXTRA_DIST = \
MAINTAINERS \
samsung-ipc.pc \
+ strict-cflags.sh \
+ tools/include/glibc/sysexits.h \
$(NULL)
MAINTAINERCLEANFILES = \
diff --git a/configure.ac b/configure.ac
index b0a6d9b..4027a47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,10 @@ AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LIBS)
#------------------------------------------------------------------------------
+# strict cflags
+AC_SUBST(STRICT_CFLAGS)
+
+#------------------------------------------------------------------------------
# valgrind
AC_SUBST(VALGRIND)
@@ -43,6 +47,14 @@ AC_ARG_ENABLE(debug,
AM_CONDITIONAL( [WANT_DEBUG], [test x"$debug" = x"yes"])
#------------------------------------------------------------------------------
+AC_ARG_ENABLE(strict-cflags,
+ [AS_HELP_STRING([--enable-strict-cflags],
+ [Build with strict cflags (default=disabled)])],
+ [strict_cflags=$enableval],
+ [strict_cflags="no"])
+AM_CONDITIONAL( [WANT_STRICT_CFLAGS], [test x"$strict_cflags" = x"yes"])
+
+#------------------------------------------------------------------------------
# TODO: GCC has --enable-checking= for extensive runtime checks and one of the
# available values is valgrind, so it would be a good idea to convert to
# it for consistency across free software projects.
@@ -88,6 +100,9 @@ AC_CONFIG_FILES([
#------------------------------------------------------------------------------
+AS_IF([test x"$strict_cflags" = x"yes"],
+ [STRICT_CFLAGS=`$srcdir/strict-cflags.sh`], [])
+
AS_IF([test x"$valgrind_tests" = x"yes"], [: ${CFLAGS="-ggdb3 -O0"}],
[test x"$debug" = x"yes"], [: ${CFLAGS="-ggdb -O0"}], [])
@@ -111,7 +126,7 @@ echo "------------------------------------------------------------------------"
echo
echo "Compiler flags:"
echo
-echo " CFLAGS..................: $CFLAGS"
+echo " CFLAGS..................: $CFLAGS $STRICT_CFLAGS"
echo
echo
echo "Configuration Options:"
@@ -127,4 +142,3 @@ echo
echo "------------------------------------------------------------------------"
echo
echo "Now type 'make' to compile and 'make install' to install this package."
-
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am
index 5eb3bbc..47484e5 100644
--- a/samsung-ipc/Makefile.am
+++ b/samsung-ipc/Makefile.am
@@ -6,6 +6,10 @@ AM_CFLAGS = \
$(OPENSSL_CFLAGS) \
$(NULL)
+if WANT_STRICT_CFLAGS
+AM_CFLAGS += $(STRICT_CFLAGS)
+endif
+
if WANT_DEBUG
AM_CFLAGS += -DDEBUG
endif
diff --git a/samsung-ipc/tests/Makefile.am b/samsung-ipc/tests/Makefile.am
index 1a7a56b..8147a7b 100644
--- a/samsung-ipc/tests/Makefile.am
+++ b/samsung-ipc/tests/Makefile.am
@@ -6,6 +6,10 @@ AM_CFLAGS = \
$(OPENSSL_CFLAGS) \
$(NULL)
+if WANT_STRICT_CFLAGS
+AM_CFLAGS += $(STRICT_CFLAGS)
+endif
+
if WANT_DEBUG
AM_CFLAGS += -DDEBUG
endif
diff --git a/scripts/guix.scm b/scripts/guix.scm
index 4a772a9..19d6221 100644
--- a/scripts/guix.scm
+++ b/scripts/guix.scm
@@ -65,20 +65,11 @@
(gnu packages valgrind))
(define %common-strict-cflags
- (string-append
- " CFLAGS="
- " -W"
- " -Wall"
- " -Werror"
- " -Werror=address"
- " -Werror=return-type"
- " -Werror=sequence-point"
- " -Winit-self"
- " -Wno-unused"
- " -Wpedantic"
- " -Wpointer-arith"
- " -Wunused"
- " -Wunused-function"))
+ (let* ((port (open-input-pipe
+ "./strict-cflags.sh"))
+ (str (read-line port)))
+ (close-pipe port)
+ (string-append "CFLAGS=" str)))
(define %clang-strict-cflags
(string-append
diff --git a/strict-cflags.sh b/strict-cflags.sh
new file mode 100755
index 0000000..55380f3
--- /dev/null
+++ b/strict-cflags.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# This file is part of libsamsung-ipc.
+#
+# Copyright (C) 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# libsamsung-ipc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# libsamsung-ipc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+
+strict_cflags="\
+ -W \
+ -Wall \
+ -Werror \
+ -Werror=address \
+ -Werror=return-type \
+ -Werror=sequence-point \
+ -Winit-self \
+ -Wno-unused \
+ -Wpedantic \
+ -Wpointer-arith \
+ -Wunused \
+ -Wunused-function \
+"
+
+echo ${strict_cflags}
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 5d79235..0360a6e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -5,6 +5,10 @@ AM_CFLAGS = \
$(LIBCURL_CFLAGS) \
$(NULL)
+if WANT_STRICT_CFLAGS
+AM_CFLAGS += $(STRICT_CFLAGS)
+endif
+
bin_PROGRAMS = \
https-send-sms \
ipc-test \
diff --git a/tools/ipc-modem/Makefile.am b/tools/ipc-modem/Makefile.am
index 069f082..2f6b537 100644
--- a/tools/ipc-modem/Makefile.am
+++ b/tools/ipc-modem/Makefile.am
@@ -4,6 +4,10 @@ AM_CFLAGS = \
-I$(top_srcdir)/include \
$(NULL)
+if WANT_STRICT_CFLAGS
+AM_CFLAGS += $(STRICT_CFLAGS)
+endif
+
bin_PROGRAMS = ipc-modem
# TODO: Find a way to make test more modular and represent each run of the