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