#!/bin/sh

print_help()
{
  echo "Usage: mruby-config [switches]"
  echo "  switches:"
  echo "  --cc                        print compiler name"
  echo "  --cflags                    print flags passed to compiler"
  echo "  --ld                        print linker name"
  echo "  --ldflags                   print flags passed to linker"
  echo "  --ldflags-before-libs       print flags passed to linker before linked libraries"
  echo "  --libs                      print linked libraries"
  echo "  --libmruby-path             print libmruby path"
  echo "  --help                      print this help"
  exit 0
}

if [ $# -eq 0 ]; then
   print_help
fi

while [ $# -gt 0 ]; do
  case $1 in
    --cc) echo gcc;;
    --cflags) echo -std=gnu99 -march=armv7-a -mfloat-abi=hard -mfpu=neon -O2 -pipe -fstack-protector-strong -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -ffat-lto-objects -DMRB_USE_RATIONAL -DMRB_USE_COMPLEX -I"/build/mruby/src/mruby-3.1.0/include" -I"/build/mruby/src/mruby-3.1.0/build/host/include" -I"/build/mruby/src/mruby-3.1.0/mrbgems/mruby-time/include" -I"/build/mruby/src/mruby-3.1.0/mrbgems/mruby-io/include";;
    --ld) echo gcc;;
    --ldflags) echo -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/build/mruby/src/mruby-3.1.0/build/host/lib;;
    --ldflags-before-libs) ;;
    --libs) echo -lmruby -lm;;
    --libmruby-path) echo /build/mruby/src/mruby-3.1.0/build/host/lib/libmruby.a;;
    *) print_help;;
  esac
  shift
done
