tools.m4 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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(ah_GLIBC_VER,
  90. [AC_MSG_CHECKING([glibc version])
  91. dummy=if$$
  92. cat <<_GLIBC_>$dummy.c
  93. #include <features.h>
  94. #include <stdio.h>
  95. int main(int argc, char **argv) { printf("libc6.%d",__GLIBC_MINOR__); exit(0); }
  96. _GLIBC_
  97. ${CC-cc} $dummy.c -o $dummy
  98. if test "$?" = 0; then
  99. GLIBC_VER=`./$dummy`
  100. AC_MSG_RESULT([$GLIBC_VER])
  101. GLIBC_VER="-$GLIBC_VER"
  102. else
  103. AC_MSG_WARN([cannot determine GNU C library minor version number])
  104. fi
  105. rm -f $dummy $dummy.c
  106. AC_SUBST(GLIBC_VER)
  107. ])
  108. AC_DEFUN(ah_LIBSTDCPP_VER,
  109. [AC_MSG_CHECKING([libstdc++ version])
  110. dummy=if$$
  111. cat <<_LIBSTDCPP_>$dummy.cc
  112. #include <features.h>
  113. #include <stdio.h>
  114. int main(int argc, char **argv) { exit(0); }
  115. _LIBSTDCPP_
  116. ${CXX-c++} $dummy.cc -o $dummy
  117. if test "$?" = 0; then
  118. soname=`objdump -p ./$dummy |grep NEEDED|grep libstd`
  119. LIBSTDCPP_VER=`echo $soname | sed -e 's/.*NEEDED.*libstdc++-libc.*-\(.*\).so.\(.*\)/\2-\1/'`
  120. fi
  121. rm -f $dummy $dummy.cc
  122. if test -z "$LIBSTDCPP_VER"; then
  123. AC_MSG_WARN([cannot determine standard C++ library version number])
  124. else
  125. AC_MSG_RESULT([$LIBSTDCPP_VER])
  126. LIBSTDCPP_VER="-$LIBSTDCPP_VER"
  127. fi
  128. AC_SUBST(LIBSTDCPP_VER)
  129. ])