diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100755 index 0000000..5e99fa6 --- /dev/null +++ b/configure @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +name='configure' # Luke's configuration script +#version='1.0' +# Copyright (C) 2009, 2016 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +srcdir="$(dirname -- "$0")" +outdir="." + +error() { + echo "$name: $1" >&2 + exit 1 +} + +if [ "${srcdir:0:1}" = / ]; then + topsrcdir=$srcdir +else + topsrcdir="&/$srcdir" +fi +topsrcdir="${topsrcdir%/.}" + +edit=(sed -E -e "s|^topsrcdir := .*|$topsrcdir|") +setvar() { + edit+=(-e "s@^(\s*$1\s*:?=).*@\1 $2@") +} + +vars=($(<"$srcdir/config.mk.in" sed -n 's/^\([ a-z_-]*\)=.*/\1/p')) + +printf -v lopt '%s:,' "${vars[@]}" +lopt+='enable-autodeps,disable-autodeps' + +sopt='' + +args=$(getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@") || exit $? +eval set -- "$args" +while [ $# -gt 0 ]; do + case "$1" in + --) break;; + --enable-autodeps) setvar AUTODEPS t;; + --disable-autodeps) setvar AUTODEPS '';; + --*) setvar "${1#--}" "$2" shift;; + *) error "unrecognized option \`$1'"; + esac + shift +done + +"${edit[@]}" < "$srcdir/config.mk.in" > "$outdir/config.mk" + +Makefiles=($(find "$srcdir/" -name 'Makefile') "$srcdir"/modules/module.mk "$srcdir"/modules/*/Makefile.inc.mk) +for src in "${Makefiles[@]}"; do + out="$outdir/${src#$srcdir/}" + mkdir -p -- $(dirname -- "$out") + if ! test "$src" -ef "$out"; then + cp -fT -- "$src" "$out" + fi +done |