subs.m4 6.2 KB

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