diff options
author | Evgeny Grin <k2k@narod.ru> | 2023-05-15 13:37:41 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2023-06-01 09:08:43 +0300 |
commit | 50e28fbb90706a255d006fcc1988546078d64dac (patch) | |
tree | a7281745ffec77daab81180657018bec015acd6b /bootstrap | |
parent | 31ce530d6b9757f5489aa943d53553dc8a045f20 (diff) | |
download | libmicrohttpd-50e28fbb90706a255d006fcc1988546078d64dac.tar.gz libmicrohttpd-50e28fbb90706a255d006fcc1988546078d64dac.zip |
bootstrap script: improved portability
Diffstat (limited to 'bootstrap')
-rwxr-xr-x | bootstrap | 64 |
1 files changed, 44 insertions, 20 deletions
@@ -1,40 +1,64 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | unset bs_srcdir | ||
3 | if test X"`dirname / 2>/dev/null`" = X"/"; then | ||
4 | bs_scrdir=`dirname $0` | ||
5 | else | ||
6 | bs_scrdir="${0%/*}" | ||
7 | fi | ||
8 | |||
9 | test -n "$bs_scrdir" && cd "$bs_scrdir" || echo "Warning: cannot get sources directory" 1>&2 | ||
10 | 2 | ||
11 | # This is more portable than `which' but comes with | 3 | # This is more portable than `which' but comes with |
12 | # the caveat of not(?) properly working on busybox's ash: | 4 | # the caveat of not(?) properly working on busybox's ash: |
13 | existence() | 5 | have_command() |
14 | { | 6 | { |
15 | command -v "$1" >/dev/null 2>&1 | 7 | command -v "$1" >/dev/null 2>&1 |
16 | } | 8 | } |
17 | 9 | ||
10 | unset bs_srcdir | ||
11 | if test X"`dirname / 2>/dev/null`" = X"/"; then | ||
12 | bs_scrdir=`dirname $0` | ||
13 | else | ||
14 | case $0 in | ||
15 | */*) bs_scrdir=`echo $0 | ${SED-sed} -n -e 's|/.*$||p'` ;; | ||
16 | *) bs_scrdir='.' ;; | ||
17 | esac | ||
18 | fi | ||
19 | |||
20 | test -n "$bs_scrdir" && cd "$bs_scrdir" || echo "Warning: cannot detect sources directory" 1>&2 | ||
21 | |||
22 | if test ! -f './configure.ac'; then | ||
23 | echo "Error: no 'configure.ac' found. Wrong sources directory?" 1>&2 | ||
24 | exit 2 | ||
25 | fi | ||
26 | if test ! -f './src/include/microhttpd.h'; then | ||
27 | echo "Error: src/include/libmicrohttpd.h not found. Wrong sources directory?" 1>&2 | ||
28 | exit 2 | ||
29 | fi | ||
18 | 30 | ||
19 | if existence uncrustify; then | 31 | if have_command uncrustify; then |
20 | echo "Installing uncrustify hook and configuration" | 32 | if test -f uncrustify.cfg; then |
21 | # Install uncrustify format symlink (if possible) | 33 | echo "Uncrustify configuration already exists, skipping installation from the upstream file." |
22 | ln -s contrib/uncrustify.cfg uncrustify.cfg 2> /dev/null | 34 | else |
23 | # Install pre-commit hook (if possible) | 35 | echo "Installing configuration" |
24 | ln -s ../../contrib/uncrustify_precommit .git/hooks/pre-commit 2> /dev/null | 36 | ln -s contrib/uncrustify.cfg uncrustify.cfg |
37 | fi | ||
38 | if test -d '.git'; then | ||
39 | if test -f .git/hooks/pre-commit; then | ||
40 | echo "Pre-commit git hook already exists, skipping installation from the upstream file." | ||
41 | else | ||
42 | echo "Installing uncrustify pre-commit git hook" | ||
43 | ln -s ../../contrib/uncrustify_precommit .git/hooks/pre-commit | ||
44 | fi | ||
45 | else | ||
46 | echo "No '.git' directory found, skipping installation of pre-commit git hook." | ||
47 | fi | ||
25 | else | 48 | else |
26 | echo "Uncrustify not detected, hook not installed. Please install uncrustify if you plan on doing development" | 49 | echo "Uncrustify not detected, hook not installed. Please install uncrustify if you plan on doing development." |
27 | fi | 50 | fi |
28 | 51 | ||
29 | if existence libtool || existence libtoolize || existence glibtoolize || existence slibtool; then | 52 | if have_command libtool || have_command libtoolize || have_command glibtoolize || have_command slibtool; then |
30 | echo "Running autotools..." | 53 | echo "Running autotools..." |
31 | aclocal -I m4 --install && \ | 54 | have_command libtoolize && \ |
55 | aclocal -I m4 --install && \ | ||
32 | libtoolize -c -i -v && \ | 56 | libtoolize -c -i -v && \ |
33 | autoconf && \ | 57 | autoconf && \ |
34 | autoheader && \ | 58 | autoheader && \ |
35 | automake -a -c --gnu | 59 | automake -a -c --gnu |
36 | if test $? -ne 0 || ! test -x configure || ! test -f Makefile.in ; then | 60 | if test $? -ne 0 || ! test -x configure || ! test -f Makefile.in ; then |
37 | echo "Autotools failed, retrying with autoreconf..." | 61 | echo "Trying with autoreconf..." |
38 | if ! autoreconf -i ${1+"$@"} ; then | 62 | if ! autoreconf -i ${1+"$@"} ; then |
39 | echo "Failed to autoreconf, retrying with force install..." | 63 | echo "Failed to autoreconf, retrying with force install..." |
40 | if ! autoreconf -i -f ${1+"$@"} ; then | 64 | if ! autoreconf -i -f ${1+"$@"} ; then |
@@ -45,6 +69,6 @@ if existence libtool || existence libtoolize || existence glibtoolize || existen | |||
45 | fi | 69 | fi |
46 | echo "The ${bs_scrdir-.}/configure is ready to run." | 70 | echo "The ${bs_scrdir-.}/configure is ready to run." |
47 | else | 71 | else |
48 | echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2; | 72 | echo "*** No libtoolize or libtool found, please install it ***" >&2; |
49 | exit 1 | 73 | exit 1 |
50 | fi | 74 | fi |