2016-10-30 20:18:15 +01:00
|
|
|
#!/bin/sh
|
2016-11-23 08:23:29 +01:00
|
|
|
cd "$(dirname $0)"
|
|
|
|
#******************************************************************************#
|
|
|
|
# Defaults #
|
|
|
|
#******************************************************************************#
|
|
|
|
# Project variables
|
2017-02-24 02:18:10 +01:00
|
|
|
[ -f Makefile.cfg ] && mv Makefile.cfg Makefile.cfg.tmp
|
2016-11-23 08:23:29 +01:00
|
|
|
name="$(make -s getname)"
|
|
|
|
version="$(make -s getversion)"
|
2016-12-31 11:37:13 +01:00
|
|
|
maintainer="$(make -s getmaintainer)"
|
2017-02-24 02:18:10 +01:00
|
|
|
[ -f Makefile.cfg.tmp ] && mv Makefile.cfg.tmp Makefile.cfg
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# 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")"
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# Make options
|
2016-10-30 20:18:15 +01:00
|
|
|
make_full_log=
|
2017-01-27 21:49:04 +01:00
|
|
|
more_warnings=
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# Build options
|
2017-01-09 16:27:41 +01:00
|
|
|
target=
|
2017-02-19 23:31:46 +01:00
|
|
|
no_file=
|
2017-01-27 21:49:04 +01:00
|
|
|
static=
|
|
|
|
windows=
|
|
|
|
optimize_size=
|
2016-10-30 20:18:15 +01:00
|
|
|
loglevel=none # none, info, warn, error, fatal
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# Installation directories
|
2016-10-30 20:18:15 +01:00
|
|
|
root=''
|
|
|
|
prefix='${root}/usr'
|
2016-12-20 17:29:54 +01:00
|
|
|
prefix_set=
|
2017-03-18 12:57:14 +01:00
|
|
|
hprefix='${root}/usr'
|
2016-10-30 20:18:15 +01:00
|
|
|
bindir='${prefix}/bin'
|
2017-03-18 12:57:14 +01:00
|
|
|
hbindir='${hprefix}/bin'
|
2016-10-30 20:18:15 +01:00
|
|
|
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'
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# Installation options
|
2016-10-30 20:18:15 +01:00
|
|
|
install_manpages=yes
|
|
|
|
install_devel=yes
|
|
|
|
|
2017-01-27 21:49:04 +01:00
|
|
|
# Tweaks
|
|
|
|
cflags=
|
|
|
|
ldflags=
|
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
#******************************************************************************#
|
|
|
|
# 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
|
2017-01-27 21:49:04 +01:00
|
|
|
--maintainer enable maintainer mode
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
Build options:
|
2016-12-27 02:59:36 +01:00
|
|
|
--target=TARGET the target (if none, native)
|
2017-01-27 21:49:04 +01:00
|
|
|
--static build a static library (by default, dynamic)
|
|
|
|
--windows build DLLs and .libs instead of ELF and archives
|
|
|
|
--optimize-size optimize size instead of speed
|
2017-02-19 23:31:46 +01:00
|
|
|
--no-file do not use the libc FILE interface
|
2016-12-20 17:29:54 +01:00
|
|
|
--loglevel=LOGLEVEL library log level [$loglevel]
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
Installation options:
|
2017-03-20 02:49:13 +01:00
|
|
|
--no-manpages should not make and install manpages
|
|
|
|
--no-devel should not install developement files
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
Installation directories:
|
|
|
|
--root=ROOT installation root [$root]
|
|
|
|
--prefix=PREFIX main installation prefix [$prefix]
|
2017-03-18 12:57:14 +01:00
|
|
|
--hprefix=HOSTPREFIX host installation prefix [$hprefix]
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
Fine tuning of the installation directories:
|
2017-03-18 12:57:14 +01:00
|
|
|
--hbindir=HOSTBINDIR host executables [$hbindir]
|
|
|
|
--bindir=BINDIR target executables [$bindir]
|
|
|
|
--pkgdir=PKGDIR pkg-config configurations directory [$pkgdir]
|
|
|
|
--libdir=LIBDIR library files of the linker [$libdir]
|
|
|
|
--includedir=INCDIR include files for the compiler [$includedir]
|
|
|
|
--mandir=MANDIR man root [$mandir]
|
2016-10-30 20:18:15 +01:00
|
|
|
|
2017-01-27 21:49:04 +01:00
|
|
|
Other tweaks:
|
|
|
|
CFLAGS=CFLAGS some more compilation flags
|
|
|
|
LDFLAGS=LDFLAGS some more linker flags
|
2017-01-09 16:27:41 +01:00
|
|
|
|
2016-12-31 11:37:13 +01:00
|
|
|
Report bugs to ${maintainer}.
|
2016-10-30 20:18:15 +01:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
#******************************************************************************#
|
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
#******************************************************************************#
|
|
|
|
# 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
|
2016-11-23 08:23:29 +01:00
|
|
|
[ $put_version ] && version
|
|
|
|
[ $put_help ] && usage
|
2016-10-30 20:18:15 +01:00
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
#******************************************************************************#
|
|
|
|
# Parse arguments #
|
|
|
|
#******************************************************************************#
|
2016-10-30 20:18:15 +01:00
|
|
|
for arg ; do case "$arg" in
|
|
|
|
--make-full-log) make_full_log=yes ;;
|
2017-03-21 02:10:01 +01:00
|
|
|
--maintainer) more_warnings=yes; loglevel=info; install_manpages= ;;
|
2017-01-27 21:49:04 +01:00
|
|
|
--target=*) target="${arg#*=}" ;;
|
|
|
|
--static) static=y ;;
|
|
|
|
--windows) windows=y ;;
|
|
|
|
--optimize-size) optimize_size=y ;;
|
2017-02-19 23:31:46 +01:00
|
|
|
--no-file) no_file=y ;;
|
2016-10-30 20:18:15 +01:00
|
|
|
--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 ;;
|
2017-03-20 02:49:13 +01:00
|
|
|
--no-manpages) install_manpages= ;;
|
|
|
|
--no-devel) install_devel= ;;
|
2016-10-30 20:18:15 +01:00
|
|
|
--root=*) root="${arg#*=}" ;;
|
2017-03-18 12:57:14 +01:00
|
|
|
--hprefix=*) hprefix="${arg#*=}" ;;
|
2016-12-20 17:29:54 +01:00
|
|
|
--prefix=*) prefix="${arg#*=}"; prefix_set=y ;;
|
2017-03-18 12:57:14 +01:00
|
|
|
--hbindir=*) hbindir="${arg#*=}" ;;
|
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#*=}" ;;
|
2017-01-27 21:49:04 +01:00
|
|
|
CFLAGS=*) cflags="${arg#*=}" ;;
|
|
|
|
LDFLAGS=*) ldflags="${arg#*=}" ;;
|
2016-10-30 20:18:15 +01:00
|
|
|
*) echo "$arg: didn't read" ;;
|
|
|
|
esac; done
|
|
|
|
|
2016-12-20 17:29:54 +01:00
|
|
|
#******************************************************************************#
|
2017-01-04 23:08:47 +01:00
|
|
|
# Little things #
|
2016-12-20 17:29:54 +01:00
|
|
|
#******************************************************************************#
|
2017-01-04 23:08:47 +01:00
|
|
|
# Cross-compilation things
|
|
|
|
if [ ! $prefix_set ] && [ $target ]; then
|
|
|
|
prefix="$prefix"/"$target"
|
2016-12-20 17:29:54 +01:00
|
|
|
fi
|
|
|
|
|
2017-01-27 21:49:04 +01:00
|
|
|
# Check MS-Windows targets
|
|
|
|
win_target=
|
|
|
|
case "$target" in *-mingw32) if [ ! "$static" ]; then
|
|
|
|
windows=y; win_target=y
|
|
|
|
fi;; esac
|
|
|
|
|
2017-01-04 23:08:47 +01:00
|
|
|
# Evaluate variables
|
2017-03-18 12:57:14 +01:00
|
|
|
vars="prefix bindir libdir pkgdir includedir mandir hprefix hbindir"
|
2017-01-27 21:49:04 +01:00
|
|
|
for var in $vars; do
|
2016-10-30 20:18:15 +01:00
|
|
|
eval $var'='$(eval 'echo $'$var)
|
|
|
|
done
|
|
|
|
|
2017-01-27 21:49:04 +01:00
|
|
|
# Check that static and MS-Windows are not asked.
|
|
|
|
if [ "$static" ] && [ "$windows" ]; then
|
|
|
|
cat >&2 <<EOF
|
|
|
|
Sadly, there is no equivalent of MSVC's LIB.EXE for GNU/Linux.
|
|
|
|
If you know one, contact the maintainer: see \`./configure --help\`.
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that MS-Windows has a target.
|
|
|
|
if [ "$windows" ] && [ ! "$target" ]; then
|
|
|
|
cat >&2 <<EOF
|
|
|
|
You have selected the --windows option, but have selected no target.
|
|
|
|
If you want to build for native use, use a mingw32/mingw64 target.
|
|
|
|
If you want to build for a cross-compiling use, specify an other target!
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if is on Cygwin
|
|
|
|
[ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] && windows=y
|
|
|
|
|
|
|
|
# Check that MS-Windows has a mingw* target.
|
|
|
|
if [ "$windows" ] && [ ! "$win_target" ]; then
|
|
|
|
cat >&2 <<EOF
|
|
|
|
You have selected the --windows option, but have not selected a mingw32/mingw64
|
2017-02-24 02:29:56 +01:00
|
|
|
BFD target. We supposed that it is because you are compiling libg1m for a
|
2017-01-27 21:49:04 +01:00
|
|
|
cross-compiler compiled for MS-Windows (that's why configuration won't fail).
|
|
|
|
|
|
|
|
If it is not, please reconfigure to use a mingw32/mingw64 toolchain!
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
#******************************************************************************#
|
|
|
|
# Create Makefile configuration #
|
|
|
|
#******************************************************************************#
|
2017-01-27 21:49:04 +01:00
|
|
|
# Clean before
|
|
|
|
make mrproper MAKE_FULL_LOG=y 1>/dev/null 2>/dev/null
|
|
|
|
|
|
|
|
# Create the configuration header
|
2017-02-24 02:18:10 +01:00
|
|
|
tools/write-header-config --version=${version} \
|
|
|
|
--maintainer="$(echo ${maintainer} | sed 's/"/\\"/g')" \
|
|
|
|
$([ "$no_file" ] && echo --no-file) \
|
|
|
|
>include/${name}/config.h
|
2017-01-27 21:49:04 +01:00
|
|
|
|
|
|
|
# Do it!
|
2016-11-23 08:23:29 +01:00
|
|
|
exec 3>&1 1>Makefile.cfg
|
2016-10-30 20:18:15 +01:00
|
|
|
cat <<EOF
|
|
|
|
#!/usr/bin/make -f
|
2016-11-23 08:23:29 +01:00
|
|
|
#******************************************************************************#
|
|
|
|
# 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
|
2017-01-27 21:49:04 +01:00
|
|
|
MORE_WARNINGS := $more_warnings
|
|
|
|
FOR_WINDOWS := $windows
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# Build options
|
2017-01-27 21:49:04 +01:00
|
|
|
STATIC := $static
|
2016-12-20 12:27:36 +01:00
|
|
|
TARGET = $target
|
2017-01-27 21:49:04 +01:00
|
|
|
OPTIMIZE_SIZE := $optimize_size
|
2016-10-30 20:18:15 +01:00
|
|
|
LOG_LEVEL = $loglevel
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# Installation directories
|
2017-03-18 12:57:14 +01:00
|
|
|
HBINDIR = $hbindir
|
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
|
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
# Installation options
|
|
|
|
INSTALL_MANPAGES = $install_manpages
|
|
|
|
INSTALL_DEVEL = $install_devel
|
|
|
|
|
2017-01-27 21:49:04 +01:00
|
|
|
# Other tweaks
|
|
|
|
CMOREFLAGS := $cflags
|
|
|
|
LDMOREFLAGS := $ldflags
|
|
|
|
|
2016-11-23 08:23:29 +01:00
|
|
|
# End of file.
|
|
|
|
EOF
|
2016-10-30 20:18:15 +01:00
|
|
|
exec 1>&3 3>&-
|
2016-11-23 08:23:29 +01:00
|
|
|
chmod +x Makefile.cfg
|
2016-10-30 20:18:15 +01:00
|
|
|
|
2017-01-27 21:49:04 +01:00
|
|
|
# Print the end message.
|
2016-10-30 20:18:15 +01:00
|
|
|
echo "Configuration loaded, you can make now."
|
2016-11-23 08:23:29 +01:00
|
|
|
|
|
|
|
# End of file.
|