~connman-maintainers/connman/head

« back to all changes in this revision

Viewing changes to configure.ac

  • Committer: Marcel Holtmann
  • Author(s): Denis Kenzior
  • Date: 2023-09-16 12:17:35 UTC
  • Revision ID: git-v1:2f52723554f187a3b72c38b9900320207175456e
build: Enable building with sanitizers

Based on code from Mat Martineau <mathew.j.martineau@linux.intel.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
AC_PROG_CC
26
26
AM_PROG_CC_C_O
27
27
AC_PROG_CC_PIE
 
28
AC_PROG_CC_ASAN
 
29
AC_PROG_CC_LSAN
 
30
AC_PROG_CC_UBSAN
28
31
AC_PROG_INSTALL
29
32
AC_PROG_MKDIR_P
30
33
 
60
63
        fi
61
64
])
62
65
 
 
66
save_LIBS=$LIBS
 
67
AC_CHECK_LIB(asan, _init)
 
68
LIBS=$save_LIBS
 
69
 
 
70
AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan],
 
71
                        [enable linking with address sanitizer]), [
 
72
        if (test "${enableval}" = "yes" &&
 
73
                                test "${ac_cv_lib_asan__init}" = "yes" &&
 
74
                                test "${ac_cv_prog_cc_asan}" = "yes"); then
 
75
                CFLAGS="$CFLAGS -fsanitize=address";
 
76
                LDFLAGS="$LDFLAGS -fsanitize=address"
 
77
        fi
 
78
])
 
79
 
 
80
save_LIBS=$LIBS
 
81
AC_CHECK_LIB(lsan, _init)
 
82
LIBS=$save_LIBS
 
83
 
 
84
AC_ARG_ENABLE(lsan, AS_HELP_STRING([--enable-lsan],
 
85
                        [enable linking with leak sanitizer]), [
 
86
        if (test "${enableval}" = "yes" &&
 
87
                                test "${ac_cv_lib_lsan__init}" = "yes" &&
 
88
                                test "${ac_cv_prog_cc_lsan}" = "yes"); then
 
89
                CFLAGS="$CFLAGS -fsanitize=leak";
 
90
                LDFLAGS="$LDFLAGS -fsanitize=leak"
 
91
        fi
 
92
])
 
93
 
 
94
save_LIBS=$LIBS
 
95
AC_CHECK_LIB(ubsan, _init)
 
96
LIBS=$save_LIBS
 
97
 
 
98
AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan],
 
99
                        [enable linking with undefined behavior sanitizer]), [
 
100
        if (test "${enableval}" = "yes" &&
 
101
                                test "${ac_cv_lib_ubsan__init}" = "yes" &&
 
102
                                test "${ac_cv_prog_cc_ubsan}" = "yes"); then
 
103
                CFLAGS="$CFLAGS -fsanitize=undefined";
 
104
                LDFLAGS="$LDFLAGS -fsanitize=undefined"
 
105
        fi
 
106
])
 
107
 
63
108
AC_ARG_ENABLE(hh2serial-gps,
64
109
        AS_HELP_STRING([--enable-hh2serial-gps], [enable hh2serial GPS support]),
65
110
                        [enable_hh2serial_gps=${enableval}], [enable_hh2serial_gps="no"])