Project

General

Profile

1
#!/bin/bash
2
# Runs a make target on all inputs at once.
3
# Creates a job in the calling shell for each process.
4

    
5
with_all_main ()
6
{
7
    local self="${BASH_SOURCE[0]}"
8
    local selfDir="$(dirname -- "$self")"
9
    
10
    # Was run without initial ".", or with insufficient parameters
11
    if test "${BASH_LINENO[1]}" = 0 -o "$#" -lt 1; then
12
        echo "Usage: . $self make_target (note initial \".\")"|fold -s >&2
13
        return 2
14
    fi
15
    
16
    for input in inputs/*/; do
17
        eval "make ${input}$1 &"
18
        disown -h "$(jobs|tail -1|"$selfDir/jobspecs")" # ignore SIGHUP
19
        sleep 2 # wait for initial output so that outputs don't become jumbled
20
    done
21
}
22
with_all_main "$@"
(44-44/46)