1#!/bin/sh
2
3# build random configurations
4# Usage:
5# ARCH=i386 nohup ./extra/scripts/randconfig.sh & sleep 1800 && touch STOP
6#
7# The above builds random i386 configs and automatically stops after 30 minutes
8
9test "x$AWK" = "x" && AWK=awk
10test "x$ARCH" = "x" && ARCH=`uname -m`
11KCONFIG_ALLCONFIG=.config.allconfig
12(echo TARGET_$ARCH=y
13) > $KCONFIG_ALLCONFIG
14export KCONFIG_ALLCONFIG
15
16if test "x$NCPU" = "x"
17then
18  test -r /proc/cpuinfo && \
19  eval `$AWK 'BEGIN{NCPU=0}
20/processor/{let NCPU++}
21END{if (NCPU<1) {NCPU=1}; print("NCPU="NCPU);}' /proc/cpuinfo` || \
22  NCPU=1
23fi
24MAKELEVEL="-j$NCPU"
25i=0
26while test ! -f STOP
27do
28  ARCH=$ARCH make $* randconfig > /dev/null
29  ARCH=$ARCH make $* silentoldconfig > /dev/null
30  if (make $MAKELEVEL $*) 2>&1 >& mk.log
31  then
32    :
33  else
34    i=`expr $i + 1`
35    num=`printf "%.5d" $i`
36    mv .config FAILED.$num.config
37    mv mk.log FAILED.$num.log
38  fi
39  make distclean > /dev/null || true
40done
41rm -f STOP
42