tools.m4 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. AC_DEFUN(ah_HAVE_GETCONF,
  2. [AC_ARG_WITH(getconf,
  3. [ --with-getconf Enable automagical buildtime configuration],
  4. [if test "$withval" = "yes"; then
  5. AC_PATH_PROG(GETCONF, getconf)
  6. elif test ! "$withval" = "no";then
  7. AC_MSG_CHECKING([getconf])
  8. AC_MSG_RESULT([$withval])
  9. GETCONF=$withval
  10. fi],
  11. [AC_PATH_PROG(GETCONF, getconf)]
  12. )
  13. AC_SUBST(GETCONF)
  14. ])
  15. dnl ah_GET_CONF(variable, value ..., [default])
  16. AC_DEFUN(ah_GET_GETCONF,
  17. [AC_REQUIRE([ah_HAVE_GETCONF])
  18. if test ! -z "$GETCONF";then
  19. old_args="[$]@"
  20. set -- $2
  21. while eval test -z \"\$$1\" -a ! -z \"[$]1\";do
  22. eval $1=`$GETCONF "[$]1" 2>/dev/null`
  23. shift
  24. done
  25. fi
  26. if eval test -z \"\$$1\" -o \"\$$1\" = "-1";then
  27. eval $1="$3"
  28. fi
  29. ])
  30. AC_DEFUN(ah_NUM_CPUS,
  31. [AC_MSG_CHECKING([number of cpus])
  32. AC_ARG_WITH(cpus,
  33. [ --with-cpus The number of cpus to be used for building(see --with-procs, default 1)],
  34. [
  35. if test "$withval" = "yes"; then
  36. ah_GET_GETCONF(NUM_CPUS, SC_NPROCESSORS_ONLN _NPROCESSORS_ONLN, 1)
  37. elif test ! "$withval" = "no";then
  38. NUM_CPUS=$withval
  39. elif test "$withval" = "no";then
  40. NUM_CPUS=1
  41. fi],
  42. [ah_GET_GETCONF(NUM_CPUS, SC_NPROCESSORS_ONLN _NPROCESSORS_ONLN, 1)]
  43. )
  44. ah_NUM_CPUS_msg="$NUM_CPUS"
  45. if test "$NUM_CPUS" = "0"; then
  46. # broken getconf, time to bitch.
  47. ah_NUM_CPUS_msg="found 0 cpus. Has someone done a lobotomy?"
  48. NUM_CPUS=1
  49. fi
  50. if test $NUM_CPUS = 1 ;then
  51. default_PROC_MULTIPLY=1
  52. else
  53. default_PROC_MULTIPLY=2
  54. fi
  55. AC_MSG_RESULT([$ah_NUM_CPUS_msg])
  56. AC_SUBST(NUM_CPUS)
  57. ])
  58. AC_DEFUN(ah_PROC_MULTIPLY,
  59. [AC_REQUIRE([ah_NUM_CPUS])
  60. AC_MSG_CHECKING([processor multiplier])
  61. AC_ARG_WITH(proc-multiply,
  62. [ --with-proc-multiply Multiply this * number of cpus for parallel making(default 2).],
  63. [if test "$withval" = "yes"; then
  64. PROC_MULTIPLY=$default_PROC_MULTIPLY
  65. elif test ! "$withval" = "no";then
  66. PROC_MULTIPLY=$withval
  67. fi],
  68. [PROC_MULTIPLY=$default_PROC_MULTIPLY]
  69. )
  70. AC_MSG_RESULT([$PROC_MULTIPLY])
  71. AC_SUBST(PROC_MULTIPLY)
  72. ])
  73. AC_DEFUN(ah_NUM_PROCS,
  74. [AC_REQUIRE([ah_PROC_MULTIPLY])
  75. AC_REQUIRE([ah_NUM_CPUS])
  76. AC_MSG_CHECKING([number of processes to run during make])
  77. AC_ARG_WITH(procs,
  78. [ --with-procs The number of processes to run in parallel during make(num_cpus * multiplier).],
  79. [if test "$withval" = "yes"; then
  80. NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`
  81. elif test ! "$withval" = "no";then
  82. NUM_PROCS=$withval
  83. fi],
  84. [NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`]
  85. )
  86. AC_MSG_RESULT([$NUM_PROCS])
  87. AC_SUBST(NUM_PROCS)
  88. ])
  89. AC_DEFUN(rc_GLIBC_VER,
  90. [AC_MSG_CHECKING([glibc version])
  91. AC_CACHE_VAL(ac_cv_glibc_ver,
  92. dummy=if$$
  93. cat <<_GLIBC_>$dummy.c
  94. #include <features.h>
  95. #include <stdio.h>
  96. #include <stdlib.h>
  97. int main(int argc, char **argv) { printf("libc6.%d",__GLIBC_MINOR__); exit(0); }
  98. _GLIBC_
  99. ${CC-cc} $dummy.c -o $dummy > /dev/null 2>&1
  100. if test "$?" = 0; then
  101. GLIBC_VER=`./$dummy`
  102. AC_MSG_RESULT([$GLIBC_VER])
  103. ac_cv_glibc_ver=$GLIBC_VER
  104. else
  105. AC_MSG_WARN([cannot determine GNU C library minor version number])
  106. fi
  107. rm -f $dummy $dummy.c
  108. )
  109. GLIBC_VER="-$ac_cv_glibc_ver"
  110. AC_SUBST(GLIBC_VER)
  111. ])
  112. AC_DEFUN(rc_LIBSTDCPP_VER,
  113. [AC_MSG_CHECKING([libstdc++ version])
  114. dummy=if$$
  115. cat <<_LIBSTDCPP_>$dummy.cc
  116. #include <features.h>
  117. #include <stdio.h>
  118. #include <stdlib.h>
  119. int main(int argc, char **argv) { exit(0); }
  120. _LIBSTDCPP_
  121. ${CXX-c++} $dummy.cc -o $dummy > /dev/null 2>&1
  122. if test "$?" = 0; then
  123. soname=`objdump -p ./$dummy |grep NEEDED|grep libstd`
  124. LIBSTDCPP_VER=`echo $soname | sed -e 's/.*NEEDED.*libstdc++\(-libc.*\(-.*\)\)\?.so.\(.*\)/\3\2/'`
  125. fi
  126. rm -f $dummy $dummy.cc
  127. if test -z "$LIBSTDCPP_VER"; then
  128. AC_MSG_WARN([cannot determine standard C++ library version number])
  129. else
  130. AC_MSG_RESULT([$LIBSTDCPP_VER])
  131. LIBSTDCPP_VER="-$LIBSTDCPP_VER"
  132. fi
  133. AC_SUBST(LIBSTDCPP_VER)
  134. ])
  135. AC_DEFUN(ah_GCC3DEP,[
  136. AC_MSG_CHECKING(if $CXX -MD works)
  137. touch gcc3dep.cc
  138. ${CXX-c++} -MD -o gcc3dep_test.o -c gcc3dep.cc
  139. rm -f gcc3dep.cc gcc3dep_test.o
  140. if test -e gcc3dep.d; then
  141. rm -f gcc3dep.d
  142. GCC_MD=input
  143. GCC3DEP=
  144. elif test -e gcc3dep_test.d; then
  145. rm -f gcc3dep_test.d
  146. GCC_MD=output
  147. GCC3DEP=yes
  148. else
  149. AC_MSG_ERROR(no)
  150. fi
  151. AC_MSG_RESULT([yes, for $GCC_MD])
  152. AC_SUBST(GCC3DEP)
  153. ])