]> git.saurik.com Git - apt.git/blob - buildlib/tools.m4
* apt-pkg/acquire.cc:
[apt.git] / buildlib / tools.m4
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
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
20 old_args="[$]@"
21 set -- $2
22 while eval test -z \"\$$1\" -a ! -z \"[$]1\";do
23 eval $1=`$GETCONF "[$]1" 2>/dev/null`
24 shift
25 done
26 fi
27 if eval test -z \"\$$1\" -o \"\$$1\" = "-1";then
28 eval $1="$3"
29 fi
30 ])
31 AC_DEFUN(ah_NUM_CPUS,
32 [AC_MSG_CHECKING([number of cpus])
33 AC_ARG_WITH(cpus,
34 [ --with-cpus The number of cpus to be used for building(see --with-procs, default 1)],
35 [
36 if test "$withval" = "yes"; then
37 ah_GET_GETCONF(NUM_CPUS, SC_NPROCESSORS_ONLN _NPROCESSORS_ONLN, 1)
38 elif test ! "$withval" = "no";then
39 NUM_CPUS=$withval
40 elif test "$withval" = "no";then
41 NUM_CPUS=1
42 fi],
43 [ah_GET_GETCONF(NUM_CPUS, SC_NPROCESSORS_ONLN _NPROCESSORS_ONLN, 1)]
44 )
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?"
49 NUM_CPUS=1
50 fi
51 if test $NUM_CPUS = 1 ;then
52 default_PROC_MULTIPLY=1
53 else
54 default_PROC_MULTIPLY=2
55 fi
56 AC_MSG_RESULT([$ah_NUM_CPUS_msg])
57 AC_SUBST(NUM_CPUS)
58 ])
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
68 fi],
69 [PROC_MULTIPLY=$default_PROC_MULTIPLY]
70 )
71 AC_MSG_RESULT([$PROC_MULTIPLY])
72 AC_SUBST(PROC_MULTIPLY)
73 ])
74
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])
79 AC_ARG_WITH(procs,
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
84 NUM_PROCS=$withval
85 fi],
86 [NUM_PROCS=`expr $NUM_CPUS \* $PROC_MULTIPLY`]
87 )
88 AC_MSG_RESULT([$NUM_PROCS])
89 AC_SUBST(NUM_PROCS)
90 ])
91
92 AC_DEFUN(rc_GLIBC_VER,
93 [AC_MSG_CHECKING([glibc version])
94 AC_CACHE_VAL(ac_cv_glibc_ver,
95 dummy=if$$
96 cat <<_GLIBC_>$dummy.c
97 #include <features.h>
98 #include <stdio.h>
99 #include <stdlib.h>
100 int main(int argc, char **argv) { printf("libc6.%d",__GLIBC_MINOR__); exit(0); }
101 _GLIBC_
102 ${CC-cc} $dummy.c -o $dummy > /dev/null 2>&1
103 if test "$?" = 0; then
104 GLIBC_VER=`./$dummy`
105 AC_MSG_RESULT([$GLIBC_VER])
106 ac_cv_glibc_ver=$GLIBC_VER
107 else
108 AC_MSG_WARN([cannot determine GNU C library minor version number])
109 fi
110 rm -f $dummy $dummy.c
111 )
112 GLIBC_VER="-$ac_cv_glibc_ver"
113 AC_SUBST(GLIBC_VER)
114 ])
115
116 AC_DEFUN(rc_LIBSTDCPP_VER,
117 [AC_MSG_CHECKING([libstdc++ version])
118 dummy=if$$
119 cat <<_LIBSTDCPP_>$dummy.cc
120 #include <features.h>
121 #include <stdio.h>
122 #include <stdlib.h>
123 int main(int argc, char **argv) { exit(0); }
124 _LIBSTDCPP_
125 ${CXX-c++} $dummy.cc -o $dummy > /dev/null 2>&1
126
127 if test "$?" = 0; then
128 soname=`objdump -p ./$dummy |grep NEEDED|grep libstd`
129 LIBSTDCPP_VER=`echo $soname | sed -e 's/.*NEEDED.*libstdc++\(-libc.*\(-.*\)\)\?.so.\(.*\)/\3\2/'`
130 fi
131 rm -f $dummy $dummy.cc
132
133 if test -z "$LIBSTDCPP_VER"; then
134 AC_MSG_WARN([cannot determine standard C++ library version number])
135 else
136 AC_MSG_RESULT([$LIBSTDCPP_VER])
137 LIBSTDCPP_VER="-$LIBSTDCPP_VER"
138 fi
139 AC_SUBST(LIBSTDCPP_VER)
140 ])
141
142 AC_DEFUN(ah_GCC3DEP,[
143 AC_MSG_CHECKING(if $CXX -MD works)
144 touch gcc3dep.cc
145 ${CXX-c++} -MD -o gcc3dep_test.o -c gcc3dep.cc
146 rm -f gcc3dep.cc gcc3dep_test.o
147 if test -e gcc3dep.d; then
148 rm -f gcc3dep.d
149 GCC_MD=input
150 GCC3DEP=
151 elif test -e gcc3dep_test.d; then
152 rm -f gcc3dep_test.d
153 GCC_MD=output
154 GCC3DEP=yes
155 else
156 AC_MSG_ERROR(no)
157 fi
158 AC_MSG_RESULT([yes, for $GCC_MD])
159 AC_SUBST(GCC3DEP)
160 ])