cake
/
libp7
Archived
1
0
Fork 1
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.
libp7/configure

97 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
#******************************************************************************#
# #
# configure #
# | Project : libp7 #
# #
# By: thomas <thomas@touhey.fr> #
# Last updated: 2016/05/22 23:13:42 #
# #
#******************************************************************************#
# Defaults
reconf=false
loglevel=none
prefix=/usr
libdir='$(IPREFIX)/lib/'"$(gcc --print-multiarch)"
includedir='$(IPREFIX)/include/'"$(gcc --print-multiarch)"
mandir='$(IPREFIX)/share/man'
# Help
usage() {
cat <<EOF
Usage: $0 [OPTION]
Defaults for the options are specified in brackets.
Build options:
--loglevel library log level [$loglevel]
Installation directories:
--prefix=PREFIX main installation prefix [$prefix]
Fine tuning of the installation directories:
--libdir=DIR library files of the linker [$libdir]
--includedir=DIR include files for the compiler [$includedir]
--mandir=DIR man root [$mandir]
EOF
exit 0
}
# Args parsing
for arg ; do
case "$arg" in
--help|-h)
usage ;;
--re)
reconf=true ;;
--loglevel=*)
level=${arg#*=};
# check if is in array
! [ $level = "info" ] && ! [ $level = "warn" ] && ! [ $level = "error" ] \
&& ! [ $level = "fatal" ] && ! [ $level = "none" ] \
&& echo "$0: '--loglevel': expected value in [info, warn, error, fatal, \
none]" && continue
# then set
loglevel=$level ;;
--prefix=*)
prefix=${arg#*=} ;;
--libdir=*)
libdir=${arg#*=} ;;
--includedir=*)
includedir=${arg#*=} ;;
--mandir=*)
mandir=${arg#*=} ;;
*) echo "$0: '$arg': DIDN'T READ LOL" ;;
esac
done
# If Makefile configuration already exists, ragequit
if [ $reconf = "false" ]; then
if [ -f Makefile.cfg ]; then
echo "Configuration is already loaded, skipping."
exit 0
fi
fi
# Create Makefile configuration
exec 3>&1 1>Makefile.cfg
cat <<EOF
#!/usr/bin/make -f
# Makefile configuration generated by ./configure
# - Build options
LOG_LEVEL = $loglevel
# - Install options
IPREFIX = $prefix
ILIBDIR = $libdir
IINCDIR = $includedir
IMANDIR = $mandir
EOF
exec 1>&3 3>&-
chmod +x Makefile.cfg
# We're done
echo "Configuration loaded, you can make now."