]> git.ipfire.org Git - thirdparty/squid.git/blame - test-suite/buildtest.sh
SourceFormat Enforcement
[thirdparty/squid.git] / test-suite / buildtest.sh
CommitLineData
3148fdf1 1#!/bin/sh
bea1ee2e 2#
bde978a6 3## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4e0938ef
AJ
4##
5## Squid software is distributed under GPLv2+ license and includes
6## contributions from numerous individuals and organizations.
7## Please see the COPYING and CONTRIBUTORS files for details.
8##
9
bea1ee2e
AJ
10# Configure and run a test build against any given set of configure options
11# or compile-time flags.
12#
13# Should be run from the source package root directory with paths relative to there.
14#
15
bc3d3d8c
AJ
16config="${1}"
17base="`dirname ${0}`"
bea1ee2e 18
8182d08a
FC
19# cache_file may be set by environment variable
20configcache=""
21if [ -n "$cache_file" ]; then
22 configcache="--cache-file=$cache_file"
23fi
24
16c198db 25#if we are on Linux, let's try parallelizing
b890da41 26if [ -z "$pjobs" -a -e /proc/cpuinfo ]; then
16c198db 27 ncpus=`grep '^processor' /proc/cpuinfo | tail -1|awk '{print $3}'`
bc3d3d8c
AJ
28 ncpus=`expr ${ncpus} + 1`
29 pjobs="-j${ncpus}"
16c198db 30fi
b890da41
FC
31#if we are on FreeBSD, let's try parallelizing
32if [ -z "$pjobs" -a -x /sbin/sysctl ]; then
33 ncpus=`sysctl kern.smp.cpus | cut -f2 -d" "`
ff2167f5 34 if [ $? -eq 0 -a -n "$ncpus" -a "$ncpus" -gt 1 ]; then
b890da41
FC
35 pjobs="-j${ncpus}"
36 fi
37fi
16c198db 38
bc3d3d8c
AJ
39if test -e ${config} ; then
40 echo "BUILD: ${config}"
41 . ${config}
bea1ee2e 42else
bc3d3d8c
AJ
43 echo -n "BUILD ERROR: Unable to locate test configuration '${config}' from " && pwd
44 exit 1;
bea1ee2e
AJ
45fi
46
47#
48# empty all the existing code, reconfigure and builds test code
e6f9e7b9 49# but skip if we have no files to remove.
e6f9e7b9 50FILECOUNT=`ls -1 | grep -c .`
bc3d3d8c 51if test "${FILECOUNT}" != "0" ; then
b01023dc 52 ${MAKE:-make} -k distclean || echo "distclean done. errors are unwanted but okay here."
0039f2b3
AJ
53 ls -la .
54 rm -fr ./src/fs/aufs/.deps src/fs/diskd/.deps
e6f9e7b9 55fi
bea1ee2e
AJ
56
57#
58# above command currently encounters dependancy problems on cleanup.
59#
701fabcc 60# do not build any of the install's ...
4fe75473
FC
61#
62# eval is need to correctly handle quoted arguments
a3abddfd 63 eval "$base/../configure ${DISTCHECK_CONFIGURE_FLAGS} ${configcache}" \
4fe75473 64 2>&1 && \
b01023dc 65 ${MAKE:-make} ${pjobs} ${MAKETEST} 2>&1
bea1ee2e 66
701fabcc
AR
67# Remember and then explicitly return the result of the last command
68# to the script caller. Probably not needed on most or all platforms.
69result=$?
70exit ${result}