cake
/
libg1m
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/configure

141 lines
3.6 KiB
Plaintext
Raw Normal View History

2016-10-30 20:18:15 +01:00
#!/bin/sh
# Defaults
name="$(make -sC $(dirname $0) getname)"
author="$(make -sC $(dirname $0) getauthor)"
complete_author="$author <$(make -sC $(dirname $0) getmail)>"
version="$(make -sC $(dirname $0) getversion)"
# - Platform
platform="$(gcc --print-multiarch)"
platform="$([ "$platform" ] && echo "/$platform")"
# - Basic things
make_full_log=
loglevel=none # none, info, warn, error, fatal
root=''
# - main things
prefix='${root}/usr'
bindir='${prefix}/bin'
libdir='${prefix}/lib'"$platform"
includedir='${prefix}/include'"$platform"
mandir='${prefix}/share/man'
# - misc
install_manpages=yes
install_devel=yes
# Help
usage() {
cat <<EOF
\`configure\` configures ${name} to adapt to systems that aren't mine.
Usage: $0 [OPTION]
Defaults for the options are specified in brackets.
General options:
--help display this help and exit
--version display version information and quit
--make-full-log display full commands while making
Build options:
--loglevel library log level [$loglevel]
Installation options:
--noinstall-manpages should not install manpages
--noinstall-devel should not install developement files
Installation directories:
--root=ROOT installation root [$root]
--prefix=PREFIX main installation prefix [$prefix]
Fine tuning of the installation directories:
--bindir=DIR executables [$bindir]
--libdir=DIR library files of the linker [$libdir]
--includedir=DIR include files for the compiler [$includedir]
--mandir=DIR man root [$mandir]
Report bugs to ${complete_author}.
EOF
exit 0
}
# Version
version() {
cat <<EOF
${name} configure script v${version}
Hand-written by ${author}.
This configure script is free software.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit 0
}
# Args parsing
# - check for help and version
put_version=
put_help=
for arg ; do case "$arg" in
--help|-h) put_help=1 ;;
--version|-v) put_version=1 ;;
esac; done
if [ $put_version ]; then version; fi
if [ $put_help ]; then usage; fi
# - get options
for arg ; do case "$arg" in
--make-full-log) make_full_log=yes ;;
--loglevel=*)
level="${arg#*=}"
# check if is in array
if ! [ $level = "info" ] && ! [ $level = "warn" ] \
&& ! [ $level = "error" ] && ! [ $level = "fatal" ] \
&& ! [ $level = "none" ]; then
echo \
"$0 : --loglevel: expected one of [info, warn, error, fatal, none], \
got '$level'"
continue
fi
# then set
loglevel=$level ;;
--noinstall-manpages) install_manpages= ;;
--noinstall-devel) install_devel= ;;
--root=*) root="${arg#*=}" ;;
--prefix=*) prefix="${arg#*=}" ;;
--bindir=*) bindir="${arg#*=}" ;;
--libdir=*) libdir="${arg#*=}" ;;
--includedir=*) includedir="${arg#*=}" ;;
--mandir=*) mandir="${arg#*=}" ;;
*) echo "$arg: didn't read" ;;
esac; done
# Evaluate
for var in prefix sysconfdir bindir libdir includedir mandir udevrulesdir; do
eval $var'='$(eval 'echo $'$var)
done
# Create Makefile configuration
exec 3>&1 1>"$(dirname $0)/Makefile.cfg"
cat <<EOF
#!/usr/bin/make -f
# Makefile configuration generated by ./configure
# - Configuration version
CONFIG_VERSION = $version
MAKE_FULL_LOG = $make_full_log
# - Build options
LOG_LEVEL = $loglevel
# - Install options
INSTALL_MANPAGES = $install_manpages
INSTALL_DEVEL = $install_devel
# - Install prefix and directories
IBINDIR = $bindir
ILIBDIR = $libdir
IINCDIR = $includedir
IMANDIR = $mandir
EOF
exec 1>&3 3>&-
chmod +x "$(dirname $0)/Makefile.cfg"
# We're done
echo "Configuration loaded, you can make now."