#!/bin/sh
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
CFLAGS=""
CPPFLAGS="-I@includedir@"
CXXFLAGS=""
OBJC="@OBJC@"
OBJCFLAGS="@GNU_RUNTIME@ -fexceptions -fobjc-exceptions"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstString"
OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@ @NO_WARN_UNUSED@ @ATOMIC_OBJCFLAGS@"
LDFLAGS=""
LDFLAGS_REEXPORT="@LDFLAGS_REEXPORT@"
LDFLAGS_RPATH="@LDFLAGS_RPATH@"
LIBS="-L${libdir} -lobjfw @LIBS@"
VERSION="0.4-dev"

show_help() {
	cat <<__EOF__
objfw-config: Available arguments are:

	--all		Outputs all flags + libs
	--cflags	Outputs the required CFLAGS
	--cppflags	Outputs the required CPPFLAGS
	--cxxflags	Outputs the required CXXFLAGS
	--objc		Outputs the OBJC used to compile ObjFW
	--objcflags	Outputs the required OBJCFLAGS
	--ldflags	Outputs the required LDFLAGS
	--reexport	Outputs LDFLAGS to reexport ObjFW
	--rpath		Outputs LDFLAGS for using rpath
	--libs		Outputs the required LIBS
	--version	Outputs the installed version
__EOF__
	exit 0
}

test -z "$1" && show_help

while test ! -z "$1"; do
	case "$1" in
		--all)
			echo "$CFLAGS"
			echo "$CPPFLAGS"
			echo "$CXXFLAGS"
			echo "$OBJCFLAGS"
			echo "$LDFLAGS"
			echo "$LDFLAGS_REEXPORT"
			echo "$LDFLAGS_RPATH"
			echo "$LIBS"
			;;
		--cflags)
			echo "$CFLAGS"
			;;
		--cppflags)
			echo "$CPPFLAGS"
			;;
		--cxxflags)
			echo "$CXXFLAGS"
			;;
		--objc)
			echo "$OBJC"
			;;
		--objcflags)
			echo "$OBJCFLAGS"
			;;
		--libs)
			echo "$LIBS"
			;;
		--ldflags)
			echo "$LDFLAGS"
			;;
		--reexport)
			echo "$LDFLAGS_REEXPORT"
			;;
		--rpath)
			echo "$LDFLAGS_RPATH"
			;;
		--version)
			echo "$VERSION"
			;;
		*)
			echo "Invalid option: $1" 1>&2
			exit 1
			;;
	esac

	shift
done
