tizen 2.3.1 release
[framework/connectivity/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([COMPILER_FLAGS], [
14         with_cflags=""
15         if (test "$USE_MAINTAINER_MODE" = "yes"); then
16                 with_cflags="$with_cflags -Wall -Werror -Wextra"
17                 with_cflags="$with_cflags -Wno-unused-parameter"
18                 with_cflags="$with_cflags -Wno-missing-field-initializers"
19                 with_cflags="$with_cflags -Wdeclaration-after-statement"
20                 with_cflags="$with_cflags -Wmissing-declarations"
21                 with_cflags="$with_cflags -Wredundant-decls"
22                 with_cflags="$with_cflags -Wcast-align"
23                 with_cflags="$with_cflags -Wswitch-enum"
24                 with_cflags="$with_cflags -Wformat -Wformat-security"
25                 with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
26                 with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
27                 with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_28"
28         fi
29         AC_SUBST([WARNING_CFLAGS], $with_cflags)
30 ])
31
32 AC_DEFUN([MISC_FLAGS], [
33         misc_cflags=""
34         misc_ldflags=""
35         AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
36                         [disable code optimization through compiler]), [
37                 if (test "${enableval}" = "no"); then
38                         misc_cflags="$misc_cflags -O0"
39                 fi
40         ])
41         AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
42                         [enable compiling with debugging information]), [
43                 if (test "${enableval}" = "yes" &&
44                                 test "${ac_cv_prog_cc_g}" = "yes"); then
45                         misc_cflags="$misc_cflags -g"
46                 fi
47         ])
48         AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
49                         [enable position independent executables flag]), [
50                 if (test "${enableval}" = "yes" &&
51                                 test "${ac_cv_prog_cc_pie}" = "yes"); then
52                         misc_cflags="$misc_cflags -fPIC"
53                         misc_ldflags="$misc_ldflags -pie"
54                 fi
55         ])
56         if (test "$enable_coverage" = "yes"); then
57                 misc_cflags="$misc_cflags --coverage"
58                 misc_ldflags="$misc_ldflags --coverage"
59         fi
60         AC_SUBST([MISC_CFLAGS], $misc_cflags)
61         AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
62 ])