#!/bin/sh

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

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 "--build=x86_64-linux-musl --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --libexecdir=/usr/libexec --mandir=/usr/share/man --enable-shared --disable-static --with-pic build_alias=x86_64-linux-musl CC=x86_64-linux-musl-gcc 'CFLAGS=-O2 -pipe -march=x86-64 -std=gnu17 -I/usr/include -fPIC -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection' 'LDFLAGS=-L/usr/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' CPPFLAGS=-I/usr/include CXX=x86_64-linux-musl-g++ 'CXXFLAGS=-O2 -pipe -march=x86-64 -std=gnu++17 -I/usr/include -fPIC -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection'"
	;;
--prefix)
	echo "/usr"
	;;
--bindir)
	echo "/usr/bin"
	;;
--datadir)
	echo "/usr/share"
	;;
--includedir)
	echo "/usr/include"
	;;
--libdir)
	echo "/usr/lib"
	;;
--mandir)
	echo "/usr/share/man"
	;;
--cc)
	echo "x86_64-linux-musl-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 -g3 -fvisibility=hidden -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -funroll-loops -O2 -pipe -march=x86-64 -std=gnu17 -I/usr/include -fPIC -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection"
	;;
--cppflags)
	echo "-I/usr/include -D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -fvisibility=hidden -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -O2 -pipe -march=x86-64 -std=gnu++17 -I/usr/include -fPIC -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection"
	;;
--ldflags)
	echo "-L/usr/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now "
	;;
--libs)
	echo "-lstdc++ -pthread"
	;;
*)
	usage
	exit 1
esac
