Show what's going on with messages to stdout. Fix another problem with transparent...
[synfig.git] / synfig-core / trunk / config / subs.m4
1
2 ## AC_ARG_WARNINGS()
3 ##
4 ## Provide the --enable-warnings configure argument, set to 'minimum'
5 ## by default.
6 ##
7 AC_DEFUN([AC_ARG_WARNINGS],
8 [
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")
14
15   AC_MSG_CHECKING([for compiler warning flags to use])
16
17   gtkmm_warning_flags=''
18
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 -Wno-unused-parameter';;
24     hardcore)    gtkmm_warning_flags='-W -Wall -Werror -Wno-unused-parameter';;
25   esac
26
27   gtkmm_use_flags=''
28
29   if test "x$gtkmm_warning_flags" != "x"
30   then
31     echo 'int foo() { return 0; }' > conftest.cc
32
33     for flag in $gtkmm_warning_flags
34     do
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"
42     done
43
44     rm -f conftest.cc
45     gtkmm_cxx_out=''
46   fi
47
48   if test "x$gtkmm_use_flags" != "x"
49   then
50     for flag in $gtkmm_use_flags
51     do
52       case " $CXXFLAGS " in
53         *" $flag "*) ;; # don't add flags twice
54         *)           CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$flag";;
55       esac
56     done
57   else
58     gtkmm_use_flags='none'
59   fi
60
61   AC_MSG_RESULT([$gtkmm_use_flags])
62 ])
63
64
65
66
67 AC_DEFUN([AC_ARG_DEBUG],
68 [
69         AC_MSG_CHECKING([for debug flags])
70
71         AC_ARG_ENABLE(debug,[  --enable-debug           Build in debugging mode],[
72                 debug=$enableval
73         ],[
74                 debug="no"
75         ])
76         debug_flags=''
77
78         case "$debug" in
79                 yes)
80                         debug_flags="-D_DEBUG -g"
81                 ;;
82                 half)
83                         debug_flags="-DNDEBUG -g"
84                 ;;
85                 no|*)
86                         debug_flags="-DNDEBUG -Wno-deprecated"
87                 ;;
88         esac
89
90
91         CXXFLAGS="`echo $CXXFLAGS | sed s:-g::` $debug_flags"
92         CFLAGS="`echo $CFLAGS | sed s:-g::` $debug_flags"
93
94         AC_MSG_RESULT([$debug_flags])
95 ])
96
97
98
99
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],
102 [
103         AC_MSG_CHECKING([for optimization flags])
104
105         AC_ARG_ENABLE(optimization,[  --enable-optimization=[[0,1,2,3,4]] Select optimization level (default=2)],[
106                 optimization=$enableval
107         ],[
108                 optimization="2"
109         ])
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";;
119         esac
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])    
123 ])
124
125 AC_DEFUN([AC_ARG_PROFILE_ARCS],
126 [
127         AC_MSG_CHECKING([for arc profiling])
128
129         AC_ARG_ENABLE(profile-arcs,[  --enable-profile-arcs      Enable arc profiling],[
130                 profile_arcs=$enableval
131         ],[
132                 profile_arcs=no
133         ])
134         
135         if test $profile_arcs = "yes" ; then {
136                 CXXFLAGS="$CXXFLAGS -fprofile-arcs";
137                 CFLAGS="$CFLAGS -fprofile-arcs";
138         } ; fi
139                 
140         AC_MSG_RESULT([$profile_arcs])  
141 ])
142
143 AC_DEFUN([AC_ARG_BRANCH_PROBABILITIES],
144 [
145         AC_MSG_CHECKING([for branch-probabilities])
146
147         AC_ARG_ENABLE(branch-probabilities,[  --enable-branch-probabilities      Enable branch-probabilities],[
148                 branch_probabilities=$enableval
149         ],[
150                 branch_probabilities=no
151         ])
152         
153         if test $branch_probabilities = "yes" ; then {
154                 CXXFLAGS="$CXXFLAGS -fbranch-probabilities";
155                 CFLAGS="$CFLAGS -fbranch-probabilities";
156         } ; fi
157                 
158         AC_MSG_RESULT([$branch_probabilities])  
159 ])
160
161 AC_DEFUN([AC_ARG_PROFILING],
162 [
163         AC_MSG_CHECKING([for profiling])
164
165         AC_ARG_ENABLE(profiling,[  --enable-profiling      Enable profiling using gprof],[
166                 profiling=$enableval
167         ],[
168                 profiling=no
169         ])
170         
171         if test $profiling = "yes" ; then {
172                 CFLAGS="$CFLAGS -pg";
173                 CXXFLAGS="$CXXFLAGS -pg";
174                 LDFLAGS="$LDFLAGS -pg";
175                 LIBS="$LIBS";
176         } ; fi
177                 
178         AC_MSG_RESULT([$profiling])     
179 ])
180
181 AC_DEFUN([AC_ARG_TIMELIMIT],
182 [
183         AC_ARG_ENABLE(timelimit,[  --enable-timelimit=[[days]] Set number of usable days(default=forever)],[
184                 death_time=$((`date +%s`+$enableval*60*60*24))
185                 AC_DEFINE_UNQUOTED(DEATH_TIME,$death_time, [ Describes the time at which the library will stop working ] )
186         ],
187         [
188                 death_time="no"
189         ])
190 ])
191
192 AC_DEFUN([AC_ARG_LICENSE_KEY],
193 [
194         AC_ARG_ENABLE(license_key,[  --enable-license-key    Turn on license key requirement],[
195                 AC_DEFINE(LICENSE_KEY_REQUIRED,, [ Enables license key checks ] )
196         ],
197         [
198                 license_key=no
199         ])
200 ])
201
202 AC_DEFUN([AC_ARG_TIMELIMIT],
203 [
204         AC_ARG_ENABLE(timelimit,[  --enable-timelimit=[[days]] Set number of usable days(default=forever)],[
205                 death_time=$((`date +%s`+$enableval*60*60*24))
206                 AC_DEFINE_UNQUOTED(DEATH_TIME,$death_time, [ Describes the time at which the library will stop working ] )
207         ],
208         [
209                 death_time="no"
210         ])
211 ])
212
213 MINGW_FLAGS="-mno-cygwin"
214
215
216 AC_DEFUN([AC_WIN32_QUIRKS],
217 [
218
219 case "$host" in
220   *mingw*)
221     AC_MSG_CHECKING([the flavor of the compiler])
222     if ( $CC --version | grep -q mingw ) ; then {
223         AC_MSG_RESULT([compiler is mingw special])
224         LIBTOOL_PATCH_SED="
225             s/dir=\"\$absdir\"/dir=\`cygpath -d -m \"\$absdir\"\`/;
226             s/absdir=\`cd \"\$dir\" && pwd\`/absdir=\`cygpath -d -m \"\$dir\"\`/;
227             s/# We need an absolute path/dir=\`cygpath -d -m \"\$dir\"\` # We need an absolute path/;
228             s- /usr/lib- C:/mingw/lib-g;
229             s-\"/lib -\"C:/mingw/lib -g;
230             s- /lib/ - -g;
231         ";
232         sys_lib_dlsearch_path_spec="C:/mingw/lib"
233         ac_default_prefix=`cygpath -d -m "$ac_default_prefix"`;
234     } else {
235     AC_MSG_RESULT([compiler is cygwin stock, adding -mno-cygwin])
236     CPP="$CPP $MINGW_FLAGS"
237     CC="$CC $MINGW_FLAGS"
238     CXX="$CXX $MINGW_FLAGS -L/usr/$host/lib -I/usr/include/c++/3.3.3/$host"
239     CXXCPP="$CXXCPP $MINGW_FLAGS"
240
241
242 } ; fi
243
244     LTCC="gcc"
245     CXXFLAGS="$CXXFLAGS -LC:/GTK/lib"
246     CFLAGS="$CFLAGS -LC:/GTK/lib"
247     LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc" 
248 dnl    LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
249     ;;
250   *cygwin*)
251     LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols"
252 dnl    LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console"
253     CXXFLAGS="$CXXFLAGS -I/target/include"
254     CFLAGS="$CFLAGS -I/target/include"
255     ;;
256   powerpc-apple*)
257     echo Adding mac-specific optimization flags. . .
258     CXXFLAGS="$CXXFLAGS $G5OPTFLAGS"
259     ;;
260 esac
261
262
263 ])
264
265 AC_DEFUN([AC_LIBTOOL_PATCH],
266 [
267
268 if [[ "$LIBTOOL_PATCH_SED""x" != "x" ]] ; then {
269     printf "Patching libtool... "
270     cat libtool | sed "$LIBTOOL_PATCH_SED" > libtool2
271     rm libtool
272     mv libtool2 libtool
273     chmod +x libtool
274     AC_MSG_RESULT([patched])
275 } fi ;
276
277
278 ])