From 3c46a94070c534c118a528be5271a54c775ec77e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 5 Jan 2016 21:21:50 +0100 Subject: first commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- mk/configure | 732 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 732 insertions(+) create mode 100644 mk/configure (limited to 'mk/configure') diff --git a/mk/configure b/mk/configure new file mode 100644 index 0000000..4b6e61a --- /dev/null +++ b/mk/configure @@ -0,0 +1,732 @@ +# -*- shell-script -*- + +# Copyright (C) 2015, 2016 Mattias Andrée +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + + +# Run './configure --help' for usage information. + + +# FOR DEVELOPERS USING THIS SCRIPT: +# This file is used by include this file, via the . builtin, +# in your ./configure. Before doing so, you must declare +# PKGNAME=the_name_of_your_package +# MAN_SECTION_SUFFIX=default_suffix_to_append_to_man_page_section # (usually empty) +# MAN_SECTION=the_section_your_man_page_is_in # (do no declare if you do not use exacly one section) +# Define the function list_optional_features_help, see the help output. +# Define the function unrecognised_argument to deal with any unrecognised argument. + + + +# Store command for rebuilding Makefile to config.status. +exec 10>config.status + +# Store configurations to .config.mk. +exec 20>.config.mk + + +# Print a quoted (if necessary) version of a string +quote () +{ + value="$1" + if ! test "${value%%\'*}" = "${value}"; then + value="'$(echo "${value}" | sed "s/'/'\\\\''/g")'" + elif ! test "$(printf '%s' ${value})" = "${value}"; then + value="'${value}'" + elif ! test "$(echo ${value}) | tr -d a-zA-Z0-9+_@%/=-" = ""; then + value="'${value}'" + fi + echo "${value}" +} + + +# Parse command line. +incomplete= +dashed= +f_help= +f_gnulinux= +f_bin_merger= +for option; do + if test -n "${incomplete}"; then + option="${incomplete}=${option}" + incomplete= + fi + + # For --{with{,out},{en,dis}able}-*. + feature="${option#--*}" + feature="${feature#*-}" + feature="$(echo "${feature}" | tr a-z- A-Z_)" + + # For directories and filename tweaks. + nodash=_novar + + case "${dashed}${option}" in +# general + (--) + dashed=yes ;; + (--help) + f_help=yes ;; + (--destdir | --destdir=* | --pkgdir | --pkgdir=*) + nodash=destdir ;; + (--srcdir | --srcdir) + nodash=srcdir ;; + +# directory automation + (--gnu-linux) + f_gnulinux=yes ;; + (--bin-merger) + f_bin_merger=yes ;; + +# directories and filenames + (--prefix | --prefix=*) + nodash=prefix ;; + (--exec-prefix | --exec-prefix=* | --exec_prefix | --exec_prefix=*) + nodash=exec_prefix ;; + (--bindir | --bindir=*) + nodash=bindir ;; + (--sbindir | --sbindir=*) + nodash=sbindir ;; + (--libexecdir | --libexecdir=*) + nodash=libexecdir ;; + (--libdir | --libdir=*) + nodash=libdir ;; + (--includedir | --includedir=*) + nodash=includedir ;; + (--oldincludedir | --oldincludedir=*) + nodash=oldincludedir ;; + (--datarootdir | --datarootdir=*) + nodash=datarootdir ;; + (--datadir | --datadir=*) + nodash=datadir ;; + (--libdatarootdir | --libdatarootdir=*) + nodash=libdatarootdir ;; + (--libdatadir | --libdatadir=*) + nodash=libdatadir ;; + (--sysconfdir | --sysconfdir=*) + nodash=sysconfdir ;; + (--sharedstatedir | --=sharedstatedir*) + nodash=sharedstatedir ;; + (--localstatedir | --localstatedir=*) + nodash=localstatedir ;; + (--runstatedir | --runstatedir=*) + nodash=runstatedir ;; + (--lispdir | --lispdir=*) + nodash=lispdir ;; + (--localedir | --localedir=*) + nodash=localedir ;; + (--licensedir | --licensedir=*) + nodash=licensedir ;; + (--emptydir | --emptydir=*) + nodash=emptydir ;; + (--cachedir | --cachedir=*) + nodash=cachedir ;; + (--spooldir | --spooldir=*) + nodash=spooldir ;; + (--logdir | --logdir=*) + nodash=logdir ;; + (--statedir | --statedir=*) + nodash=statedir ;; + (--gamedir | --gamedir=*) + nodash=gamedir ;; + (--sharedcachedir | --sharedcachedir=*) + nodash=sharedcachedir ;; + (--sharedspooldir | --sharedspooldir=*) + nodash=sharedspooldir ;; + (--sharedlogdir | --sharedlogdir=*) + nodash=sharedlogdir ;; + (--sharedstatedir | --sharedstatedir=*) + nodash=sharedstatedir ;; + (--sharedgamedir | --sharedgamedir=*) + nodash=sharedgamedir ;; + (--tmpdir | --tmpdir=*) + nodash=tmpdir ;; + (--localtmpdir | --localtmpdir=*) + nodash=localtmpdir ;; + (--sharedtmpdir | --sharedtmpdir=*) + nodash=sharedtmpdir ;; + (--lockdir | --lockdir=*) + nodash=lockdir ;; + (--skeldir | --skeldir=*) + nodash=skeldir ;; + (--devdir | --devdir=*) + nodash=devdir ;; + (--sysdir | --sysdir=*) + nodash=sysdir ;; + (--procdir | --procdir=*) + nodash=procdir ;; + (--selfprocdir | --selfprocdir=*) + nodash=selfprocdir ;; + (--docdir | --docdir=*) + nodash=docdir ;; + (--infodir | --infodir=*) + nodash=infodir ;; + (--dvidir | --dvidir=*) + nodash=dvidir ;; + (--pdfdir | --pdfdir=*) + nodash=pdfdir ;; + (--psdir | --psdir=*) + nodash=psdir ;; + (--htmldir | --htmldir=*) + nodash=htmldir ;; + (--mandir | --mandir=*) + nodash=mandir ;; + (--man0 | --man0=*) + nodash=man0 ;; + (--man1 | --man1=*) + nodash=man1 ;; + (--man2 | --man2=*) + nodash=man2 ;; + (--man3 | --man3=*) + nodash=man3 ;; + (--man4 | --man4=*) + nodash=man4 ;; + (--man5 | --man5=*) + nodash=man5 ;; + (--man6 | --man6=*) + nodash=man6 ;; + (--man7 | --man7=*) + nodash=man7 ;; + (--man8 | --man8=*) + nodash=man8 ;; + (--man9 | --man9=*) + nodash=man9 ;; + (--man0ext | --man0ext=*) + nodash=man0ext ;; + (--man1ext | --man1ext=*) + nodash=man1ext ;; + (--man2ext | --man2ext=*) + nodash=man2ext ;; + (--man3ext | --man3ext=*) + nodash=man3ext ;; + (--man4ext | --man4ext=*) + nodash=man4ext ;; + (--man5ext | --man5ext=*) + nodash=man5ext ;; + (--man6ext | --man6ext=*) + nodash=man6ext ;; + (--man7ext | --man7ext=*) + nodash=man7ext ;; + (--man8ext | --man8ext=*) + nodash=man8ext ;; + (--man9ext | --man9ext=*) + nodash=man9ext ;; + (--manext | --manext=*) + if test -n "${MAN_SECTION}"; then + nodash=manext + else + printf "\e[01;31m%s: warning: ignoring: %s\e[00m\n" "${0}" "${option}" >&2 + sleep 1 + fi + ;; + +# ignored + # Unrecognised directories, and settings that cannot be used with internationalisation. + (--*dir=* | --*dir | --man?dir | --man?dir=*) + printf "\e[01;31m%s: warning: ignoring: %s\e[00m\n" "${0}" "${option}" >&2 + sleep 1 + ;; + +# feature tweaking + (--with-*) + feature="WITH_${feature}" + echo "${feature}" = yes >&20 + export "${feature}"=yes + option="${option}=x" + ;; + + (--without-*) + feature="WITHOUT_${feature}" + echo "${feature}" = yes >&20 + export "${feature}"=yes + option="${option}=x" + ;; + + (--enable-*=*) + param="${feature#*=}" + feature="${feature%%=*}" + if ! test "${param}" = "no"; then + feature="ENABLE_${feature}" + else + feature="DISABLE_${feature}" + param=yes + fi + echo "${feature}" = "${param}" >&20 + export "${feature}"="${param}" + ;; + + (--enable-*) + feature="DISABLE_${feature}" + echo "${feature}" = yes >&20 + export "${feature}"=yes + option="${option}=x" + ;; + + (--disable-*) + feature="DISABLE_${feature}" + echo "${feature}" = yes >&20 + export "${feature}"=yes + option="${option}=x" + ;; + +# unrecognised + (${dashed}--*) + unrecognised_argument "${option}" + ;; + +# variables + (${dashed}*=*) + var="${option%%=*}" + val="${option#*=}" + if test -n "$(echo "${var}" | tr -d '[_a-zA-Z0-9-]')"; then + # Variable is not used and is potentially not + # formatted in a compatible way. + printf "\e[01;31m%s: warning: ignoring because of bad format: %s\e[00m\n" "${0}" "${option}" >&2 + sleep 1 + fi + echo "${var}" = "${val}" >&20 + ;; + +# unrecognised + (*) + unrecognised_argument "${option}" + ;; + esac + + if test "${option%%=*}" = "${option}"; then + incomplete="${option}" + else + eval "${nodash}=$(quote "${option#*=}")" + eval "have_${nodash}=yes" + fi +done + + +# Print usage information. This is parsed by +# the auto-completion script for ./configure. +if test -n "${f_help}"; then + cat <&10 +echo >&10 +echo '# This file was generated by ./configure, its purpose is two-fold:' >&10 +echo '# 1) It lets you rebuild Makefile with the same configurations you' >&10 +echo '# used last time you run ./configure.' >&10 +echo '# 2) It lets Makefile rebuild itself transparently when out of date.' >&10 +echo >&10 + +# config.status should adjust CWD. +echo 'cd "$(dirname "${0}")"' >&10 + +# config.status calls ./configure with all arguments you called ./configure. +printf "exec %s" "${0}" >&10 +for option; do + printf " %s" "$(quote "${option}")" >&10 +done +echo >&10 + +# Close config.status. +exec 10>&- + + +# Store environment (with restrictions). +env | while read line; do + var="${line%%=*}" + val="${line#*=}" + if test "${var}" = "${line}"; then + # Malformated variables. (Can happen!, sigh...) + continue + elif test -n "$(echo "${var}" | tr -d '[_a-zA-Z0-9-]')"; then + # Variable is not used and is potentially not + # formatted in a compatible way. + continue + fi + case "${var}" in + (_ | PWD | SHELL | SHLVL | TERM | COLORTERM | MAKEFLAGS) + # We do not want to propagate these. + ;; + (*) + echo "${var}" = "${val}" >&20 + ;; + esac +done + +# Store directories and filenames. +if test -n "${destdir}"; then + echo DESTDIR = "${destdir}" >&20 +fi +echo PREFIX = "${prefix}" >&20 +echo SYSCONFDIR = "${sysconfdir}" >&20 +echo COMDIR = "${sharedstatedir}" >&20 +echo VARDIR = "${localstatedir}" >&20 +echo RUNDIR = "${runstatedir}" >&20 +echo TMPDIR = "${tmpdir}" >&20 +echo DEVDIR = "${devdir}" >&20 +echo SYSDIR = "${sysdir}" >&20 +echo PROCDIR = "${procdir}" >&20 +echo EXEC_PREFIX = "${exec_prefix}" >&20 +echo BINDIR = "${bindir}" >&20 +echo SBINDIR = "${sbindir}" >&20 +echo LIBEXECDIR = "${libexecdir}" >&20 +echo LIBDIR = "${libdir}" >&20 +echo INCLUDEDIR = "${includedir}" >&20 +echo OLDINCLUDEDIR = "${oldincludedir}" >&20 +echo DATADIR = "${datarootdir}" >&20 +echo RESDIR = "${datadir}" >&20 +echo SYSDEPDATADIR = "${libdatarootdir}" >&20 +echo SYSDEPRESDIR = "${libdatadir}" >&20 +echo LISPDIR = "${lispdir}" >&20 +echo LOCALEDIR = "${localedir}" >&20 +echo LICENSEDIR = "${licensedir}" >&20 +echo CACHEDIR = "${cachedir}" >&20 +echo SPOOLDIR = "${spooldir}" >&20 +echo EMPTYDIR = "${emptydir}" >&20 +echo LOGDIR = "${logdir}" >&20 +echo STATEDIR = "${statedir}" >&20 +echo GAMEDIR = "${gamedir}" >&20 +echo COMCACHEDIR = "${sharedcachedir}" >&20 +echo COMPOOLDIR = "${sharedpooldir}" >&20 +echo COMLOGDIR = "${sharedlogdir}" >&20 +echo COMSTATEDIR = "${sharedstatedir}" >&20 +echo COMGAMEDIR = "${sharedgamedir}" >&20 +echo LOCALTMPDIR = "${localtmpdir}" >&20 +echo SHAREDTMPDIR = "${sharedtmpdir}" >&20 +echo LOCKDIR = "${lockdir}" >&20 +echo SKELDIR = "${skeldir}" >&20 +echo SELFPROCDIR = "${selfprocdir}" >&20 +echo DOCDIR = "${docdir}" >&20 +echo INFODIR = "${infodir}" >&20 +echo DVIDIR = "${dvidir}" >&20 +echo PDFDIR = "${pdfdir}" >&20 +echo PSDIR = "${psdir}" >&20 +echo HTMLDIR = "${htmldir}" >&20 +echo MANDIR = "${mandir}" >&20 +echo MAN0 = "${man0}" >&20 +echo MAN1 = "${man1}" >&20 +echo MAN2 = "${man2}" >&20 +echo MAN3 = "${man3}" >&20 +echo MAN4 = "${man4}" >&20 +echo MAN5 = "${man5}" >&20 +echo MAN6 = "${man6}" >&20 +echo MAN7 = "${man7}" >&20 +echo MAN8 = "${man8}" >&20 +echo MAN9 = "${man9}" >&20 +echo MAN0EXT = "${man0ext}" >&20 +echo MAN1EXT = "${man1ext}" >&20 +echo MAN2EXT = "${man2ext}" >&20 +echo MAN3EXT = "${man3ext}" >&20 +echo MAN4EXT = "${man4ext}" >&20 +echo MAN5EXT = "${man5ext}" >&20 +echo MAN6EXT = "${man6ext}" >&20 +echo MAN7EXT = "${man7ext}" >&20 +echo MAN8EXT = "${man8ext}" >&20 +echo MAN9EXT = "${man9ext}" >&20 + +# Close .config.mk. +exec 20>&- + +# Now, make Makefile available. +if test -f Makefile; then + chmod u+w Makefile # This scripts makes it read-only. +fi +exec 30>Makefile +echo "# ----------------------------------------------------- #" >&30 +echo "# This file was created by ./configure from Makefile.in #" >&30 +echo "# ----------------------------------------------------- #" >&30 +echo >&30 +if test -n "${srcdir}"; then + echo v = "${srcdir}" >&30 +fi +cat "${srcdir_proper}"Makefile.in >&30 +exec 30>&- + + +# config.status should be executable. +chmod a+x config.status + +# Makefile should be read-only to ones does not edit it by mistake. +chmod a-w Makefile + + +# Help functions for the parent script. +test_with () +{ + with="$(eval echo '${WITH_'"${1}"'}')" + without="$(eval echo '${WITHOUT_'"${1}"'}')" + if ! test -n "${with}" && ! test -n "${without}"; then + echo "${2}" + elif ! test -n "${with}" && test -n "${without}"; then + echo "no" + elif test -n "${with}" && ! test -n "${without}"; then + echo "yes" + elif test "${2}" = yes; then + echo "no" + else + echo "yes" + fi +} +test_enable () +{ + enable="$(eval echo '${ENABLE_'"${1}"'}')" + disable="$(eval echo '${DISABLE_'"${1}"'}')" + if ! test -n "${enable}" && ! test -n "${disable}"; then + echo "${2}" + elif ! test -n "${enable}" && test -n "${disable}"; then + echo "no" + elif test -n "${enable}" && ! test -n "${disable}"; then + echo "${enable}" + elif test "${2}" = yes ; then + echo "no" + else + echo "${enable}" + fi +} + + +# After including this file, you may want +# to do something like: +# +# cat <