summaryrefslogtreecommitdiff
path: root/buildlib/tools.m4
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:55:23 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:55:23 +0000
commitf43579d10c48a2a21c8f418a2a1a7de118b52429 (patch)
treec216058162ad69f36957a47c1f8996ec1fe54476 /buildlib/tools.m4
parentc0f453871317ecccff95b132a093e30288555036 (diff)
Removed the tl_* macros, as dpkg doesn't use them, so w...
Author: doogie Date: 1999-12-10 03:20:21 GMT Removed the tl_* macros, as dpkg doesn't use them, so why should we? Added smp configure support detection, so on cpu >= 2, we compile in parallel. The default multiplier is 2(2 processes per cpu) on machines with more than one cpu. Non-smp boxen compile 1 process at a time.
Diffstat (limited to 'buildlib/tools.m4')
-rw-r--r--buildlib/tools.m4294
1 files changed, 69 insertions, 225 deletions
diff --git a/buildlib/tools.m4 b/buildlib/tools.m4
index 88a06dfab..de9c8a103 100644
--- a/buildlib/tools.m4
+++ b/buildlib/tools.m4
@@ -1,231 +1,75 @@
-# tl_CHECK_TOOL_PREFIX will work _BEFORE_ AC_CANONICAL_HOST, etc., has been
-# called. It should be called again after these have been called.
-#
-# Basically we want to check if the host alias specified by the user is
-# different from the build alias. The rules work like this:-
-#
-# If host is not specified, it defaults to NONOPT
-# If build is not specified, it defaults to NONOPT
-# If nonopt is not specified, we guess all other values
-
-dnl Replace AC_CHECK_TOOL_PREFIX
-undefine([AC_CHECK_TOOL_PREFIX])
-define([AC_CHECK_TOOL_PREFIX], [tl_CHECK_TOOL_PREFIX])
-
-AC_DEFUN(tl_CHECK_TOOL_PREFIX,
-[AC_PROVIDE([AC_CHECK_TOOL_PREFIX])
-AC_BEFORE([AC_CANONICAL_HOST])
-AC_BEFORE([AC_CANONICAL_BUILD])
-dnl Quick check
-if test "$host_alias" = ""; then
- if test $host = NONE; then
- thost=$nonopt
- else
- thost=$host
- fi
- if test $thost != $build -a $thost != NONE; then
- ac_tool_prefix=${thost}-
- ac_tool_dir=${thost}
- else
- ac_tool_prefix=
- ac_tool_dir=
- fi
-else
- if test $host != $build; then
- ac_tool_prefix=${host_alias}-
- ac_tool_dir=${host_alias}
- else
- ac_tool_prefix=
- ac_tool_dir=
- fi
-fi
-])
-
-dnl replacement for AC_CHECK_TOOL
-undefine([AC_CHECK_TOOL])
-define([AC_CHECK_TOOL], [tl_CHECK_TOOL($1, $2, $3, $4)])
-
-dnl tl_CHECK_TOOL - AC_CHECK_TOOL, with a couple of extra checks
-dnl tl_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH
-dnl [, REJECT]])
-AC_DEFUN(tl_CHECK_TOOL,
-[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
-AC_CHECK_PROG($1, ${ac_tool_prefix}$2, ${ac_tool_prefix}$2,
- ifelse([$3], , [$2], ), $4, $5)
-if test -z "$ac_cv_prog_$1_dir";then ac_cv_prog_$1_dir=""; fi
-if test "$ac_tool_dir" != ""; then
- if test -z "$ac_cv_prog_$1" -a "$5" != "/usr/${ac_tool_dir}/bin/$2" -a \
- "$5" != "/usr/local/${ac_tool_dir}/bin/$2"; then
- if test -f /usr/${ac_tool_dir}/bin/$2; then $1="/usr/${ac_tool_dir}/bin/$2"; ac_cv_prog_$1_dir=/usr/${ac_tool_dir}
- elif test -f /usr/local/${ac_tool_dir}/bin/$2; then $1="/usr/local/${ac_tool_dir}/bin/$2"; ac_cv_prog_$1_dir=/usr/local/${ac_tool_dir}
- fi
- fi
-fi
-ifelse([$3], , , [
-if test -z "$ac_cv_prog_$1"; then
-if test -n "$ac_tool_prefix"; then
- AC_CHECK_PROG($1, $2, $2, $3, $4, $5)
-else
- $1="$3"
-fi
-fi])
-])
-
-dnl tl_CHECK_TOOLS -
-dnl do a tl_CHECK_TOOL for multiple tools (like AC_CHECK_PROGS)
-dnl tl_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
-dnl [, PATH]])
-AC_DEFUN(tl_CHECK_TOOLS,
-[for ac_tool in $2
-do
-tl_CHECK_TOOL($1, [$]ac_tool, [$]ac_tool, , $4)
-test -n "[$]$1" && break
-done
-ifelse([$3], , , [test -n "[$]$1" || $1="$3"
-])])
-
-dnl replace AC_PROG_CC and AC_PROG_CXX
-undefine([AC_PROG_CC])
-define([AC_PROG_CC], [tl_PROG_CC])
-undefine([AC_PROG_CXX])
-define([AC_PROG_CXX], [tl_PROG_CXX])
-
-dnl tl_PROG_CC, tl_PROG_CXX - same as old AC_PROG_CC and AC_PROG_CXX, but
-dnl use AC_CHECK_TOOL/tl_CHECK_TOOLS instead of AC_CHECK_PROG, etc.
-AC_DEFUN(tl_PROG_CC,
-[AC_BEFORE([$0], [AC_PROG_CPP])dnl
-AC_PROVIDE([AC_PROG_CC])dnl
-tl_CHECK_TOOL(CC, gcc, gcc)
-if test -z "$CC"; then
- AC_CHECK_TOOL(CC, cc, cc, , , /usr/ucb/cc)
- test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
-fi
-if test -n "$ac_tool_prefix" -a "`echo $CC | grep '$ac_tool_prefix'`" = "" \
- -a "`echo $CC | grep -- '-b'`" = ""; then
- if test -z "$ac_cv_prog_CC_dir" && $CC -v 2>&1 | grep gcc >/dev/null 2>&1 ; then
- AC_CACHE_CHECK([if $CC -b${ac_tool_dir} works], tl_cv_prog_cc_bhost,[
- old_cc="${CC}"
- CC="${CC} -b${ac_tool_dir}"
- AC_LANG_SAVE
- AC_LANG_C
- AC_TRY_COMPILER([main(){return(0);}], tl_cv_prog_cc_bhost, ac_cv_prog_cc_cross)
- AC_LANG_RESTORE])
- if test $tl_cv_prog_cc_bhost = "yes"; then
- ac_cv_prog_cc_works=yes
- cctest=yes
- else
- CC="${old_cc}"
- fi
- fi
-fi
-
-if test "$cctest" != "yes"; then
- tl_PROG_CC_WORKS
-fi
-AC_PROG_CC_GNU
-
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
-dnl Check whether -g works, even if CFLAGS is set, in case the package
-dnl plays around with CFLAGS (such as to build both debugging and
-dnl normal versions of a library), tasteless as that idea is.
- ac_test_CFLAGS="${CFLAGS+set}"
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS=
- AC_PROG_CC_G
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
- elif test $ac_cv_prog_cc_g = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-O2"
- fi
-else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
-fi
+AC_DEFUN(ah_HAVE_GETCONF,
+ [AC_ARG_WITH(getconf,
+ [ --with-getconf Enable automagical buildtime configuration],
+ [if test "$withval" = "yes"; then
+ AC_PATH_PROG(GETCONF, getconf)
+ elif test ! "$withval" = "no";then
+ AC_MSG_CHECKING([getconf])
+ AC_MSG_RESULT([$withval])
+ GETCONF=$withval
+ fi],
+ [AC_PATH_PROG(GETCONF, getconf)]
+ )
+ AC_SUBST(GETCONF)
])
-AC_DEFUN(tl_PROG_CXX,
-[AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
-AC_PROVIDE([AC_PROG_CXX])dnl
-tl_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
-if test -n "$CXX"; then
- if test -n "$ac_tool_prefix" -a "`echo $CXX | grep '$ac_tool_prefix'`" = "" \
- -a "`echo $CXX | grep -- '-b'`" = ""; then
- if test -z "$ac_cv_prog_CXX_dir" && $CXX -v 2>&1 | grep gcc >/dev/null 2>&1; then
- AC_CACHE_CHECK([if $CXX -b${ac_tool_dir} works], tl_cv_prog_cxx_bhost,[
- old_cxx="${CXX}"
- CXX="${CXX} -b${ac_tool_dir}"
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_COMPILER([main(){return(0);}], tl_cv_prog_cxx_bhost, ac_cv_prog_cxx_cross)
- AC_LANG_RESTORE])
- if test $tl_cv_prog_cxx_bhost = "yes"; then
- ac_cv_prog_cxx_works=yes
- cxxtest=yes
- else
- CXX="${old_cxx}"
- fi
- fi
- fi
-
- if test "$cxxtest" != "yes"; then
- tl_PROG_CXX_WORKS
- fi
- AC_PROG_CXX_GNU
-
- if test $ac_cv_prog_gxx = yes; then
- GXX=yes
-dnl Check whether -g works, even if CXXFLAGS is set, in case the package
-dnl plays around with CXXFLAGS (such as to build both debugging and
-dnl normal versions of a library), tasteless as that idea is.
- ac_test_CXXFLAGS="${CXXFLAGS+set}"
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS=
- AC_PROG_CXX_G
- if test "$ac_test_CXXFLAGS" = set; then
- CXXFLAGS="$ac_save_CXXFLAGS"
- elif test $ac_cv_prog_cxx_g = yes; then
- CXXFLAGS="-g -O2"
- else
- CXXFLAGS="-O2"
- fi
- else
- GXX=
- test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
- fi
-fi
+AC_DEFUN(ah_NUM_CPUS,
+ [AC_REQUIRE([ah_HAVE_GETCONF])
+ AC_MSG_CHECKING([number of cpus])
+ AC_ARG_WITH(cpus,
+ [ --with-cpus The number of cpus to be used for building(see --with-procs, default 1)],
+ [if test "$withval" = "yes"; then
+ if test "$GETCONF";then
+ NUM_CPUS=`$GETCONF _NPROCESSORS_ONLN 2>/dev/null`
+ else
+ NUM_CPUS=1
+ fi
+ elif test ! "$withval" = "no";then
+ NUM_CPUS=$withval
+ fi],
+ [if test "$GETCONF";then
+ NUM_CPUS=`$GETCONF _NPROCESSORS_ONLN 2>/dev/null`
+ else
+ NUM_CPUS=1
+ fi]
+ )
+ if test $NUM_CPUS = 1 ;then
+ default_PROC_MULTIPLY=1
+ else
+ default_PROC_MULTIPLY=2
+ fi
+ AC_MSG_RESULT([$NUM_CPUS])
+ AC_SUBST(NUM_CPUS)
])
-
-AC_DEFUN(tl_PROG_CC_WORKS,
-[AC_PROVIDE(AC_PROG_CC_WORKS)
-AC_CACHE_CHECK([whether the C compiler ($CC $CFLAGS $LDFLAGS) works],
- ac_cv_prog_cc_works, [
-AC_LANG_SAVE
-AC_LANG_C
-AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
-AC_LANG_RESTORE
-if test $ac_cv_prog_cc_works = no; then
- AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.])
-fi])
-AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
-AC_MSG_RESULT($ac_cv_prog_cc_cross)
-cross_compiling=$ac_cv_prog_cc_cross
+AC_DEFUN(ah_PROC_MULTIPLY,
+ [AC_REQUIRE([ah_NUM_CPUS])
+ AC_MSG_CHECKING([processor multiplier])
+ AC_ARG_WITH(proc-multiply,
+ [ --with-proc-multiply Multiply this * number of cpus for parallel making(default 2).],
+ [if test "$withval" = "yes"; then
+ PROC_MULTIPLY=$default_PROC_MULTIPLY
+ elif test ! "$withval" = "no";then
+ PROC_MULTIPLY=$withval
+ fi],
+ [PROC_MULTIPLY=$default_PROC_MULTIPLY]
+ )
+ AC_MSG_RESULT([$PROC_MULTIPLY])
+ AC_SUBST(PROC_MULTIPLY)
])
-AC_DEFUN(tl_PROG_CXX_WORKS,
-[AC_PROVIDE(AC_PROG_CXX_WORKS)
-AC_CACHE_CHECK([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works],
- ac_cv_prog_cxx_works, [
-AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
-AC_LANG_RESTORE
-if test $ac_cv_prog_cxx_works = no; then
- AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
-fi])
-AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
-AC_MSG_RESULT($ac_cv_prog_cxx_cross)
-cross_compiling=$ac_cv_prog_cxx_cross
+AC_DEFUN(ah_NUM_PROCS,
+ [AC_REQUIRE([ah_PROC_MULTIPLY])
+ AC_REQUIRE([ah_NUM_CPUS])
+ AC_MSG_CHECKING([number of processes to run during make])
+ AC_ARG_WITH(procs,
+ [ --with-procs The number of processes to run in parallel during make(num_cpus * multiplier).],
+ [if test "$withval" = "yes"; then
+ let "NUM_PROCS=$NUM_CPUS*$PROC_MULTIPLY"
+ elif test ! "$withval" = "no";then
+ NUM_PROCS=$withval
+ fi],
+ [let "NUM_PROCS=$NUM_CPUS*$PROC_MULTIPLY"]
+ )
+ AC_MSG_RESULT([$NUM_PROCS])
+ AC_SUBST(NUM_PROCS)
])