Source

mirage2iso / configure

#!/bin/sh
# mirage2iso
# (c) 2009 Michał Górny
# released under 3-clause BSD license

conf_check() {
	if [ -z "$1" ]; then
		echo "#define $2 1"
		echo "$3 explicitly disabled." >&2
	elif [ -f "$1" ]; then
		echo "$3 found." >&2
	else
		echo "#define $2 1"
		echo "$3 unavailable." >&2
	fi
}

conf_results() {
	conf_check check-getopt.o NO_GETOPT_LONG 'getopt_long()'
	conf_check check-sysexits.o NO_SYSEXITS '<sysexits.h>'
	conf_check check-mmapio.o NO_MMAPIO 'mmap() & ftruncate()'
	conf_check check-termios.o NO_TERMIOS 'termios'
	conf_check "${ASSUAN2_CHECK}" NO_ASSUAN2 'assuan-2'
	if [ ! -f "${ASSUAN2_CHECK}" ]; then
		conf_check "${ASSUAN_CHECK}" NO_ASSUAN 'assuan'
	fi
}

conf_help() {
	cat <<_EOF_
Synopsis:
	./configure [options]

Options:
	--prefix=DIR		Prefix used to install arch-independent files
				(\${PREFIX}, default: /usr/local)
	--exec-prefix=DIR	Prefix used to install arch-dependent files
				(\${EPREFIX}, default: \${PREFIX})
	--bindir=DIR		Path to install user binaries
				(\${BINDIR}, default: \${EPREFIX}/bin)

	--without-assuan	Disable use of assuan

_EOF_
}

# parse command-line arguments

while [ $# -gt 0 ]; do
	case "$1" in
		--prefix=*)
			PREFIX=${1#--prefix=}
			;;
		--exec-prefix=*)
			EPREFIX=${1#--eprefix=}
			;;
		--bindir=*)
			BINDIR=${1#--bindir=}
			;;
		--with-assuan)
			WITH_ASSUAN=1
			;;
		--without-assuan)
			WITH_ASSUAN=0
			;;
		--help)
			conf_help
			exit 1
	esac

	shift
done

: ${PREFIX=/usr/local}
: ${EPREFIX=${PREFIX}}
: ${BINDIR=${EPREFIX}/bin}

: ${WITH_ASSUAN:=1}

if ! pkg-config --exists libmirage; then
	echo "Your pkg-config is unable to find libmirage." >&2
	echo >&2
	echo "To be able to build mirage2iso, you need to have both pkg-config" >&2
	echo "and libmirage with development headers installed." >&2
	exit 1
else
	echo 'libmirage found.'
fi

MAKEIN=Makefile.in

if [ ${WITH_ASSUAN} -eq 1 ]; then
	# Both can fail
	ASSUAN_CPPFLAGS=$(libassuan-config --cflags 2>/dev/null)
	ASSUAN_LIBS=$(libassuan-config --libs 2>/dev/null)
	: ${ASSUAN_LIBS:=-lassuan} # fallback

	ASSUAN2_CHECK='check-assuan2'
	ASSUAN_CHECK='check-assuan'
fi

echo >&2
echo ">> calling 'make configure' to perform additional tests" >&2

make ${MAKEFLAGS:-${MAKEOPTS}} -f ${MAKEIN} -k \
	ASSUAN_CPPFLAGS="${ASSUAN_CPPFLAGS}" \
	ASSUAN_LIBS="${ASSUAN_LIBS}" \
	ASSUAN_CHECK="${ASSUAN2_CHECK} ${ASSUAN_CHECK}" \
	configure

echo "<< 'make configure' done" >&2
echo >&2

if [ -z "${ASSUAN_CHECK}" -o ! -f "${ASSUAN_CHECK}" ]; then
	if [ -z "${ASSUAN2_CHECK}" -o ! -f "${ASSUAN2_CHECK}" ]; then
		ASSUAN_CPPFLAGS=
		ASSUAN_LIBS=
	fi
fi

conf_results > mirage-config.h
make -f ${MAKEIN} confclean

cat - ${MAKEIN} << _EOF_ > ${MAKEIN%.in}
# autogenerated by configure, please modify Makefile.in instead

CONF_CPPFLAGS = $(pkg-config --cflags libmirage) ${ASSUAN_CPPFLAGS}
CONF_LDFLAGS = $(pkg-config --libs-only-L --libs-only-other libmirage)
CONF_LIBS = $(pkg-config --libs-only-l libmirage) ${ASSUAN_LIBS}

BINDIR = ${BINDIR}

_EOF_

echo >&2
echo Done. >&2

exit 0
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.