Today, Ralf Corsepius wrote:
>I.e. instead of trying to detect the number of processes, I'd recommend
>to tell users to run
>make -j <what-the-user-wants>
I agree, in general, but it might be nice to add the support as an option
(see attached).
Note that the attached macro doesn't enable parallel building as yet -- I
don't know enough of make on different systems to be able to check for
parallel build capabilities so someone who does will have to do that.
Regards,
Philip Willoughby
Systems Programmer, Department of Computing, Imperial College, London, UK
--
echo [EMAIL PROTECTED] | tr "bizndfohces" "pwgd9ociaku"
AC_DEFUN([AC_PROG_MAKE_PARALLEL], [
AC_ARG_WITH(parallel-build,
[ --with-parallel-build=[[n]]
Enable parallel build. n is number of cpus.],
if [[[[ x${withval} == xyes ]]]] ; then
AC_MSG_CHECKING([[how many cpus for parallel build]])
cat > conftest.c <<EOF
[#]ifdef _WIN32
[#]define WIN32_LEAN_AND_MEAN
[#]include <windows.h>
[#]else
[#]include <unistd.h>
[#]endif
[#]include <stdio.h>
int main() {
long nprocs = -1;
[#]ifdef _WIN32
SYSTEM_INFO info;
[#]endif
[#]ifdef _SC_NPROCESSORS_ONLN
nprocs = sysconf(_SC_NPROCESSORS_ONLN);
[#]elif defined _SC_NPROC_ONLN
nprocs = sysconf(_SC_NPROC_ONLN);
[#]elif defined _SC_CRAY_NCPU
nprocs = sysconf(_SC_CRAY_NCPU);
[#]elif defined _WIN32
GetSystemInfo(&info);
nprocs = info.dwNumberOfProcessors;
[#]endif
if (nprocs < 1)
nprocs = 1;
printf ("%ld\n", nprocs);
}
EOF
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}
then
PROG_MAKE_PARALLEL_NCPUS="`./conftest${ac_exeext}`"
export PROG_MAKE_PARALLEL_NCPUS
else
echo "configure: failed program was:" >&AC_FD_CC
cat conftest.$ac_ext >&AC_FD_CC
ifelse([$3], , , [ rm -fr conftest*
$3
])dnl
PROG_MAKE_PARALLEL_NCPUS=1
export PROG_MAKE_PARALLEL_NCPUS
fi
rm -fr conftest*
AC_MSG_RESULT([[$PROG_MAKE_PARALLEL_NCPUS]])
elif [[[[ x${withval} != xno ]]]] ; then
PROG_MAKE_PARALLEL_NCPUS=${withval}
export PROG_MAKE_PARALLEL_NCPUS
fi
# Someone not me needs to add the code to check if make -j works here and
# change the make flags appropriately, of course
)])