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

191 lines
6.2 KiB
Plaintext
Raw Normal View History

2016-10-30 20:18:15 +01:00
#!/bin/sh
cd "$(dirname $0)"
#******************************************************************************#
# Defaults #
#******************************************************************************#
# Project variables
name="$(make -s getname)"
version="$(make -s getversion)"
2016-12-31 11:37:13 +01:00
# Maintainer
maintainer="$(make -s getmaintainer)"
# Target
target=""
# Platform
2016-12-21 16:39:26 +01:00
platform="$(command -v gcc 1>/dev/null && gcc --print-multiarch)"
2016-10-30 20:18:15 +01:00
platform="$([ "$platform" ] && echo "/$platform")"
# Make options
2016-10-30 20:18:15 +01:00
make_full_log=
# Build options
2016-10-30 20:18:15 +01:00
loglevel=none # none, info, warn, error, fatal
# Installation directories
2016-10-30 20:18:15 +01:00
root=''
prefix='${root}/usr'
2016-12-20 17:29:54 +01:00
prefix_set=
2016-10-30 20:18:15 +01:00
bindir='${prefix}/bin'
libdir='${prefix}/lib'"$platform"
includedir='${prefix}/include'"$platform"
2016-12-20 21:59:26 +01:00
pkgdir='${libdir}/pkgconfig'
2016-10-30 20:18:15 +01:00
mandir='${prefix}/share/man'
# Installation options
2016-10-30 20:18:15 +01:00
install_manpages=yes
install_devel=yes
#******************************************************************************#
# Help message #
#******************************************************************************#
2016-10-30 20:18:15 +01:00
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:
2016-12-27 02:59:36 +01:00
--target=TARGET the target (if none, native)
2016-12-20 17:29:54 +01:00
--loglevel=LOGLEVEL library log level [$loglevel]
2016-10-30 20:18:15 +01:00
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]
2016-12-20 21:59:26 +01:00
--pkgdir=DIR pkg-config configurations directory [$pkgdir]
2016-10-30 20:18:15 +01:00
--libdir=DIR library files of the linker [$libdir]
--includedir=DIR include files for the compiler [$includedir]
--mandir=DIR man root [$mandir]
2016-12-31 11:37:13 +01:00
Report bugs to ${maintainer}.
2016-10-30 20:18:15 +01:00
EOF
exit 0
}
#******************************************************************************#
# Version message #
#******************************************************************************#
2016-10-30 20:18:15 +01:00
version() {
cat <<EOF
${name} configure script v${version}
2016-12-31 11:37:13 +01:00
Hand-written by Thomas "Cakeisalie5" Touhey.
2016-10-30 20:18:15 +01:00
This configure script is free software.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit 0
}
#******************************************************************************#
# Check for help and version #
#******************************************************************************#
2016-10-30 20:18:15 +01:00
put_version=
put_help=
for arg ; do case "$arg" in
--help|-h) put_help=1 ;;
--version|-v) put_version=1 ;;
esac; done
[ $put_version ] && version
[ $put_help ] && usage
2016-10-30 20:18:15 +01:00
#******************************************************************************#
# Parse arguments #
#******************************************************************************#
2016-10-30 20:18:15 +01:00
for arg ; do case "$arg" in
--target=*) target="${arg#*=}" ;;
2016-10-30 20:18:15 +01:00
--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#*=}" ;;
2016-12-20 17:29:54 +01:00
--prefix=*) prefix="${arg#*=}"; prefix_set=y ;;
2016-10-30 20:18:15 +01:00
--bindir=*) bindir="${arg#*=}" ;;
2016-12-20 21:59:26 +01:00
--pkgdir=*) pkgdir="${arg#*=}" ;;
2016-10-30 20:18:15 +01:00
--libdir=*) libdir="${arg#*=}" ;;
--includedir=*) includedir="${arg#*=}" ;;
--mandir=*) mandir="${arg#*=}" ;;
*) echo "$arg: didn't read" ;;
esac; done
2016-12-20 17:29:54 +01:00
#******************************************************************************#
# Check for defaults #
#******************************************************************************#
2016-12-29 12:48:08 +01:00
# Cross-compiling things
if [ ! $prefix_set ]; then
2016-12-20 17:29:54 +01:00
prefix='${root}/usr/'"$target"
fi
#******************************************************************************#
# Evaluate variables #
#******************************************************************************#
2016-12-20 21:59:26 +01:00
for var in prefix sysconfdir bindir libdir pkgdir includedir mandir; do
2016-10-30 20:18:15 +01:00
eval $var'='$(eval 'echo $'$var)
done
#******************************************************************************#
# Create Makefile configuration #
#******************************************************************************#
exec 3>&1 1>Makefile.cfg
2016-10-30 20:18:15 +01:00
cat <<EOF
#!/usr/bin/make -f
#******************************************************************************#
# Makefile configuration generated by ./configure #
#******************************************************************************#
# Configuration version and messages configuration
2016-10-30 20:18:15 +01:00
CONFIG_VERSION = $version
MAKE_FULL_LOG = $make_full_log
# Build options
TARGET = $target
2016-10-30 20:18:15 +01:00
LOG_LEVEL = $loglevel
# Installation directories
2016-10-30 20:18:15 +01:00
IBINDIR = $bindir
2016-12-20 21:59:26 +01:00
IPKGDIR = $pkgdir
2016-10-30 20:18:15 +01:00
ILIBDIR = $libdir
IINCDIR = $includedir
IMANDIR = $mandir
# Installation options
INSTALL_MANPAGES = $install_manpages
INSTALL_DEVEL = $install_devel
# End of file.
EOF
2016-10-30 20:18:15 +01:00
exec 1>&3 3>&-
chmod +x Makefile.cfg
2016-10-30 20:18:15 +01:00
#******************************************************************************#
# Finish #
#******************************************************************************#
2016-10-30 20:18:15 +01:00
echo "Configuration loaded, you can make now."
# End of file.