#!/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=/usr/bin/clang 'CFLAGS=-pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64' 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64' 'CPPFLAGS=-I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk' CXX=/usr/bin/clang++ 'CXXFLAGS=-pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64'"
	;;
--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 "/usr/bin/clang"
	;;
--cflags)
	echo "-std=gnu11 -Werror=unknown-warning-option -Wall -Wextra -Wshorten-64-to-32 -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -pipe -g3 -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -funroll-loops -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64"
	;;
--cppflags)
	echo "-I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64"
	;;
--ldflags)
	echo "-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64 "
	;;
--libs)
	echo "-lstdc++ -pthread"
	;;
*)
	usage
	exit 1
esac
