4 ## Provide the --enable-warnings configure argument, set to 'minimum'
7 AC_DEFUN([AC_ARG_WARNINGS],
9 AC_ARG_ENABLE([warnings],
10 [ --enable-warnings=[[none|minimum|maximum|hardcore]]
11 Control compiler pickyness. [[default=maximum]]],
12 [gtkmm_enable_warnings="$enableval"],
13 gtkmm_enable_warnings="maximum")
15 AC_MSG_CHECKING([for compiler warning flags to use])
17 gtkmm_warning_flags=''
19 # -W is now known as -Wextra, but that's not known by gcc 2 or 3
20 case "$gtkmm_enable_warnings" in
21 none|no) gtkmm_warning_flags='';;
22 minimum|yes) gtkmm_warning_flags='-Wall -Wno-unused-parameter';;
23 maximum) gtkmm_warning_flags='-W -Wall';;
24 hardcore) gtkmm_warning_flags='-W -Wall -Werror';;
29 if test "x$gtkmm_warning_flags" != "x"
31 echo 'int foo() { return 0; }' > conftest.cc
33 for flag in $gtkmm_warning_flags
35 # Test whether the compiler accepts the flag. GCC doesn't bail
36 # out when given an unsupported flag but prints a warning, so
37 # check the compiler output instead.
38 gtkmm_cxx_out="`$CXX $flag -c conftest.cc 2>&1`"
39 rm -f conftest.$OBJEXT
40 test "x${gtkmm_cxx_out}" = "x" && \
41 gtkmm_use_flags="${gtkmm_use_flags:+$gtkmm_use_flags }$flag"
48 if test "x$gtkmm_use_flags" != "x"
50 for flag in $gtkmm_use_flags
53 *" $flag "*) ;; # don't add flags twice
54 *) CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$flag";;
58 gtkmm_use_flags='none'
61 AC_MSG_RESULT([$gtkmm_use_flags])
67 AC_DEFUN([AC_ARG_DEBUG],
69 AC_MSG_CHECKING([for debug flags])
71 AC_ARG_ENABLE(debug,[ --enable-debug Build in debugging mode],[
80 debug_flags="-D_DEBUG -g"
83 debug_flags="-DNDEBUG -g"
86 debug_flags="-DNDEBUG"
91 CXXFLAGS="`echo $CXXFLAGS | sed s:-g::` $debug_flags"
92 CFLAGS="`echo $CFLAGS | sed s:-g::` $debug_flags"
94 AC_MSG_RESULT([$debug_flags])
100 ## Optimisation level 2 in g++ 4.1 or g++ 4.2 breaks composition loading in the vector parsing function in loadcanvas.cpp (1509627)
101 AC_DEFUN([AC_ARG_OPTIMIZATION],
103 AC_MSG_CHECKING([for optimization flags])
105 AC_ARG_ENABLE(optimization,[ --enable-optimization=[[0,1,2,3,4]] Select optimization level (default=2)],[
106 optimization=$enableval
110 optimization_flags=''
111 case "$optimization" in
112 0|no) optimization_flags="-O0";;
113 1) optimization_flags="-O1";;
114 2|yes) optimization_flags="-O2";;
115 pass1) optimization_flags="-O2 -fprofile-arcs";;
116 pass2) optimization_flags="-O2 -fbranch-probabilities";;
117 3) optimization_flags="-O3";;
118 *) optimization_flags="-O4";;
120 CXXFLAGS="`echo $CXXFLAGS | sed 's:-O.::g'` $optimization_flags"
121 CFLAGS="`echo $CFLAGS | sed 's:-O.::g'` $optimization_flags"
122 AC_MSG_RESULT([$optimization_flags])
125 AC_DEFUN([AC_ARG_PROFILE_ARCS],
127 AC_MSG_CHECKING([for arc profiling])
129 AC_ARG_ENABLE(profile-arcs,[ --enable-profile-arcs Enable arc profiling],[
130 profile_arcs=$enableval
135 if test $profile_arcs = "yes" ; then {
136 CXXFLAGS="$CXXFLAGS -fprofile-arcs";
137 CFLAGS="$CFLAGS -fprofile-arcs";
140 AC_MSG_RESULT([$profile_arcs])
143 AC_DEFUN([AC_ARG_BRANCH_PROBABILITIES],
145 AC_MSG_CHECKING([for branch-probabilities])
147 AC_ARG_ENABLE(branch-probabilities,[ --enable-branch-probabilities Enable branch-probabilities],[
148 branch_probabilities=$enableval
150 branch_probabilities=no
153 if test $branch_probabilities = "yes" ; then {
154 CXXFLAGS="$CXXFLAGS -fbranch-probabilities";
155 CFLAGS="$CFLAGS -fbranch-probabilities";
158 AC_MSG_RESULT([$branch_probabilities])
161 AC_DEFUN([AC_ARG_PROFILING],
163 AC_MSG_CHECKING([for profiling])
165 AC_ARG_ENABLE(profiling,[ --enable-profiling Enable profiling using gprof],[
171 if test $profiling = "yes" ; then {
172 CFLAGS="$CFLAGS -pg";
173 CXXFLAGS="$CXXFLAGS -pg";
174 LDFLAGS="$LDFLAGS -pg";
178 AC_MSG_RESULT([$profiling])
181 MINGW_FLAGS="-mno-cygwin"
184 AC_DEFUN([AC_WIN32_QUIRKS],
189 AC_MSG_CHECKING([the flavor of the compiler])
190 if ( $CC --version | grep -q mingw ) ; then {
191 AC_MSG_RESULT([compiler is mingw special])
193 s/dir=\"\$absdir\"/dir=\`cygpath -d -m \"\$absdir\"\`/;
194 s/absdir=\`cd \"\$dir\" && pwd\`/absdir=\`cygpath -d -m \"\$dir\"\`/;
195 s/# We need an absolute path/dir=\`cygpath -d -m \"\$dir\"\` # We need an absolute path/;
196 s- /usr/lib- C:/mingw/lib-g;
197 s-\"/lib -\"C:/mingw/lib -g;
200 sys_lib_dlsearch_path_spec="C:/mingw/lib"
201 ac_default_prefix=`cygpath -d -m "$ac_default_prefix"`;
203 AC_MSG_RESULT([compiler is cygwin stock, adding -mno-cygwin])
204 CPP="$CPP $MINGW_FLAGS"
205 CC="$CC $MINGW_FLAGS"
206 CXX="$CXX $MINGW_FLAGS -L/usr/$host/lib -I/usr/include/c++/3.3.3/$host"
207 CXXCPP="$CXXCPP $MINGW_FLAGS"
213 CXXFLAGS="$CXXFLAGS -LC:/GTK/lib"
214 CFLAGS="$CFLAGS -LC:/GTK/lib"
215 LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
216 dnl LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
219 LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols"
220 dnl LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console"
221 CXXFLAGS="$CXXFLAGS -I/target/include"
222 CFLAGS="$CFLAGS -I/target/include"
225 echo Adding mac-specific optimization flags. . .
226 CXXFLAGS="$CXXFLAGS $G5OPTFLAGS"
233 AC_DEFUN([AC_LIBTOOL_PATCH],
236 if [[ "$LIBTOOL_PATCH_SED""x" != "x" ]] ; then {
237 printf "Patching libtool... "
238 cat libtool | sed "$LIBTOOL_PATCH_SED" > libtool2
242 AC_MSG_RESULT([patched])