bootstrap
[oweals/gnunet.git] / bootstrap
1 #!/bin/sh
2 # This file is in the public domain.
3
4 # We can't set -eu because we encounter warnings which
5 # result in stops, whereas the warnings can for now be
6 # safely ignored.
7 # set -eu
8
9 cleanup()
10 {
11     echo "Removing folder 'libltdl'..."
12     rm -rf libltdl
13 }
14
15 # This is more portable than `which' but comes with
16 # the caveat of not(?) properly working on busybox's ash:
17 existence()
18 {
19     command -v "$1" >/dev/null 2>&1
20 }
21
22 check_uncrustify()
23 {
24     if existence uncrustify; then
25         echo "Installing uncrustify hook and configuration"
26         # Install uncrustify format symlink (if possible)
27         ln -s contrib/uncrustify.cfg uncrustify.cfg 2> /dev/null
28         # Install pre-commit hook (if possible)
29         ln -s ../../contrib/uncrustify_precommit .git/hooks/pre-commit 2> /dev/null
30     else
31         echo "Uncrustify not detected, hook not installed."
32         echo "Please install uncrustify if you plan on doing development"
33     fi
34 }
35
36 # yapf can be a suffixed binary, don't change the essential logic
37 # of this if you change it.
38 check_yapf()
39 {
40     if existence yapf || \
41             existence yapf3.0 || \
42             existence yapf3.1 || \
43             existence yapf3.2 || \
44             existence yapf3.3 || \
45             existence yapf3.4 || \
46             existence yapf3.5 || \
47             existence yapf3.6 || \
48             existence yapf3.7 || \
49             existence yapf3.8 || \
50             existence yapf3.9 || \
51             existence yapf4.0; then
52         echo "Installing yapf symlink"
53         ln -s contrib/conf/.style.yapf 2> /dev/null
54     else
55         echo "yapf not detected, please install yapf if you plan on contributing python code"
56     fi
57 }
58
59 check_libtool()
60 {
61     echo "checking for libtoolize / libtool... "
62
63     if existence libtool || \
64             existence libtoolize || \
65             existence glibtoolize || \
66             existence slibtool; then
67         autoreconf -if
68         . "bin/pogen.sh"
69     else
70         echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2;
71         exit 1
72     fi
73 }
74
75 main()
76 {
77     cleanup
78     sleep 1
79     check_uncrustify
80     sleep 1
81     check_yapf
82     sleep 1
83     check_libtool
84 }
85
86 main "$@"