[c5c522c] | 1 | dnl $Id: gcc_build_options.m4,v 1.1 2004/10/24 20:48:37 jonz Exp $ |
---|
| 2 | dnl gcc_build_options.m4 |
---|
| 3 | dnl |
---|
| 4 | |
---|
| 5 | AC_DEFUN([GCC_BUILD_OPTIONS], |
---|
| 6 | [ |
---|
| 7 | |
---|
| 8 | if test x$GCC = xyes |
---|
| 9 | then |
---|
| 10 | |
---|
| 11 | # |
---|
| 12 | # Enable Compiler Warnings |
---|
| 13 | # |
---|
| 14 | |
---|
| 15 | AC_ARG_ENABLE(warnings, |
---|
| 16 | [[ --enable-warnings[={no|[{yes|error}][,proto]}] |
---|
| 17 | Disable (no) or enable (yes) more warnings |
---|
| 18 | or enable and treat warnings as errors (error). |
---|
| 19 | Simple --enable-warnings is the same |
---|
| 20 | as --enable-warnings=yes. |
---|
| 21 | You can add ',proto' to 'yes' or 'error' option |
---|
| 22 | for turning on additional '-Wstrict-prototypes' |
---|
| 23 | flag. |
---|
| 24 | Have effect for GCC compilers only. |
---|
| 25 | --disable-warnings Same as --enable-warnings=no [default]]]) |
---|
| 26 | |
---|
| 27 | gcc_param=",$enable_warnings," |
---|
| 28 | gcc_enable_warnings=`echo $gcc_param|grep ',no,' >/dev/null 2>&1 && echo no || echo yes` |
---|
| 29 | gcc_enable_error=`echo $gcc_param|grep ',error,' >/dev/null 2>&1 && echo yes || echo no` |
---|
| 30 | gcc_enable_strict_proto=`echo $gcc_param|grep ',proto,' >/dev/null 2>&1 && echo yes || echo no` |
---|
| 31 | |
---|
| 32 | warn_flags='-Wall -Wmissing-prototypes -Wmissing-declarations' |
---|
| 33 | |
---|
| 34 | if test x$gcc_enable_strict_proto != xno |
---|
| 35 | then |
---|
| 36 | warn_flags="$warn_flags -Wstrict-prototypes" |
---|
| 37 | fi |
---|
| 38 | |
---|
| 39 | if test x$gcc_enable_error != xno |
---|
| 40 | then |
---|
| 41 | warn_flags="$warn_flags -Werror" |
---|
| 42 | fi |
---|
| 43 | |
---|
| 44 | if test x$gcc_enable_warnings != xno |
---|
| 45 | then |
---|
| 46 | CFLAGS="$CFLAGS $warn_flags" |
---|
| 47 | CXXFLAGS="$CXXFLAGS $warn_flags" |
---|
| 48 | fi |
---|
| 49 | |
---|
| 50 | # |
---|
| 51 | # Enable Profiling Support |
---|
| 52 | # |
---|
| 53 | AC_ARG_ENABLE(profiling, |
---|
| 54 | [AS_HELP_STRING(--enable-profiling, |
---|
| 55 | Disable (no) or enable (yes) performance profiling. |
---|
| 56 | Generate extra code to write profile information |
---|
| 57 | suitable for the analysis program gprof. |
---|
| 58 | Has effect for GCC compilers only. |
---|
| 59 | )]) |
---|
| 60 | AC_MSG_CHECKING([whether to enable profiling output]) |
---|
| 61 | case x"$enable_profiling" in |
---|
| 62 | xyes) # profiling output enabled explicity |
---|
| 63 | ;; |
---|
| 64 | xno) # profiling output disabled explicity |
---|
| 65 | ;; |
---|
| 66 | x) # profiling output disabled by default |
---|
| 67 | enable_profiling=no |
---|
| 68 | ;; |
---|
| 69 | *) AC_MSG_ERROR([unexpected value $enable_profiling for --{enable,disable}-profiling configure option]) |
---|
| 70 | ;; |
---|
| 71 | esac |
---|
| 72 | if test x"$enable_profiling" != xyes |
---|
| 73 | then |
---|
| 74 | enable_profiling=no |
---|
| 75 | else |
---|
| 76 | enable_profiling=yes # overkill, but convenient |
---|
| 77 | CFLAGS="$CFLAGS -pg" |
---|
| 78 | CXXFLAGS="$CXXFLAGS -pg" |
---|
| 79 | fi |
---|
| 80 | AC_MSG_RESULT([$enable_profiling]) |
---|
| 81 | |
---|
| 82 | # GCC |
---|
| 83 | fi |
---|
| 84 | |
---|
| 85 | ]) |
---|
| 86 | |
---|