#!/bin/sh

usage() {
	cat <<EOF
Usage:
  /opt/local/bin/jemalloc-config <option>
Options:
  --help | -h  : Print usage.
  --version    : Print jemalloc version.
  --revision   : Print shared library revision number.
  --config     : Print configure options used to build jemalloc.
  --prefix     : Print installation directory prefix.
  --bindir     : Print binary installation directory.
  --datadir    : Print data installation directory.
  --includedir : Print include installation directory.
  --libdir     : Print library installation directory.
  --mandir     : Print manual page installation directory.
  --cc         : Print compiler used to build jemalloc.
  --cflags     : Print compiler flags used to build jemalloc.
  --cppflags   : Print preprocessor flags used to build jemalloc.
  --cxxflags   : Print C++ compiler flags used to build jemalloc.
  --ldflags    : Print library flags used to build jemalloc.
  --libs       : Print libraries jemalloc was linked against.
EOF
}

prefix="/opt/local"
exec_prefix="/opt/local"

case "$1" in
--help | -h)
	usage
	exit 0
	;;
--version)
	echo "0.0.0-0-g000000missing_version_try_git_fetch_tags"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--prefix=/opt/local --with-jemalloc-prefix= CC=/opt/local/bin/gcc-mp-13 'CFLAGS=-pipe -Os -arch ppc' 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc' CPPFLAGS=-I/opt/local/include CXX=/opt/local/bin/g++-mp-13 'CXXFLAGS=-pipe -Os -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc'"
	;;
--prefix)
	echo "/opt/local"
	;;
--bindir)
	echo "/opt/local/bin"
	;;
--datadir)
	echo "/opt/local/share"
	;;
--includedir)
	echo "/opt/local/include"
	;;
--libdir)
	echo "/opt/local/lib"
	;;
--mandir)
	echo "/opt/local/share/man"
	;;
--cc)
	echo "/opt/local/bin/gcc-mp-13"
	;;
--cflags)
	echo "-std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -Wno-missing-attributes -pipe -g3 -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -funroll-loops -pipe -Os -arch ppc"
	;;
--cppflags)
	echo "-I/opt/local/include -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -pipe -Os -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc"
	;;
--ldflags)
	echo "-L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc "
	;;
--libs)
	echo "-lstdc++ -pthread"
	;;
*)
	usage
	exit 1
esac
