#!/bin/sh

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

case "$1" in
--help | -h)
	usage
	exit 0
	;;
--version)
	echo "0.0.0-0-g0000000000000000000000000000000000000000"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux --disable-stats --disable-tcache --disable-fill --disable-cxx --prefix=/ --with-jemalloc-prefix=je_ build_alias=x86_64-linux host_alias=arm-openwrt-linux target_alias=arm-openwrt-linux CC=arm-openwrt-linux-muslgnueabi-gcc 'LIBS=-lpthread -ldl'"
	;;
--prefix)
	echo "/"
	;;
--bindir)
	echo "//bin"
	;;
--datadir)
	echo "//share"
	;;
--includedir)
	echo "//include"
	;;
--libdir)
	echo "//lib"
	;;
--mandir)
	echo "//share/man"
	;;
--cc)
	echo "arm-openwrt-linux-muslgnueabi-gcc"
	;;
--cflags)
	echo "-std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -pipe -g3 -fvisibility=hidden -O3 -funroll-loops"
	;;
--cppflags)
	echo "-D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo ""
	;;
--ldflags)
	echo " "
	;;
--libs)
	echo "-lpthread -ldl -pthread"
	;;
*)
	usage
	exit 1
esac
