]> gitweb @ CieloNegro.org - autobuild.git/blob - src/main.bash
src/main.bash (install): wrong arguments for runMake
[autobuild.git] / src / main.bash
1 function runMake () {
2     run gmake -w -j $(detectNumCPUs) $@
3 }
4
5 function configure () {
6     if [[ ! -f configure.ac && ! -f configure.in ]]; then
7         echo "ERROR: Neither configure.ac nor configure.in exists in the current directory." >&2
8         return 1
9     fi
10
11     if [[ ! -f configure ]]; then
12         run autoreconf -v -i -f
13     fi
14
15     if [[ ! -f "_build/Makefile" ]]; then
16         run mkdir -p _build
17         run pushd _build
18         run ../configure "${configArgs[@]}"
19         run popd
20     fi
21 }
22
23 function build () {
24     configure
25     runMake -C "_build" $buildTarget
26 }
27
28 function doc () {
29     configure
30     runMake -C "_build/$docDirectory" $docTarget
31 }
32
33 function check () {
34     build
35     runMake -C "_build" check "$@"
36 }
37
38 function clean () {
39     run rm -rf "_build"
40 }
41
42 function dist () {
43     configure
44     runMake -C "_build" dist
45 }
46
47 function distcheck () {
48     configure
49     runMake -C "_build" distcheck
50 }
51
52 function install () {
53     build
54     runMake -C "_build" install "$@"
55 }
56
57 function usage () {
58     cat <<EOF >&2
59 Usage: $0 [COMMAND]
60
61 This is an automation script designed to work with autotools. It creates a
62 directory "./_build" and builds any files inside it. Its behaviour is
63 somewhat configurable: See "./Build.rc" for details.
64
65 If no COMMAND is given, it defaults to "build".
66
67 Commands:
68     build          run "$0 configure" then make(1)
69     check [ARG]    run "$0 build" then "make check [ARG]"
70     configure      run autoreconf(1) and "./configure" if necessary
71     clean          run "rm -rf _build"
72     dist           run "make dist"
73     distcheck      run "$0 configure" then "make distcheck"
74     doc            similar to "$0 build" but only build the documentation
75     help           print this message
76     install [ARG]  run "$0 build" then "make install [ARG]"
77
78 Please report any bugs, feature requests, and pull requests (the most
79 preferred!) to the maintainer presented in the preamble of the "$0" itself.
80 EOF
81     return 1
82 }
83
84 function main () {
85     local cmd
86     case "$1" in
87         ""|"build" ) cmd="build"    ;;
88         "configure") cmd="configure";;
89         "doc"      ) cmd="doc"      ;;
90         "check"    ) cmd="check"    ;;
91         "clean"    ) cmd="clean"    ;;
92         "dist"     ) cmd="dist"     ;;
93         "distcheck") cmd="distcheck";;
94         "help"     ) cmd="usage"    ;;
95         "install"  ) cmd="install"  ;;
96         *)           cmd="usage"    ;;
97     esac
98     if (( $# > 0 )); then
99         shift
100     fi
101     "$cmd" "$@"
102 }
103
104 main "$@"