1 AC_DEFUN(ah_HAVE_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])
11 [AC_PATH_PROG(GETCONF, getconf)]
16 dnl ah_GET_CONF(variable, value ..., [default])
17 AC_DEFUN(ah_GET_GETCONF,
18 [AC_REQUIRE([ah_HAVE_GETCONF])
19 if test ! -z "$GETCONF";then
22 while eval test -z \"\$$1\" -a ! -z \"[$]1\";do
23 eval $1=`$GETCONF "[$]1" 2>/dev/null`
27 if eval test -z \"\$$1\" -o \"\$$1\" = "-1";then
32 [AC_MSG_CHECKING([number of cpus])
34 [ --with-cpus The number of cpus to be used for building(see --with-procs, default 1)],
36 if test "$withval" = "yes"; then
37 ah_GET_GETCONF(NUM_CPUS, SC_NPROCESSORS_ONLN _NPROCESSORS_ONLN, 1)
38 elif test ! "$withval" = "no";then
40 elif test "$withval" = "no";then
43 [ah_GET_GETCONF(NUM_CPUS, SC_NPROCESSORS_ONLN _NPROCESSORS_ONLN, 1)]
45 ah_NUM_CPUS_msg="$NUM_CPUS"
46 if test "$NUM_CPUS" = "0"; then
47 # broken getconf, time to bitch.
48 ah_NUM_CPUS_msg="found 0 cpus. Has someone done a lobotomy?"
51 if test $NUM_CPUS = 1 ;then
52 default_PROC_MULTIPLY=1
54 default_PROC_MULTIPLY=2
56 AC_MSG_RESULT([$ah_NUM_CPUS_msg])
59 AC_DEFUN(ah_PROC_MULTIPLY,
60 [AC_REQUIRE([ah_NUM_CPUS])
61 AC_MSG_CHECKING([processor multiplier])
62 AC_ARG_WITH(proc-multiply,
63 [ --with-proc-multiply Multiply this * number of cpus for parallel making(default 2).],
64 [if test "$withval" = "yes"; then
65 PROC_MULTIPLY=$default_PROC_MULTIPLY
66 elif test ! "$withval" = "no";then
67 PROC_MULTIPLY=$withval
69 [PROC_MULTIPLY=$default_PROC_MULTIPLY]
71 AC_MSG_RESULT([$PROC_MULTIPLY])
72 AC_SUBST(PROC_MULTIPLY)
75 AC_DEFUN(ah_NUM_PROCS,
76 [AC_REQUIRE([ah_PROC_MULTIPLY])
77 AC_REQUIRE([ah_NUM_CPUS])
78 AC_MSG_CHECKING([number of processes to run during make])
80 [ --with-procs The number of processes to run in parallel during make(num_cpus * multiplier).],
81 [if test "$withval" = "yes"; then
82 NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`
83 elif test ! "$withval" = "no";then
86 [NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`]
88 AC_MSG_RESULT([$NUM_PROCS])
92 AC_DEFUN(ah_GLIBC_VER,
93 [AC_MSG_CHECKING([glibc version])
95 cat <<_GLIBC_>$dummy.c
99 int main(int argc, char **argv) { printf("libc6.%d",__GLIBC_MINOR__); exit(0); }
101 ${CC-cc} $dummy.c -o $dummy > /dev/null 2>&1
102 if test "$?" = 0; then
104 AC_MSG_RESULT([$GLIBC_VER])
105 GLIBC_VER="-$GLIBC_VER"
107 AC_MSG_WARN([cannot determine GNU C library minor version number])
109 rm -f $dummy $dummy.c
113 AC_DEFUN(ah_LIBSTDCPP_VER,
114 [AC_MSG_CHECKING([libstdc++ version])
116 cat <<_LIBSTDCPP_>$dummy.cc
117 #include <features.h>
120 int main(int argc, char **argv) { exit(0); }
122 ${CXX-c++} $dummy.cc -o $dummy > /dev/null 2>&1
124 if test "$?" = 0; then
125 soname=`objdump -p ./$dummy |grep NEEDED|grep libstd`
126 LIBSTDCPP_VER=`echo $soname | sed -e 's/.*NEEDED.*libstdc++\(-libc.*\(-.*\)\)\?.so.\(.*\)/\3\2/'`
128 rm -f $dummy $dummy.cc
130 if test -z "$LIBSTDCPP_VER"; then
131 AC_MSG_WARN([cannot determine standard C++ library version number])
133 AC_MSG_RESULT([$LIBSTDCPP_VER])
134 LIBSTDCPP_VER="-$LIBSTDCPP_VER"
136 AC_SUBST(LIBSTDCPP_VER)