#!/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 "5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--build=loongarch64-aosc-linux-gnu --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --bindir=/usr/bin --sbindir=/usr/bin --mandir=/usr/share/man --enable-option-checking=fatal build_alias=loongarch64-aosc-linux-gnu CC=gcc 'CFLAGS=-pipe -Wno-error -fstack-protector-strong --param=ssp-buffer-size=4 -fexceptions -ggdb -fira-loop-pressure -fira-hoist-pressure -O2 -fno-omit-frame-pointer -flto=auto -ffat-lto-objects -mabi=lp64d -mno-strict-align -march=la64v1.0 -mtune=la664' 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed -Wl,-build-id=sha1 -Wl,-z,relro -Wl,-z,now -flto -fuse-linker-plugin -Wl,-z,pack-relative-relocs' 'CPPFLAGS=-D_GLIBCXX_ASSERTIONS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -O2' CXX=g++ 'CXXFLAGS=-ggdb -fno-permissive -fdeclone-ctor-dtor -pipe -Wno-error -fstack-protector-strong --param=ssp-buffer-size=4 -fexceptions -ggdb -fira-loop-pressure -fira-hoist-pressure -O2 -fno-omit-frame-pointer -flto=auto -ffat-lto-objects -mabi=lp64d -mno-strict-align -march=la64v1.0 -mtune=la664'"
	;;
--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 "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 -pipe -Wno-error -fstack-protector-strong --param=ssp-buffer-size=4 -fexceptions -ggdb -fira-loop-pressure -fira-hoist-pressure -O2 -fno-omit-frame-pointer -flto=auto -ffat-lto-objects -mabi=lp64d -mno-strict-align -march=la64v1.0 -mtune=la664"
	;;
--cppflags)
	echo "-D_GLIBCXX_ASSERTIONS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -O2 -D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -fvisibility=hidden -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -ggdb -fno-permissive -fdeclone-ctor-dtor -pipe -Wno-error -fstack-protector-strong --param=ssp-buffer-size=4 -fexceptions -ggdb -fira-loop-pressure -fira-hoist-pressure -O2 -fno-omit-frame-pointer -flto=auto -ffat-lto-objects -mabi=lp64d -mno-strict-align -march=la64v1.0 -mtune=la664"
	;;
--ldflags)
	echo "-Wl,-O1,--sort-common,--as-needed -Wl,-build-id=sha1 -Wl,-z,relro -Wl,-z,now -flto -fuse-linker-plugin -Wl,-z,pack-relative-relocs "
	;;
--libs)
	echo "-lm -lstdc++ -pthread"
	;;
*)
	usage
	exit 1
esac
