Update/add copyrights for people who modified the code.
[synfig.git] / ETL / trunk / m4 / 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';;
23     hardcore)    gtkmm_warning_flags='-W -Wall -Werror';;
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"
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 AC_DEFUN([AC_ARG_OPTIMIZATION],
100 [
101         AC_MSG_CHECKING([for optimization flags])
102
103         AC_ARG_ENABLE(optimization,[  --enable-optimization=[[0,1,2,3,4]] Select optimization level (default=2)],[
104                 optimization=$enableval
105         ],[
106                 optimization="2"
107         ])
108         optimization_flags=''
109         case "$optimization" in
110                 0|no)   optimization_flags="-O0";;
111                 1)              optimization_flags="-O1";;
112                 2|yes)  optimization_flags="-O2";;
113                 pass1)  optimization_flags="-O2 -fprofile-arcs";;
114                 pass2)  optimization_flags="-O2 -fbranch-probabilities";;
115                 3)              optimization_flags="-O3";;
116                 *)              optimization_flags="-O4";;
117         esac
118         CXXFLAGS="`echo $CXXFLAGS | sed 's:-O.::g'` $optimization_flags"
119         CFLAGS="`echo $CFLAGS | sed 's:-O.::g'` $optimization_flags"
120         AC_MSG_RESULT([$optimization_flags])    
121 ])
122
123 AC_DEFUN([AC_ARG_PROFILE_ARCS],
124 [
125         AC_MSG_CHECKING([for arc profiling])
126
127         AC_ARG_ENABLE(profile-arcs,[  --enable-profile-arcs      Enable arc profiling],[
128                 profile_arcs=$enableval
129         ],[
130                 profile_arcs=no
131         ])
132         
133         if test $profile_arcs = "yes" ; then {
134                 CXXFLAGS="$CXXFLAGS -fprofile-arcs";
135                 CFLAGS="$CFLAGS -fprofile-arcs";
136         } ; fi
137                 
138         AC_MSG_RESULT([$profile_arcs])  
139 ])
140
141 AC_DEFUN([AC_ARG_BRANCH_PROBABILITIES],
142 [
143         AC_MSG_CHECKING([for branch-probabilities])
144
145         AC_ARG_ENABLE(branch-probabilities,[  --enable-branch-probabilities      Enable branch-probabilities],[
146                 branch_probabilities=$enableval
147         ],[
148                 branch_probabilities=no
149         ])
150         
151         if test $branch_probabilities = "yes" ; then {
152                 CXXFLAGS="$CXXFLAGS -fbranch-probabilities";
153                 CFLAGS="$CFLAGS -fbranch-probabilities";
154         } ; fi
155                 
156         AC_MSG_RESULT([$branch_probabilities])  
157 ])
158
159 AC_DEFUN([AC_ARG_PROFILING],
160 [
161         AC_MSG_CHECKING([for profiling])
162
163         AC_ARG_ENABLE(profiling,[  --enable-profiling      Enable profiling using gprof],[
164                 profiling=$enableval
165         ],[
166                 profiling=no
167         ])
168         
169         if test $profiling = "yes" ; then {
170                 CFLAGS="$CFLAGS -pg";
171                 CXXFLAGS="$CXXFLAGS -pg";
172                 LDFLAGS="$LDFLAGS -pg";
173                 LIBS="$LIBS";
174         } ; fi
175                 
176         AC_MSG_RESULT([$profiling])     
177 ])
178
179 MINGW_FLAGS="-mno-cygwin"
180
181
182 AC_DEFUN([AC_WIN32_QUIRKS],
183 [
184
185 case "$host" in
186   *mingw*)
187     AC_MSG_CHECKING([the flavor of the compiler])
188     if ( $CC --version | grep -q mingw ) ; then {
189         AC_MSG_RESULT([compiler is mingw special])
190         LIBTOOL_PATCH_SED="
191             s/dir=\"\$absdir\"/dir=\`cygpath -d -m \"\$absdir\"\`/;
192             s/absdir=\`cd \"\$dir\" && pwd\`/absdir=\`cygpath -d -m \"\$dir\"\`/;
193             s/# We need an absolute path/dir=\`cygpath -d -m \"\$dir\"\` # We need an absolute path/;
194             s- /usr/lib- C:/mingw/lib-g;
195             s-\"/lib -\"C:/mingw/lib -g;
196             s- /lib/ - -g;
197         ";
198         sys_lib_dlsearch_path_spec="C:/mingw/lib"
199         ac_default_prefix=`cygpath -d -m "$ac_default_prefix"`;
200     } else {
201     AC_MSG_RESULT([compiler is cygwin stock, adding -mno-cygwin])
202     CPP="$CPP $MINGW_FLAGS"
203     CC="$CC $MINGW_FLAGS"
204     CXX="$CXX $MINGW_FLAGS -L/usr/$host/lib -I/usr/include/c++/3.3.3/$host"
205     CXXCPP="$CXXCPP $MINGW_FLAGS"
206
207
208 } ; fi
209
210     LTCC="gcc"
211     CXXFLAGS="$CXXFLAGS -LC:/GTK/lib"
212     CFLAGS="$CFLAGS -LC:/GTK/lib"
213     LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc" 
214 dnl    LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
215     ;;
216   *cygwin*)
217     LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols"
218 dnl    LDFLAGS="$LDFLAGS -lole32 -no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console"
219     CXXFLAGS="$CXXFLAGS -I/target/include"
220     CFLAGS="$CFLAGS -I/target/include"
221     ;;
222   powerpc-apple*)
223     echo Adding mac-specific optimization flags. . .
224     CXXFLAGS="$CXXFLAGS $G5OPTFLAGS"
225     ;;
226 esac
227
228
229 ])
230
231 AC_DEFUN([AC_LIBTOOL_PATCH],
232 [
233
234 if [[ "$LIBTOOL_PATCH_SED""x" != "x" ]] ; then {
235     printf "Patching libtool... "
236     cat libtool | sed "$LIBTOOL_PATCH_SED" > libtool2
237     rm libtool
238     mv libtool2 libtool
239     chmod +x libtool
240     AC_MSG_RESULT([patched])
241 } fi ;
242
243
244 ])