-remove debug message
[oweals/gnunet.git] / bootstrap
1 #!/bin/sh
2 #
3 # We should use /usr/bin/env sh, but some systems are notoriously picky.
4 # In fact we could ommit this line if some automations wouldn't rely on
5 # running this file via ./bootstrap.
6 #
7 # This file is in the public domain.
8 # SPDX-License-Identifier: 0BSD
9 #
10 # We can't set -eu because we encounter warnings which
11 # result in stops, whereas the warnings can for now be
12 # safely ignored.
13 # set -eu
14
15 cleanup()
16 {
17     echo "Removing folder 'libltdl'..."
18     rm -rf libltdl
19 }
20
21 errmsg=''
22
23 # Check if shell supports builtin 'type'.
24 if test -z "$errmsg"; then
25     if ! (eval 'type type') >/dev/null 2>&1
26     then
27         errmsg='Shell does not support type builtin'
28         exit 1
29     fi
30 fi
31
32 # This is more portable than `which' but comes with
33 # the caveat of not(?) properly working on busybox's ash:
34 existence()
35 {
36     type "$1" >/dev/null 2>&1
37 }
38
39 check_uncrustify()
40 {
41     if existence uncrustify; then
42         echo "Installing uncrustify hook and configuration"
43         ln -fs contrib/build-common/conf/uncrustify.cfg uncrustify.cfg 2> /dev/null
44         ln -fs contrib/build-common/conf/uncrustify_precommit .git/hooks/pre-commit 2> /dev/null
45     else
46         echo "Uncrustify not detected, hook not installed."
47         echo "Please install uncrustify if you plan on doing development"
48     fi
49 }
50
51 # yapf can be a suffixed binary, don't change the essential logic
52 # of this if you change it.
53 check_yapf()
54 {
55     if existence yapf || \
56        existence yapf3.0 || \
57        existence yapf3.1 || \
58        existence yapf3.2 || \
59        existence yapf3.3 || \
60        existence yapf3.4 || \
61        existence yapf3.5 || \
62        existence yapf3.6 || \
63        existence yapf3.7 || \
64        existence yapf3.8 || \
65        existence yapf3.9 || \
66        existence yapf4.0; then
67         echo "Installing yapf symlink"
68         ln -fs contrib/build-common/conf/.style.yapf .style.yapf 2> /dev/null
69     else
70         echo "yapf not detected, please install yapf if you plan on contributing python code"
71     fi
72 }
73
74 check_libtool()
75 {
76     echo "checking for libtoolize / libtool... "
77
78     if existence libtool || \
79        existence libtoolize || \
80        existence glibtoolize || \
81        existence slibtool; then
82         autoreconf -if
83         . "bin/pogen.sh"
84     else
85         echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2;
86         exit 1
87     fi
88 }
89
90 submodules()
91 {
92     # Try to update the submodule. Since bootstrap
93     # is also invoked by distributors, we must
94     # ignore any failing of this function as we
95     # could have no outgoing network connection
96     # in a restricted environment.
97     if ! git --version >/dev/null; then
98         echo "git not installed, skipping submodule update"
99     else
100         git submodule update --init || true
101         git submodule update --recursive || true
102         git submodule sync || true
103     fi
104 }
105
106 init_buildcommon_include()
107 {
108     cp contrib/build-common/Makefile.inc contrib/Makefile.inc || true
109 }
110
111 main()
112 {
113     cleanup
114     submodules
115     init_buildcommon_include
116     check_uncrustify
117     check_yapf
118     check_libtool
119 }
120
121 main "$@"