doc/test-runner: Update documentation using rst format
[platform/upstream/bluez.git] / acinclude.m4
1 AC_DEFUN([AC_PROG_CC_PIE], [
2         AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
3                 echo 'void f(){}' > conftest.c
4                 if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
5                         ac_cv_prog_cc_pie=yes
6                 else
7                         ac_cv_prog_cc_pie=no
8                 fi
9                 rm -rf conftest*
10         ])
11 ])
12
13 AC_DEFUN([AC_PROG_CC_ASAN], [
14         AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=address],
15                                                 ac_cv_prog_cc_asan, [
16                 echo 'void f(){}' > asan.c
17                 if test -z "`${CC-cc} -fsanitize=address -c asan.c 2>&1`"; then
18                         ac_cv_prog_cc_asan=yes
19                 else
20                         ac_cv_prog_cc_asan=no
21                 fi
22                 rm -rf asan*
23        ])
24 ])
25
26 AC_DEFUN([AC_PROG_CC_LSAN], [
27         AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=leak],
28                                                 ac_cv_prog_cc_lsan, [
29                 echo 'void f(){}' > lsan.c
30                 if test -z "`${CC-cc} -fsanitize=leak -c lsan.c 2>&1`"; then
31                         ac_cv_prog_cc_lsan=yes
32                 else
33                         ac_cv_prog_cc_lsan=no
34                 fi
35                 rm -rf lsan*
36         ])
37 ])
38
39 AC_DEFUN([AC_PROG_CC_UBSAN], [
40         AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=undefined],
41                                                 ac_cv_prog_cc_ubsan, [
42                 echo 'void f(){}' > ubsan.c
43                 if test -z "`${CC-cc} -fsanitize=undefined -c ubsan.c 2>&1`"; then
44                         ac_cv_prog_cc_ubsan=yes
45                 else
46                         ac_cv_prog_cc_ubsan=no
47                 fi
48                 rm -rf ubsan*
49         ])
50 ])
51
52 AC_DEFUN([COMPILER_FLAGS], [
53         with_cflags=""
54         if (test "$USE_MAINTAINER_MODE" = "yes"); then
55                 with_cflags="$with_cflags -Wall -Werror -Wextra"
56                 with_cflags="$with_cflags -Wno-unused-parameter"
57                 with_cflags="$with_cflags -Wno-missing-field-initializers"
58                 with_cflags="$with_cflags -Wdeclaration-after-statement"
59                 with_cflags="$with_cflags -Wmissing-declarations"
60                 with_cflags="$with_cflags -Wredundant-decls"
61                 with_cflags="$with_cflags -Wcast-align"
62                 with_cflags="$with_cflags -Wswitch-enum"
63                 with_cflags="$with_cflags -Wformat -Wformat-security"
64                 with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
65                 with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
66                 with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
67         fi
68         AC_SUBST([WARNING_CFLAGS], $with_cflags)
69 ])
70
71 AC_DEFUN([MISC_FLAGS], [
72         misc_cflags=""
73         misc_ldflags=""
74         AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization],
75                         [disable code optimization through compiler]), [
76                 if (test "${enableval}" = "no"); then
77                         misc_cflags="$misc_cflags -O0"
78                 fi
79         ])
80         AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan],
81                         [enable linking with address sanitizer]), [
82                 save_LIBS=$LIBS
83                 AC_CHECK_LIB(asan, _init)
84                 LIBS=$save_LIBS
85                 if (test "${enableval}" = "yes" &&
86                                 test "${ac_cv_lib_asan__init}" = "yes" &&
87                                 test "${ac_cv_prog_cc_asan}" = "yes"); then
88                         misc_cflags="$misc_cflags -fsanitize=address";
89                         misc_ldflags="$misc_ldflags -fsanitize=address"
90                         AC_SUBST([ASAN_LIB], ${ac_cv_lib_asan__init})
91                 fi
92         ])
93         AC_ARG_ENABLE(lsan, AS_HELP_STRING([--enable-lsan],
94                         [enable linking with address sanitizer]), [
95                 save_LIBS=$LIBS
96                 AC_CHECK_LIB(lsan, _init)
97                 LIBS=$save_LIBS
98                 if (test "${enableval}" = "yes" &&
99                                 test "${ac_cv_lib_lsan__init}" = "yes" &&
100                                 test "${ac_cv_prog_cc_lsan}" = "yes"); then
101                         misc_cflags="$misc_cflags -fsanitize=leak";
102                         misc_ldflags="$misc_ldflags -fsanitize=leak"
103                         AC_SUBST([ASAN_LIB], ${ac_cv_lib_lsan__init})
104                 fi
105         ])
106         AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan],
107                         [enable linking with address sanitizer]), [
108                 save_LIBS=$LIBS
109                 AC_CHECK_LIB(ubsan, _init)
110                 LIBS=$save_LIBS
111                 if (test "${enableval}" = "yes" &&
112                                 test "${ac_cv_lib_ubsan__init}" = "yes" &&
113                                 test "${ac_cv_prog_cc_ubsan}" = "yes"); then
114                         misc_cflags="$misc_cflags -fsanitize=undefined";
115                         misc_ldflags="$misc_ldflags -fsanitize=undefined";
116                 fi
117         ])
118         AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
119                         [enable compiling with debugging information]), [
120                 if (test "${enableval}" = "yes" &&
121                                 test "${ac_cv_prog_cc_g}" = "yes"); then
122                         misc_cflags="$misc_cflags -g"
123                 fi
124         ])
125         AC_ARG_ENABLE(pie, AS_HELP_STRING([--enable-pie],
126                         [enable position independent executables flag]), [
127                 if (test "${enableval}" = "yes" &&
128                                 test "${ac_cv_prog_cc_pie}" = "yes"); then
129                         misc_cflags="$misc_cflags -fPIC"
130                         misc_ldflags="$misc_ldflags -pie -Wl,-z,now"
131                 fi
132         ])
133         if (test "$enable_coverage" = "yes"); then
134                 misc_cflags="$misc_cflags --coverage"
135                 misc_ldflags="$misc_ldflags --coverage"
136         fi
137         AC_SUBST([MISC_CFLAGS], $misc_cflags)
138         AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
139 ])