tools.m4 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. AC_DEFUN(ah_NUM_CPUS,
  16. [AC_REQUIRE([ah_HAVE_GETCONF])
  17. AC_MSG_CHECKING([number of cpus])
  18. NUM_CPUS=
  19. AC_ARG_WITH(cpus,
  20. [ --with-cpus The number of cpus to be used for building(see --with-procs, default 1)],
  21. [if test "$withval" = "yes"; then
  22. if test ! -z "$GETCONF";then
  23. NUM_CPUS=`$GETCONF _NPROCESSORS_ONLN 2>/dev/null`
  24. fi
  25. elif test ! "$withval" = "no";then
  26. NUM_CPUS=$withval
  27. fi],
  28. [if test ! -z "$GETCONF";then
  29. NUM_CPUS=`$GETCONF _NPROCESSORS_ONLN 2>/dev/null`
  30. fi]
  31. )
  32. if test -z "$NUM_CPUS"; then
  33. NUM_CPUS=1
  34. fi
  35. if test $NUM_CPUS = 1 ;then
  36. default_PROC_MULTIPLY=1
  37. else
  38. default_PROC_MULTIPLY=2
  39. fi
  40. AC_MSG_RESULT([$NUM_CPUS])
  41. AC_SUBST(NUM_CPUS)
  42. ])
  43. AC_DEFUN(ah_PROC_MULTIPLY,
  44. [AC_REQUIRE([ah_NUM_CPUS])
  45. AC_MSG_CHECKING([processor multiplier])
  46. AC_ARG_WITH(proc-multiply,
  47. [ --with-proc-multiply Multiply this * number of cpus for parallel making(default 2).],
  48. [if test "$withval" = "yes"; then
  49. PROC_MULTIPLY=$default_PROC_MULTIPLY
  50. elif test ! "$withval" = "no";then
  51. PROC_MULTIPLY=$withval
  52. fi],
  53. [PROC_MULTIPLY=$default_PROC_MULTIPLY]
  54. )
  55. AC_MSG_RESULT([$PROC_MULTIPLY])
  56. AC_SUBST(PROC_MULTIPLY)
  57. ])
  58. AC_DEFUN(ah_NUM_PROCS,
  59. [AC_REQUIRE([ah_PROC_MULTIPLY])
  60. AC_REQUIRE([ah_NUM_CPUS])
  61. AC_MSG_CHECKING([number of processes to run during make])
  62. AC_ARG_WITH(procs,
  63. [ --with-procs The number of processes to run in parallel during make(num_cpus * multiplier).],
  64. [if test "$withval" = "yes"; then
  65. NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`
  66. elif test ! "$withval" = "no";then
  67. NUM_PROCS=$withval
  68. fi],
  69. [NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`]
  70. )
  71. AC_MSG_RESULT([$NUM_PROCS])
  72. AC_SUBST(NUM_PROCS)
  73. ])