Skip to content

Commit bd565cc

Browse files
N-R-Kguijan
andcommitted
autogen: rewrite to be simpler and more robust
Based-on: PR #174 Co-authored-by: Guilherme Janczak <[email protected]> Closes: #174 Closes: #372
1 parent a6ae534 commit bd565cc

File tree

1 file changed

+35
-49
lines changed

1 file changed

+35
-49
lines changed

autogen.sh

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,43 @@
11
#!/bin/sh
22

3-
# autogen.sh with clean option, v0.1-scrot
4-
# Copyright 2019 Joao Eriberto Mota Filho <[email protected]>
3+
# Copyright 2021 Guilherme Janczak <[email protected]>
4+
# Copyright 2023 NRK <[email protected]>
55
#
6-
# This file is under BSD-3-Clause license.
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to
8+
# deal in the Software without restriction, including without limitation the
9+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
# sell copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
712
#
8-
# Redistribution and use in source and binary forms, with or without
9-
# modification, are permitted provided that the following conditions
10-
# are met:
11-
# 1. Redistributions of source code must retain the above copyright
12-
# notice, this list of conditions and the following disclaimer.
13-
# 2. Redistributions in binary form must reproduce the above copyright
14-
# notice, this list of conditions and the following disclaimer in the
15-
# documentation and/or other materials provided with the distribution.
16-
# 3. Neither the name of the authors nor the names of its contributors
17-
# may be used to endorse or promote products derived from this software
18-
# without specific prior written permission.
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies of the Software and its documentation and acknowledgment shall be
15+
# given in the documentation and software packages that this Software was
16+
# used.
1917
#
20-
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23-
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24-
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25-
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26-
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27-
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29-
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30-
# SUCH DAMAGE.
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21+
# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3124

3225

33-
# Use clean option
34-
if [ "$1" = "clean" ] && [ ! -e Makefile ]
35-
then
36-
echo "Vanishing the code"
37-
rm -rf aclocal.m4 autom4te.cache/ compile configure depcomp install-sh \
38-
Makefile.in missing src/config.h.in src/Makefile.in
39-
exit 0
26+
if [ "$#" -eq 0 ]; then
27+
autoreconf -i || { echo "autoreconf failed." >&2; exit 1; }
28+
echo "autogen.sh: done."
29+
echo "Run './configure && make && make install' to install."
30+
echo "Or run './autogen.sh clean' to clean up."
31+
elif [ "$#" -eq 1 ] && [ "$1" = "clean" ]; then
32+
if [ -e Makefile ]; then
33+
echo "Cannot clean. Run 'make distclean' first." >&2
34+
exit 1
35+
else
36+
echo "Cleaning up."
37+
rm -rf aclocal.m4 autom4te.cache/ compile configure depcomp install-sh \
38+
Makefile.in missing src/config.h.in src/Makefile.in
39+
fi
40+
else
41+
printf 'Invalid command: %s\n' "$*" >&2
42+
exit 1
4043
fi
41-
42-
# Do not use clean option
43-
if [ "$1" = "clean" ] && [ -e Makefile ]
44-
then
45-
echo "I can not clean. Use '$ make distclean'."
46-
exit 0
47-
fi
48-
49-
# Do autoreconf
50-
autoreconf -i \
51-
&& { echo " "; \
52-
echo "Done. You can use the 'clean' option to vanish the source code."; \
53-
echo "Example of use: $ ./autogen.sh clean"; \
54-
echo " "; \
55-
echo "Now run ./configure, make, and make install."; \
56-
} \
57-
|| { echo "We have a problem..."; exit 1; }

0 commit comments

Comments
 (0)