subs.m4 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. AC_DEFUN([AC_ARG_OPTIMIZATION],
  77. [
  78. AC_MSG_CHECKING([for optimization flags])
  79. AC_ARG_ENABLE(optimization,[ --enable-optimization=[[0,1,2,3,4]] Select optimization level (default=2)],[
  80. optimization=$enableval
  81. ],[
  82. optimization="2"
  83. ])
  84. optimization_flags=''
  85. case "$optimization" in
  86. 0|no) optimization_flags="-O0";;
  87. 1) optimization_flags="-O1";;
  88. 2|yes) optimization_flags="-O2";;
  89. pass1) optimization_flags="-O2 -fprofile-arcs";;
  90. pass2) optimization_flags="-O2 -fbranch-probabilities";;
  91. 3) optimization_flags="-O3";;
  92. *) optimization_flags="-O4";;
  93. esac
  94. CXXFLAGS="`echo $CXXFLAGS | sed 's:-O.::g'` $optimization_flags"
  95. CFLAGS="`echo $CFLAGS | sed 's:-O.::g'` $optimization_flags"
  96. AC_MSG_RESULT([$optimization_flags])
  97. ])
  98. AC_DEFUN([AC_ARG_PROFILE_ARCS],
  99. [
  100. AC_MSG_CHECKING([for arc profiling])
  101. AC_ARG_ENABLE(profile-arcs,[ --enable-profile-arcs Enable arc profiling],[
  102. profile_arcs=$enableval
  103. ],[
  104. profile_arcs=no
  105. ])
  106. if test $profile_arcs = "yes" ; then {
  107. CXXFLAGS="$CXXFLAGS -fprofile-arcs";
  108. CFLAGS="$CFLAGS -fprofile-arcs";
  109. } ; fi
  110. AC_MSG_RESULT([$profile_arcs])
  111. ])
  112. AC_DEFUN([AC_ARG_BRANCH_PROBABILITIES],
  113. [
  114. AC_MSG_CHECKING([for branch-probabilities])
  115. AC_ARG_ENABLE(branch-probabilities,[ --enable-branch-probabilities Enable branch-probabilities],[
  116. branch_probabilities=$enableval
  117. ],[
  118. branch_probabilities=no
  119. ])
  120. if test $branch_probabilities = "yes" ; then {
  121. CXXFLAGS="$CXXFLAGS -fbranch-probabilities";
  122. CFLAGS="$CFLAGS -fbranch-probabilities";
  123. } ; fi
  124. AC_MSG_RESULT([$branch_probabilities])
  125. ])
  126. AC_DEFUN([AC_ARG_PROFILING],
  127. [
  128. AC_MSG_CHECKING([for profiling])
  129. AC_ARG_ENABLE(profiling,[ --enable-profiling Enable profiling using gprof],[
  130. profiling=$enableval
  131. ],[
  132. profiling=no
  133. ])
  134. if test $profiling = "yes" ; then {
  135. CFLAGS="$CFLAGS -pg";
  136. CXXFLAGS="$CXXFLAGS -pg";
  137. LDFLAGS="$LDFLAGS -pg";
  138. LIBS="$LIBS";
  139. } ; fi
  140. AC_MSG_RESULT([$profiling])
  141. ])
  142. MINGW_FLAGS="-mno-cygwin"
  143. AC_DEFUN([AC_WIN32_QUIRKS],
  144. [
  145. case "$host" in
  146. *mingw*)
  147. AC_MSG_CHECKING([the flavor of the compiler])
  148. if ( $CC --version | grep -q mingw ) ; then {
  149. AC_MSG_RESULT([compiler is mingw special])
  150. LIBTOOL_PATCH_SED="
  151. s/dir=\"\$absdir\"/dir=\`cygpath -d -m \"\$absdir\"\`/;
  152. s/absdir=\`cd \"\$dir\" && pwd\`/absdir=\`cygpath -d -m \"\$dir\"\`/;
  153. s/# We need an absolute path/dir=\`cygpath -d -m \"\$dir\"\` # We need an absolute path/;
  154. s- /usr/lib- C:/mingw/lib-g;
  155. s-\"/lib -\"C:/mingw/lib -g;
  156. s- /lib/ - -g;
  157. ";
  158. sys_lib_dlsearch_path_spec="C:/mingw/lib"
  159. ac_default_prefix=`cygpath -d -m "$ac_default_prefix"`;
  160. } else {
  161. AC_MSG_RESULT([compiler is cygwin stock, adding -mno-cygwin])
  162. CPP="$CPP $MINGW_FLAGS"
  163. CC="$CC $MINGW_FLAGS"
  164. CXX="$CXX $MINGW_FLAGS -L/usr/$host/lib -I/usr/include/c++/3.3.3/$host"
  165. CXXCPP="$CXXCPP $MINGW_FLAGS"
  166. } ; fi
  167. LTCC="gcc"
  168. CXXFLAGS="$CXXFLAGS -Wno-cpp -LC:/GTK/lib"
  169. CFLAGS="$CFLAGS -LC:/GTK/lib"
  170. LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols -Wl,--subsystem=windows -Wl,--enable-runtime-pseudo-reloc"
  171. dnl LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console -Wl,--enable-runtime-pseudo-reloc"
  172. ;;
  173. *cygwin*)
  174. LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols"
  175. dnl LDFLAGS="$LDFLAGS -lole32 -Wl,-no-undefined -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--subsystem=console"
  176. CXXFLAGS="$CXXFLAGS -I/target/include"
  177. CFLAGS="$CFLAGS -I/target/include"
  178. ;;
  179. powerpc-apple*)
  180. echo Adding mac-specific optimization flags. . .
  181. CXXFLAGS="$CXXFLAGS $G5OPTFLAGS"
  182. ;;
  183. esac
  184. ])
  185. AC_DEFUN([AC_LIBTOOL_PATCH],
  186. [
  187. if [[ "$LIBTOOL_PATCH_SED""x" != "x" ]] ; then {
  188. printf "Patching libtool... "
  189. cat libtool | sed "$LIBTOOL_PATCH_SED" > libtool2
  190. rm libtool
  191. mv libtool2 libtool
  192. chmod +x libtool
  193. AC_MSG_RESULT([patched])
  194. } fi ;
  195. ])