tools.m4 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_GCC3DEP],[
  90. AC_MSG_CHECKING(if $CXX -MD works)
  91. touch gcc3dep.cc
  92. ${CXX-c++} -MD -o gcc3dep_test.o -c gcc3dep.cc
  93. rm -f gcc3dep.cc gcc3dep_test.o
  94. if test -e gcc3dep.d; then
  95. rm -f gcc3dep.d
  96. GCC_MD=input
  97. GCC3DEP=
  98. elif test -e gcc3dep_test.d; then
  99. rm -f gcc3dep_test.d
  100. GCC_MD=output
  101. GCC3DEP=yes
  102. else
  103. AC_MSG_ERROR(no)
  104. fi
  105. AC_MSG_RESULT([yes, for $GCC_MD])
  106. AC_SUBST(GCC3DEP)
  107. ])