subs.m4 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. ## AC_ARG_WARNINGS()
  2. ##
  3. ## Provide the --enable-warnings configure argument, set to 'minimum'
  4. ## by default.
  5. ##
  6. AC_DEFUN([AC_ARG_WARNINGS],
  7. [
  8. AC_ARG_ENABLE([warnings],
  9. [ --enable-warnings=[[none|minimum|maximum|hardcore]]
  10. Control compiler pickyness. [[default=maximum]]],
  11. [gtkmm_enable_warnings="$enableval"],
  12. gtkmm_enable_warnings="maximum")
  13. AC_MSG_CHECKING([for compiler warning flags to use])
  14. gtkmm_warning_flags=''
  15. # -W is now known as -Wextra, but that's not known by gcc 2 or 3
  16. case "$gtkmm_enable_warnings" in
  17. none|no) gtkmm_warning_flags='';;
  18. minimum|yes) gtkmm_warning_flags='-Wall -Wno-unused-parameter';;
  19. maximum) gtkmm_warning_flags='-W -Wall';;
  20. hardcore) gtkmm_warning_flags='-W -Wall -Werror';;
  21. esac
  22. gtkmm_use_flags=''
  23. if test "x$gtkmm_warning_flags" != "x"
  24. then
  25. echo 'int foo() { return 0; }' > conftest.cc
  26. for flag in $gtkmm_warning_flags
  27. do
  28. # Test whether the compiler accepts the flag. GCC doesn't bail
  29. # out when given an unsupported flag but prints a warning, so
  30. # check the compiler output instead.
  31. gtkmm_cxx_out="`$CXX $flag -c conftest.cc 2>&1`"
  32. rm -f conftest.$OBJEXT
  33. test "x${gtkmm_cxx_out}" = "x" && \
  34. gtkmm_use_flags="${gtkmm_use_flags:+$gtkmm_use_flags }$flag"
  35. done
  36. rm -f conftest.cc
  37. gtkmm_cxx_out=''
  38. fi
  39. if test "x$gtkmm_use_flags" != "x"
  40. then
  41. for flag in $gtkmm_use_flags
  42. do
  43. case " $CXXFLAGS " in
  44. *" $flag "*) ;; # don't add flags twice
  45. *) CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$flag";;
  46. esac
  47. done
  48. else
  49. gtkmm_use_flags='none'
  50. fi
  51. AC_MSG_RESULT([$gtkmm_use_flags])
  52. ])
  53. AC_DEFUN([AC_ARG_DEBUG],
  54. [
  55. AC_MSG_CHECKING([for debug flags])
  56. AC_ARG_ENABLE(debug,[ --enable-debug Build in debugging mode],[
  57. debug=$enableval
  58. ],[
  59. debug="no"
  60. ])
  61. debug_flags=''
  62. case "$debug" in
  63. yes)
  64. debug_flags="-D_DEBUG -g -O0"
  65. CXXFLAGS="`echo $CXXFLAGS | sed s:-O.::` $debug_flags -fno-inline"
  66. CFLAGS="`echo $CFLAGS | sed s:-O.::` $debug_flags"
  67. ;;
  68. no|*)
  69. debug_flags="-DNDEBUG"
  70. CXXFLAGS="`echo $CXXFLAGS | sed 's:-g[[a-z-]]*\s::g' | sed 's:-g[[a-z-]]*$::'` $debug_flags"
  71. CFLAGS="`echo $CFLAGS | sed 's:-g[[a-z-]]*\s::g' | sed 's:-g[[a-z-]]*$::'` $debug_flags"
  72. ;;
  73. esac
  74. AC_MSG_RESULT([$debug_flags])
  75. ])
  76. ## Optimisation level 2 in g++ 4.1 or g++ 4.2 breaks composition loading in the vector parsing function in loadcanvas.cpp (1509627)
  77. AC_DEFUN([AC_ARG_OPTIMIZATION],
  78. [
  79. AC_MSG_CHECKING([for optimization flags])
  80. AC_ARG_ENABLE(optimization,[ --enable-optimization=[[0,1,2,3,4]] Select optimization level (default=2)],[
  81. optimization=$enableval
  82. ],[
  83. optimization="2"
  84. ])
  85. optimization_flags=''
  86. case "$optimization" in
  87. 0|no) optimization_flags="-O0";;
  88. 1) optimization_flags="-O1";;
  89. 2|yes) optimization_flags="-O2";;
  90. pass1) optimization_flags="-O2 -fprofile-arcs";;
  91. pass2) optimization_flags="-O2 -fbranch-probabilities";;
  92. 3) optimization_flags="-O3";;
  93. *) optimization_flags="-O4";;
  94. esac
  95. CXXFLAGS="`echo $CXXFLAGS | sed 's:-O.::g'` $optimization_flags"
  96. CFLAGS="`echo $CFLAGS | sed 's:-O.::g'` $optimization_flags"
  97. AC_MSG_RESULT([$optimization_flags])
  98. ])
  99. AC_DEFUN([AC_ARG_PROFILE_ARCS],
  100. [
  101. AC_MSG_CHECKING([for arc profiling])
  102. AC_ARG_ENABLE(profile-arcs,[ --enable-profile-arcs Enable arc profiling],[
  103. profile_arcs=$enableval
  104. ],[
  105. profile_arcs=no
  106. ])
  107. if test $profile_arcs = "yes" ; then {
  108. CXXFLAGS="$CXXFLAGS -fprofile-arcs";
  109. CFLAGS="$CFLAGS -fprofile-arcs";
  110. } ; fi
  111. AC_MSG_RESULT([$profile_arcs])
  112. ])
  113. AC_DEFUN([AC_ARG_BRANCH_PROBABILITIES],
  114. [
  115. AC_MSG_CHECKING([for branch-probabilities])
  116. AC_ARG_ENABLE(branch-probabilities,[ --enable-branch-probabilities Enable branch-probabilities],[
  117. branch_probabilities=$enableval
  118. ],[
  119. branch_probabilities=no
  120. ])
  121. if test $branch_probabilities = "yes" ; then {
  122. CXXFLAGS="$CXXFLAGS -fbranch-probabilities";
  123. CFLAGS="$CFLAGS -fbranch-probabilities";
  124. } ; fi
  125. AC_MSG_RESULT([$branch_probabilities])
  126. ])
  127. AC_DEFUN([AC_ARG_PROFILING],
  128. [
  129. AC_MSG_CHECKING([for profiling])
  130. AC_ARG_ENABLE(profiling,[ --enable-profiling Enable profiling using gprof],[
  131. profiling=$enableval
  132. ],[
  133. profiling=no
  134. ])
  135. if test $profiling = "yes" ; then {
  136. CFLAGS="$CFLAGS -pg";
  137. CXXFLAGS="$CXXFLAGS -pg";
  138. LDFLAGS="$LDFLAGS -pg";
  139. LIBS="$LIBS";
  140. } ; fi
  141. AC_MSG_RESULT([$profiling])
  142. ])
  143. MINGW_FLAGS="-mno-cygwin"
  144. AC_DEFUN([AC_WIN32_QUIRKS],
  145. [
  146. case "$host" in
  147. *mingw*)
  148. AC_MSG_CHECKING([the flavor of the compiler])
  149. if ( $CC --version | grep -q mingw ) ; then {
  150. AC_MSG_RESULT([compiler is mingw special])
  151. LIBTOOL_PATCH_SED="
  152. s/dir=\"\$absdir\"/dir=\`cygpath -d -m \"\$absdir\"\`/;
  153. s/absdir=\`cd \"\$dir\" && pwd\`/absdir=\`cygpath -d -m \"\$dir\"\`/;
  154. s/# We need an absolute path/dir=\`cygpath -d -m \"\$dir\"\` # We need an absolute path/;
  155. s- /usr/lib- C:/mingw/lib-g;
  156. s-\"/lib -\"C:/mingw/lib -g;
  157. s- /lib/ - -g;
  158. ";
  159. sys_lib_dlsearch_path_spec="C:/mingw/lib"
  160. ac_default_prefix=`cygpath -d -m "$ac_default_prefix"`;
  161. } else {
  162. AC_MSG_RESULT([compiler is cygwin stock, adding -mno-cygwin])
  163. CPP="$CPP $MINGW_FLAGS"
  164. CC="$CC $MINGW_FLAGS"
  165. CXX="$CXX $MINGW_FLAGS -L/usr/$host/lib -I/usr/include/c++/3.3.3/$host"
  166. CXXCPP="$CXXCPP $MINGW_FLAGS"
  167. } ; fi
  168. LTCC="gcc"
  169. CXXFLAGS="$CXXFLAGS -Wno-cpp -LC:/GTK/lib"
  170. CFLAGS="$CFLAGS -LC:/GTK/lib"
  171. LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
  172. dnl LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
  173. ;;
  174. *cygwin*)
  175. LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols"
  176. dnl LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console"
  177. CXXFLAGS="$CXXFLAGS -I/target/include"
  178. CFLAGS="$CFLAGS -I/target/include"
  179. ;;
  180. powerpc-apple*)
  181. echo Adding mac-specific optimization flags. . .
  182. CXXFLAGS="$CXXFLAGS $G5OPTFLAGS"
  183. ;;
  184. esac
  185. ])
  186. AC_DEFUN([AC_LIBTOOL_PATCH],
  187. [
  188. if [[ "$LIBTOOL_PATCH_SED""x" != "x" ]] ; then {
  189. printf "Patching libtool... "
  190. cat libtool | sed "$LIBTOOL_PATCH_SED" > libtool2
  191. rm libtool
  192. mv libtool2 libtool
  193. chmod +x libtool
  194. AC_MSG_RESULT([patched])
  195. } fi ;
  196. ])