#!/bin/sh

usage() {
	cat <<EOF
Usage:
  /usr/pkg/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="/usr/pkg"
exec_prefix="/usr/pkg"

case "$1" in
--help | -h)
	usage
	exit 0
	;;
--version)
	echo "5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--enable-xmalloc --with-xslroot=/usr/pkg/share/xsl/docbook/ --prefix=/usr/pkg --build=aarch64--netbsd --host=aarch64--netbsd --mandir=/usr/pkg/man --enable-option-checking=yes build_alias=aarch64--netbsd host_alias=aarch64--netbsd CC=gcc CFLAGS=-O2 'LDFLAGS=-Wl,-zrelro -Wl,-R/usr/pkg/lib' LIBS= CPPFLAGS= CXX=c++ CXXFLAGS=-O2"
	;;
--prefix)
	echo "/usr/pkg"
	;;
--bindir)
	echo "/usr/pkg/bin"
	;;
--datadir)
	echo "/usr/pkg/share"
	;;
--includedir)
	echo "/usr/pkg/include"
	;;
--libdir)
	echo "/usr/pkg/lib"
	;;
--mandir)
	echo "/usr/pkg/man"
	;;
--cc)
	echo "gcc"
	;;
--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 -fvisibility=hidden -Wimplicit-fallthrough -O2"
	;;
--cppflags)
	echo "-D_REENTRANT"
	;;
--cxxflags)
	echo "-O2"
	;;
--ldflags)
	echo "-Wl,-zrelro -Wl,-R/usr/pkg/lib "
	;;
--libs)
	echo "-lm  -pthread"
	;;
*)
	usage
	exit 1
esac
