Skip to content

Commit

Permalink
autogen: rewrite to be simpler and more robust
Browse files Browse the repository at this point in the history
Based-on: PR #174
Co-authored-by: Guilherme Janczak <guilherme.janczak@yandex.com>
Closes: #174
Closes: #372
  • Loading branch information
N-R-K and guijan committed Oct 21, 2023
1 parent a6ae534 commit bd565cc
Showing 1 changed file with 35 additions and 49 deletions.
84 changes: 35 additions & 49 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,57 +1,43 @@
#!/bin/sh

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


# Use clean option
if [ "$1" = "clean" ] && [ ! -e Makefile ]
then
echo "Vanishing the code"
rm -rf aclocal.m4 autom4te.cache/ compile configure depcomp install-sh \
Makefile.in missing src/config.h.in src/Makefile.in
exit 0
if [ "$#" -eq 0 ]; then
autoreconf -i || { echo "autoreconf failed." >&2; exit 1; }
echo "autogen.sh: done."
echo "Run './configure && make && make install' to install."
echo "Or run './autogen.sh clean' to clean up."
elif [ "$#" -eq 1 ] && [ "$1" = "clean" ]; then
if [ -e Makefile ]; then
echo "Cannot clean. Run 'make distclean' first." >&2
exit 1
else
echo "Cleaning up."
rm -rf aclocal.m4 autom4te.cache/ compile configure depcomp install-sh \
Makefile.in missing src/config.h.in src/Makefile.in
fi
else
printf 'Invalid command: %s\n' "$*" >&2
exit 1
fi

# Do not use clean option
if [ "$1" = "clean" ] && [ -e Makefile ]
then
echo "I can not clean. Use '$ make distclean'."
exit 0
fi

# Do autoreconf
autoreconf -i \
&& { echo " "; \
echo "Done. You can use the 'clean' option to vanish the source code."; \
echo "Example of use: $ ./autogen.sh clean"; \
echo " "; \
echo "Now run ./configure, make, and make install."; \
} \
|| { echo "We have a problem..."; exit 1; }

0 comments on commit bd565cc

Please sign in to comment.