#!/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 "--target=aarch64-openwrt-linux --host=aarch64-openwrt-linux --build=x86_64-pc-linux-gnu --disable-dependency-tracking --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --enable-shared --disable-static --enable-prof --enable-prof-libunwind --enable-readlinkat build_alias=x86_64-pc-linux-gnu host_alias=aarch64-openwrt-linux target_alias=aarch64-openwrt-linux CC=aarch64-openwrt-linux-musl-gcc 'CFLAGS=-Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/home/ncasu/disks/sdk/build_dir/target-aarch64_cortex-a53_musl/jemalloc-5.3.0=jemalloc-5.3.0 -Wl,-z,max-page-size=4096 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs ' 'LDFLAGS=-L/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -zmax-page-size=4096 -znow -zrelro -zpack-relative-relocs ' 'CPPFLAGS=-I/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/include -I/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/include -I/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/include/fortify ' CXX=aarch64-openwrt-linux-musl-g++ 'CXXFLAGS=-Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/home/ncasu/disks/sdk/build_dir/target-aarch64_cortex-a53_musl/jemalloc-5.3.0=jemalloc-5.3.0 -Wl,-z,max-page-size=4096 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs '"
	;;
--prefix)
	echo "/usr"
	;;
--bindir)
	echo "/usr/bin"
	;;
--datadir)
	echo "/usr/share"
	;;
--includedir)
	echo "/usr/include"
	;;
--libdir)
	echo "/usr/lib"
	;;
--mandir)
	echo "/usr/man"
	;;
--cc)
	echo "aarch64-openwrt-linux-musl-gcc -std=gnu23"
	;;
--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 -O3 -funroll-loops -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/home/ncasu/disks/sdk/build_dir/target-aarch64_cortex-a53_musl/jemalloc-5.3.0=jemalloc-5.3.0 -Wl,-z,max-page-size=4096 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs "
	;;
--cppflags)
	echo "-I/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/include -I/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/include -I/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/include/fortify  -D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/home/ncasu/disks/sdk/build_dir/target-aarch64_cortex-a53_musl/jemalloc-5.3.0=jemalloc-5.3.0 -Wl,-z,max-page-size=4096 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs "
	;;
--ldflags)
	echo "-L/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/ncasu/disks/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -zmax-page-size=4096 -znow -zrelro -zpack-relative-relocs  "
	;;
--libs)
	echo "-lstdc++ -lunwind -pthread"
	;;
*)
	usage
	exit 1
esac
