From 53fbfa7ace2a8977ab894d7ae2ebe38392fa5218 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 19 Jan 2012 15:27:43 -0500 Subject: Initial commit. Write build system. --- (limited to 'configure') diff --git a/configure b/configure new file mode 100755 index 0000000..0eefd30 --- /dev/null +++ b/configure @@ -0,0 +1,169 @@ +#! /bin/sh +# +# opkhelper +# configure +# Configuration script to generate Makefile. +# +# Copyright (C) 2012 Patrick "P. J." McDermott +# +# 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 3 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. If not, see . + +PACKAGE='opkhelper' +VERSION='0.1.0' + +print_usage() +{ + printf 'Usage: %s [OPTION]...\n' "$1" +} + +print_help() +{ + cat <. +This configure script is free software: you can redistribute and/or modify it. +There is NO WARRANTY, to the extent permitted by law. +EOF +} + +opts=$(getopt -n "${0}" -o 'hVq' -l 'help,version,quiet' \ + -l 'srcdir:,prefix:,sbindir:' -- "${@}") +if [ ${?} -ne 0 ]; then + print_usage "${0}" >&2 + exit 1; +fi +eval set -- "${opts}" +while true; do + case "${1}" in + -h|--help) + print_help "${0}" + exit 0 + ;; + -V|--version) + print_version + exit 0 + ;; + -q|--quiet) + QUIET=true + shift + ;; + --srcdir) + SRCDIR="${2}" + shift 2 + ;; + --prefix) + PREFIX="${2}" + shift 2 + ;; + --sbindir) + # Leave PREFIX unexpanded for now, in case it isn't set yet. + SBINDIR="\${PREFIX}/${2}" + shift 2 + ;; + --) + shift + break + ;; + *) + print_usage "${0}" >&2 + exit 1 + ;; + esac +done + +if [ -z "${QUIET}" ]; then + QUIET=false +fi + +if [ -z "${SRCDIR}" ]; then + SRCDIR=$(dirname "${0}") +fi +if [ -z "${PREFIX}" ]; then + PREFIX=/usr/local +fi +if [ -z "${SBINDIR}" ]; then + SBINDIR=${PREFIX}/sbin +fi +# Expand PREFIX if it's there. +eval "SBINDIR=${SBINDIR}" + +find_dependency() +{ + dep=${1} + var=${2} + shift 2 + + ${QUIET} || printf 'checking for %s... ' "${dep}" + + while [ ${#} -gt 0 ]; do + if [ -f "${1}/${dep}" ]; then + ${QUIET} || printf '%s/%s\n' "${1}" "${dep}" + eval "${var}=${1}/${dep}" + return 0 + fi + shift + done + + ${QUIET} || printf 'not found\n' + missing_dependencies=true + return 1 +} + +missing_dependencies=false + +find_dependency sh SHELL /bin +find_dependency install INSTALL /usr/bin + +if ${missing_dependencies}; then + printf '\nSome dependencies could not be found.\n' + printf 'Please make sure all dependencies are installed and try again.\n\n' + exit 1 +fi + +sed_script=" +s&@shell@&${SHELL}& +s&@install@&${INSTALL} -c& +s&@srcdir@&${SRCDIR}& +s&@prefix@&${PREFIX}& +s&@sbindir@&${SBINDIR}&" + +# Replace configuration variables in Makefile.in +sed "$sed_script" ${SRCDIR}/Makefile.in > Makefile + +printf '\nConfiguration complete!\n\n' -- cgit v0.9.1