Debian Codegraph @

platform/unix/automagic

raw
1 #!/bin/bash
2
3 log() {
4 echo "[automagic] " $@
5 }
6
7 die() {
8 log "Fatal: "$@
9 exit 1
10 }
11
12 if [[ ! -d platform/unix ]]; then
13 log "Can't find the 'plaform/unix' folder, make sure you run this from the root of the repository."
14 exit 1
15 fi
16
17 AUTOHEADER=${AUTOHEADER:-$(which autoheader)}
18 AUTOCONF=${AUTOCONF:-$(which autoconf)}
19 LIBTOOLIZE=${LIBTOOLIZE:-$(which libtoolize)}
20 ACLOCAL=${ACLOCAL:-$(which aclocal)}
21 AUTOMAKE=${AUTOMAKE:-$(which automake)}
22
23 [[ -x ${AUTOHEADER} ]] || die "Could not find autoheader. Install autoconf."
24 [[ -x ${AUTOCONF} ]] || die "Could not find autoconf."
25 [[ -x ${LIBTOOLIZE} ]] || die "Could not find libtoolize. Install libtool."
26 [[ -x ${ACLOCAL} ]] || die "Could not find aclocal. Install automake."
27 [[ -x ${AUTOMAKE} ]] || die "Could not find automake."
28
29 print_errors() {
30 local output
31 output="$("$@" 2>&1)" && return 0
32 printf "%s\n" "$output"
33 return 1
34 }
35
36 automagic() {
37 log "Copying files..."
38 cp platform/unix/configure.ac .
39 cp platform/unix/Makefile.am .
40
41 log "Running genmodules..."
42 if ! print_errors bash platform/unix/genmodules "$1"; then
43 echo "You should be doing this from the root directory of the project."
44 exit 1
45 fi
46
47 log "Running autoheader..."
48 print_errors ${AUTOHEADER} || return 1 # Gimmie config.h.in
49
50 log "Running libtoolize..."
51 print_errors ${LIBTOOLIZE} --force || return 1
52
53 log "Running aclocal..."
54 print_errors ${ACLOCAL} || return 1
55
56 log "Running autoconf..."
57 print_errors ${AUTOCONF} || return 1
58
59 log "Running automake..."
60 print_errors ${AUTOMAKE} -a || return 1
61 }
62
63 automagic "$@"
64
65 if [[ $? -eq 1 ]]; then
66 log "Failed, sadface."
67 log "This is generally a configuration error (I'm looking at you aclocal)"
68 exit 1
69 else
70 log "Success, carry on configuring."
71 fi