#!/usr/bin/env bash
# -*- sh-indentation: 3 -*-
# This script returns the machine dependent compile options needed
# to compile and link applications using the ROOT libraries.
#
# Author: Fons Rademakers, 06/06/99

readlink=readlink
if [ `uname` = "AIX" ]; then
   readlink=echo
fi

# work around readlink versions not having -f option
fullpath1=`$readlink $0`
if [ "$?" -ne "0" ]; then
   fullpath1=$0
else
   if [ ${fullpath1##/} = $fullpath1 ] && [ ${fullpath1##~} = $fullpath1 ]; then
      # relative path, prepend directory where executable was found
      lpath=`dirname $0`
      fullpath1=$lpath/$fullpath1
   fi
fi
progdir=`dirname $fullpath1`
runningdir=`pwd`
if [ ${progdir##/} != $progdir ] || [ ${progdir##~} != $progdir ]; then
   # absolute path
   fullpath=$progdir
else
   # relative path
   if [ $progdir != "." ]; then
      fullpath=$runningdir/$progdir
   else
      fullpath=$runningdir
   fi
fi
# work around readlink versions not having -f option
fullpath1=`$readlink $fullpath`
if [ "$?" -ne "0" ]; then
   fullpath1=$fullpath
fi
ROOTSYS=`dirname $fullpath1`

arch=macosxarm64
platform=macosx
bindir=$ROOTSYS/bin
libdir=$ROOTSYS/lib
incdir=$ROOTSYS/include
etcdir=$ROOTSYS/etc
tutdir=$ROOTSYS/tutorials
all_features=""
features="cxx14  asimage builtin_afterimage builtin_cfitsio builtin_clang builtin_cling builtin_cppzmq builtin_davix builtin_fftw3 builtin_freetype builtin_ftgl builtin_gl2ps builtin_glew builtin_gsl builtin_llvm builtin_lz4 builtin_lzma builtin_nlohmannjson builtin_openssl builtin_openui5 builtin_pcre builtin_tbb builtin_unuran builtin_vc builtin_vdt builtin_veccore builtin_xrootd builtin_xxhash builtin_zeromq builtin_zstd clad cocoa dataframe davix exceptions fftw3 fitsio gdml http imt libcxx mathmore mlp minuit2 opengl pyroot roofit roofit_multiprocess rpath runtime_cxxmodules shared soversion sqlite ssl tmva tmva-cpu tmva-pymva spectrum unuran vc vdt veccore xml xrootd"
configargs="BLAS_Accelerate_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Accelerate.framework BLAS_blas_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libblas.tbd CURL_INCLUDE_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include CURL_LIBRARY_RELEASE=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libcurl.tbd DAVIX_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/davix/DAVIX-prefix/include/davix DAVIX_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/davix/DAVIX-prefix/include/davix DAVIX_LIBRARY=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/davix/DAVIX-prefix/lib/libdavix.a GLEW_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/glew/inc GLEW_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/glew/inc GLEW_LIBRARIES=GLEW::GLEW GLEW_LIBRARY=$<TARGET_FILE:GLEW> LIBXML2_INCLUDE_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/libxml2 LIBXML2_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libxml2.tbd LZ4_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/lz4 LZ4_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/lz4 LZ4_LIBRARIES=LZ4::LZ4 LZ4_LIBRARY=$<TARGET_FILE:lz4> LZ4_VERSION=1.9.3 LZ4_VERSION_STRING=1.9.3 NUMPY_INCLUDE_DIRS=/Users/sftnight/Library/Python/3.8/lib/python/site-packages/numpy/core/include OPENGL_INCLUDE_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework OPENGL_gl_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework OPENGL_glu_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework OPENSSL_CRYPTO_LIBRARY=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/openssl/OPENSSL-prefix/lib/libcrypto.a OPENSSL_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/openssl/OPENSSL-prefix/include OPENSSL_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/openssl/OPENSSL-prefix/include OPENSSL_SSL_LIBRARY=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/openssl/OPENSSL-prefix/lib/libssl.a OPENSSL_VERSION=1.1.1g OPENSSL_VERSION_STRING=1.1.1g PCRE_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/pcre/PCRE-prefix/src/PCRE-build PCRE_LIBRARIES=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/pcre/PCRE-prefix/src/PCRE-build/./libpcre.a PCRE_PCRE_LIBRARY=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/pcre/PCRE-prefix/src/PCRE-build/./libpcre.a PCRE_VERSION=8.43 PNG_LIBRARY_RELEASE=/usr/X11R6/lib/libpng.dylib PNG_PNG_INCLUDE_DIR=/usr/X11R6/include PYTHON_INCLUDE_DIRS=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 PYTHON_LIBRARIES=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/libpython3.8.dylib PYTHON_LIBRARY_DIR=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib PYTHON_VERSION_MAJOR=3 PYTHON_VERSION_MINOR=8 PYTHON_VERSION_STRING=3.8.2 SQLITE_INCLUDE_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include SQLITE_LIBRARIES=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libsqlite3.tbd UUID_INCLUDE_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include XROOTD_LIBRARY=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/xrootd/XROOTD-prefix/lib/ XROOTD_VERSIONNUM=500040001 ZLIB_INCLUDE_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include ZLIB_LIBRARY_RELEASE=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libz.tbd ZSTD_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/zstd ZSTD_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/zstd ZSTD_LIBRARIES=ZSTD::ZSTD ZSTD_LIBRARY=$<TARGET_FILE:ZSTD> ZSTD_VERSION=1.4.8 ZSTD_VERSION_STRING=1.4.8 ZeroMQ_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/zeromq/libzmq/BUILTIN_ZeroMQ-prefix/include ZeroMQ_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/zeromq/libzmq/BUILTIN_ZeroMQ-prefix/include ZeroMQ_LIBRARIES=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/zeromq/libzmq/BUILTIN_ZeroMQ-prefix/lib/libzmq.a ZeroMQ_LIBRARY=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/zeromq/libzmq/BUILTIN_ZeroMQ-prefix/lib/libzmq.a cppzmq_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/zeromq/cppzmq/BUILTIN_cppzmq-prefix/src/BUILTIN_cppzmq cppzmq_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/build/builtins/zeromq/cppzmq/BUILTIN_cppzmq-prefix/src/BUILTIN_cppzmq xxHash_INCLUDE_DIR=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/xxhash xxHash_INCLUDE_DIRS=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root/builtins/xxhash xxHash_LIBRARIES=xxHash::xxHash xxHash_LIBRARY=$<TARGET_FILE:xxhash> xxHash_VERSION=0.8.0 xxHash_VERSION_STRING=0.8.0 "
altcc="cc"
altcxx="c++"
altf77="CMAKE_Fortran_COMPILER-NOTFOUND"
altld="c++"

if test "$platform" = "win32"; then
   if [ "x$ROOTSYS" != "x" ]; then
      unixROOTSYS=`cygpath -u $ROOTSYS`
   else
      unixROOTSYS=.
   fi
   bindir=$unixROOTSYS/bin
   libdir=$unixROOTSYS/lib
   incdir=$unixROOTSYS/include
   etcdir=$unixROOTSYS/etc
fi

### ROOT libraries ###

newlib="-lNew"
rootglibs="-lGui"
rootevelibs="-lEve -lEG -lGeom -lGed -lRGL"
rootlibs="-lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer\
          -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread"

# MultiProc is not supported on Windows
if test "$platform" != "win32"; then
   rootlibs="$rootlibs -lMultiProc"
fi

if echo "${features}" | grep -q "dataframe"; then
   rootlibs="$rootlibs -lROOTDataFrame"
fi

if test "$platform" = "win32"; then
   rootulibs="-include:_G__cpp_setupG__Net        \
              -include:_G__cpp_setupG__IO         \
              -include:_G__cpp_setupG__Hist       \
              -include:_G__cpp_setupG__Graf       \
              -include:_G__cpp_setupG__G3D        \
              -include:_G__cpp_setupG__GPad       \
              -include:_G__cpp_setupG__Tree       \
              -include:_G__cpp_setupG__TreePlayer \
              -include:_G__cpp_setupG__Thread     \
              -include:_G__cpp_setupG__Rint       \
              -include:_G__cpp_setupG__PostScript \
              -include:_G__cpp_setupG__Matrix     \
              -include:_G__cpp_setupG__Physics"
   rootuglibs="-include:_G__cpp_setupG__Gui1"
   rootuevelibs="-include:_G__cpp_setupG__EG         \
                 -include:_G__cpp_setupG__Geom1      \
                 -include:_G__cpp_setupG__Ged        \
                 -include:_G__cpp_setupG__GL         \
                 -include:_G__cpp_setupG__Eve1"
elif test "$platform" = "aix5"; then
   rootulibs="-Wl,-u,.G__cpp_setupG__Net        \
              -Wl,-u,.G__cpp_setupG__IO         \
              -Wl,-u,.G__cpp_setupG__Hist       \
              -Wl,-u,.G__cpp_setupG__Graf       \
              -Wl,-u,.G__cpp_setupG__G3D        \
              -Wl,-u,.G__cpp_setupG__GPad       \
              -Wl,-u,.G__cpp_setupG__Tree       \
              -Wl,-u,.G__cpp_setupG__TreePlayer \
              -Wl,-u,.G__cpp_setupG__Thread     \
              -Wl,-u,.G__cpp_setupG__Rint       \
              -Wl,-u,.G__cpp_setupG__PostScript \
              -Wl,-u,.G__cpp_setupG__Matrix     \
              -Wl,-u,.G__cpp_setupG__Physics"
   rootuglibs="-Wl,-u,.G__cpp_setupG__Gui1"
   rootuevelibs="-Wl,-u,.G__cpp_setupG__EG         \
                 -Wl,-u,.G__cpp_setupG__Geom1      \
                 -Wl,-u,.G__cpp_setupG__Ged        \
                 -Wl,-u,.G__cpp_setupG__GL         \
                 -Wl,-u,.G__cpp_setupG__Eve1"
else
   rootulibs="-Wl,-u,_G__cpp_setupG__Net           \
              -Wl,-u,_G__cpp_setupG__IO            \
              -Wl,-u,_G__cpp_setupG__Hist          \
              -Wl,-u,_G__cpp_setupG__Graf          \
              -Wl,-u,_G__cpp_setupG__G3D           \
              -Wl,-u,_G__cpp_setupG__GPad          \
              -Wl,-u,_G__cpp_setupG__Tree          \
              -Wl,-u,_G__cpp_setupG__TreePlayer    \
              -Wl,-u,_G__cpp_setupG__Thread        \
              -Wl,-u,_G__cpp_setupG__Rint          \
              -Wl,-u,_G__cpp_setupG__PostScript    \
              -Wl,-u,_G__cpp_setupG__Matrix        \
              -Wl,-u,_G__cpp_setupG__Physics"
   rootuglibs="-Wl,-u,_G__cpp_setupG__Gui1"
   rootuevelibs="-Wl,-u,_G__cpp_setupG__EG         \
                 -Wl,-u,_G__cpp_setupG__Geom1      \
                 -Wl,-u,_G__cpp_setupG__Ged        \
                 -Wl,-u,_G__cpp_setupG__GL         \
                 -Wl,-u,_G__cpp_setupG__Eve1"
fi

### machine dependent settings ###

# Set the C++ standard version
cxxversionflag="-std=c++14 "

case $arch in
aix5)
   # IBM AIX
   auxcflags="-qnoro -qnoroconst -qmaxmem=-1 -qrtti=all"
   auxlibs=
   #forcelibs=$rootulibs
   #forceglibs=$rootuglibs
   #forceevelibs=$rootuevelibs
   ;;
aixgcc)
   # IBM AIX with g++
   auxcflags="${cxxversionflag} -fsigned-char"
   auxlibs=
   #forcelibs=$rootulibs
   #forceglibs=$rootuglibs
   #forceevelibs=$rootuevelibs
   ;;
solarisgcc)
   # Solaris g++ 2.8.x
   auxcflags="${cxxversionflag}"
   auxlibs="-L/usr/ccs/lib -lm -lsocket -lgen -ldl"
   ;;
solarisCC5)
   # Solaris CC 5.0
   if [ `uname -p` = "i386" ]; then
      auxcflags="${cxxversionflag} -library=stlport4"
      auxldflags="-library=stlport4"
   else
      auxcflags="${cxxversionflag}"
      auxldflags=
   fi
   auxlibs="-lm -ldl -lnsl -lsocket"
   ;;
solaris64CC5)
   # Solaris CC 5.0 x86-64
   auxcflags="${cxxversionflag} -m64 -library=stlport4"
   auxldflags="-m64 -library=stlport4"
   auxlibs="-lm -ldl -lnsl -lsocket"
   ;;
linux)
   # Linux with gcc >= 3.x
   auxcflags="${cxxversionflag} -m32 -msse -mfpmath=sse "
   auxldflags="-m32 -msse -mfpmath=sse "
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxicc)
   # Linux with the Intel icc compiler
   auxcflags="${cxxversionflag}"
   auxlibs="-limf -lm -ldl"
   ;;
linuxppcgcc)
   # PPC Linux with gcc
   auxcflags="${cxxversionflag} -m32 -fsigned-char"
   auxldflags="-m32"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxppc64gcc)
   # PPC64/PPC64LE (64 bit mode) Linux with gcc
   auxcflags="${cxxversionflag} -m64 -fsigned-char"
   auxldflags="-m64"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxx8664gcc)
   # AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x
   auxcflags="${cxxversionflag} -m64"
   auxldflags="-m64"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxx8664icc)
   # AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc
   auxcflags="${cxxversionflag}"
   auxlibs="-limf -lm -ldl"
   ;;
linuxx8664k1omicc)
   # Intel Many Integrated Cores Architecture (Knights Corner) Linux with Intel icc
   auxcflags="${cxxversionflag} -mmic -I/usr/include"
   auxlibs="-limf -lm -ldl"
   ;;
linuxx32gcc)
   # x32 ABI (64 bit mode with 32 bit pointers) Linux with gcc > 4.7
   auxcflags="${cxxversionflag} -mx32"
   auxldflags="-mx32"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxarm)
   # ARM Linux with gcc
   auxcflags="${cxxversionflag} -fsigned-char"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxarm64)
   # ARMv8-A (AArch64) Linux with gcc
   auxcflags="${cxxversionflag} -fsigned-char"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxs390gcc)
   # s390 (31 bit mode) Linux with gcc
   auxcflags="${cxxversionflag} -m31 -fsigned-char"
   auxldflags="-m31"
   auxlibs="-lm -ldl -rdynamic"
   ;;
linuxs390xgcc)
   # s390x (64 bit mode) Linux with gcc
   auxcflags="${cxxversionflag} -m64 -fsigned-char"
   auxldflags="-m64"
   auxlibs="-lm -ldl -rdynamic"
   ;;
freebsd)
   # FreeBSD with libc5
   auxcflags="${cxxversionflag}"
   auxlibs="-lm -lg++"
   ;;
freebsd4)
   # FreeBSD 4 with glibc
   auxcflags="${cxxversionflag}"
   auxlibs="-lm -lstdc++"
   ;;
freebsd5|freebsd7)
   # FreeBSD 5/7 with glibc
   auxcflags="${cxxversionflag}"
   auxlibs="-lm -lstdc++"
   ;;
openbsd)
   # OpenBSD with libc
   auxcflags="${cxxversionflag}"
   auxlibs="-lm -lstdc++"
   ;;
macosx)
   # MacOS X with gcc (GNU cc v3.1) and possible fink (fink.sf.net)
   macosx_major=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 1 | sed -e 's/^[[:space:]]*//'`
   macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
   # cannot find the one linked to libGraf if relocated after built
   if [ $macosx_major -eq 10 -a $macosx_minor -le 4 ]; then
      rootlibs="$rootlibs -lfreetype"
   fi
   if [ $macosx_major -eq 10 -a $macosx_minor -le 3 ]; then
      finkdir=`which fink 2>&1 | sed -ne "s/\/bin\/fink//p"`
      auxcflags=`[ -d ${finkdir}/include ] && echo -I${finkdir}/include`
      auxcflags="-Wno-long-double $auxcflags"
      auxlibs="-lm `[ -d ${finkdir}/lib ] && echo -L${finkdir}/lib` -ldl"
      forcelibs=$rootulibs
      forceglibs=$rootuglibs
      forceevelibs=$rootuevelibs
   else
      auxcflags="${cxxversionflag} -m32"
      auxldflags="-m32"
      auxlibs="-lm -ldl"
   fi
   ;;
macosxicc)
   # MacOS X with Intel icc compiler
   macosx_major=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 1 | sed -e 's/^[[:space:]]*//'`
   macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
   # cannot find the one linked to libGraf if relocated after built
   if [ $macosx_major -eq 10 -a $macosx_minor -le 4 ]; then
      rootlibs="$rootlibs -lfreetype"
   fi
   auxcflags="${cxxversionflag}"
   auxlibs="-lm -ldl"
   ;;
macosx64|macosxarm64)
   # MacOS X with gcc (GNU cc v4.x) in 64 bit mode
   macosx_major=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 1 | sed -e 's/^[[:space:]]*//'`
   macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
   # cannot find the one linked to libGraf if relocated after built
   if [ $macosx_major -eq 10 -a $macosx_minor -le 4 ]; then
      rootlibs="$rootlibs -lfreetype"
   fi
   auxcflags="${cxxversionflag} -m64"
   auxldflags="-m64"
   auxlibs="-lm -ldl"
   ;;
hiux)
   # Hitachi HIUX
   auxcflags=
   auxlibs="-lm -ldld"
   ;;
win32)
   # Win32
   auxcflags="-MD"
   if test "xno" = "xyes"; then
      auxcflags="-MDd"
   fi
   VC_MAJOR=`unset VS_UNICODE_OUTPUT; cl.exe 2>&1 | awk '{ if (NR==1) print $(NF-2) }' | cut -d'.' -f1`
   if test "$VC_MAJOR" != "" && test $VC_MAJOR -gt 13; then
      auxcflags="$auxcflags -EHs -GR"
   else
      auxcflags="$auxcflags -GR -GX -G5"
   fi
   auxlibs=
   #forcelibs=$rootulibs
   #forceglibs=$rootuglibs
   #forceevelibs=$rootuevelibs
   ;;
win32gcc | win64gcc)
   # Windows (32 or 64) with cygwin gcc
   auxcflags="-std=gnu++14"
   auxlibs=
   forcelibs=$rootulibs
   forceglibs=$rootuglibs
   forceevelibs=$rootuevelibs
   ;;
*)
   echo "root-config: \"$arch\" invalid architecture"
   echo "Please report to rootdev@cern.ch"
   exit 1
   ;;
esac


### compiler dependent settings ###

case $arch in
freebsd* | openbsd* | linux*)
   auxcflags="-pthread $auxcflags"
   auxlibs="-pthread $auxlibs"

   for f in $features ; do
      if test "x$f" = "xrpath" ; then
         auxlibs="-Wl,-rpath,$libdir $auxlibs"
      fi
      if test "x$f" = "xlibcxx" ; then
         auxcflags="-stdlib=libc++ $auxcflags"
         auxlibs="-stdlib=libc++ $auxlibs"
      fi
   done
   ;;
macosx*)
   if [ \( $macosx_major -eq 10 -a $macosx_minor -ge 5 \) -o $macosx_major -gt 10  ]; then
      auxcflags="-pthread $auxcflags"
      auxlibs="-lpthread $auxlibs"
   else
      auxcflags="-D_REENTRANT $auxcflags"
      auxlibs="-lpthread $auxlibs"
   fi
   for f in $features ; do
      if test "x$f" = "xrpath" ; then
         if [ \( $macosx_major -eq 10 -a $macosx_minor -ge 5 \) -o $macosx_major -gt 10  ]; then
            auxlibs="-Wl,-rpath,$libdir $auxlibs"
         fi
      fi
      if test "x$f" = "xlibcxx" ; then
         auxcflags="-stdlib=libc++ $auxcflags"
         auxlibs="-stdlib=libc++ $auxlibs"
      fi
   done
   ;;
hpuxacc | hpuxia64acc)
   auxcflags="-mt $auxcflags"
   auxlibs="-mt $auxlibs"
   ;;
win32)
   ;;
*)
   for f in $features ; do
      auxcflags="-D_REENTRANT $auxcflags"
      auxlibs="-lpthread $auxlibs"
   done
   ;;
esac

# allocator must be last in auxlibs
for f in $features ; do
   if test "x$f" = "xalloc" ; then
      auxlibs="$auxlibs  "
   fi
done

auxcflags="$auxcflags "

### end of machine and compiler dependent settings ###

srcdir=/Users/sftnight/build/ws/BUILDTYPE/Release/LABEL/mac11arm/V/6-26/root
prefix=$ROOTSYS
if test "$platform" = "win32" && test "$prefix" != ""; then
   prefix=`cygpath -u $prefix`
fi
exec_prefix=${prefix}
exec_prefix_set=no
new_set=no
libsout=no
glibsout=no
noauxlibs=no
noauxcflags=no
noldflags=no

usage="\
Usage: root-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version]\
 [--cflags] [--auxcflags] [--ldflags] [--new] [--nonew] [--libs] [--glibs]\
 [--evelibs] [--bindir] [--libdir] [--incdir] [--etcdir] [--tutdir] [--srcdir]\
 [--noauxcflags] [--noauxlibs] [--noldflags] [--has-<feature>] [--arch]\
 [--platform] [--config] [--features] [--ncpu] [--git-revision]\
 [--python-version] [--python2-version] [--python3-version]\
 [--cc] [--cxx] [--f77] [--ld ] [--help]"

if test $# -eq 0; then
   echo "${usage}" 1>&2
   exit 1
fi

out=""

while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *)    optarg= ;;
  esac

  case $1 in
    --arch)
      ### Output the arcitecture (compiler/OS combination)
      out="$out $arch"
      ;;
    --platform)
      ### Output the platform (OS)
      out="$out $platform"
      ;;
    --has-*)
      ### Check for feature
      target=`echo $1 | sed 's/--has-//'`
      found=""
      for feature in $features ; do
         if test "$target" = "" ; then
            feature="<invalid>"
            errors="${errors}--has-: feature name is required!\n"
            break
         fi
         if test "$feature" = "$target" ; then
            out="$out yes"
            break
         fi
         feature=""
      done
      if test "$feature" = "" ; then
         for feature in $all_features ; do
            if test "$feature" = "$target" ; then
               found="$feature"
               break
            fi
         done
         if test "$found" = "" ; then
            errors="${errors}--has-$target: unknown feature!\n"
         else
            out="$out no"
         fi
      fi
      ;;
    --prefix=*)
      ### Set the prefix
      if test "$platform" = "win32"; then
         ### We need to expand the path to backslash seperated path
         optarg=`cygpath -u $optarg`
      fi
      prefix=$optarg
      bindir=${prefix}/bin
      libdir=${prefix}/lib
      incdir=${prefix}/include
      if test $exec_prefix_set = no ; then
         exec_prefix=$optarg
      fi
      ;;
    --prefix)
      ### Output the prefix
      out="$out $prefix"
      ;;
    --exec-prefix=*)
      ### Set the exec-prefix
      if test "$platform" = "win32"; then
      ### We need to expand the path to backslash seperated path
         optarg=`cygpath -u $optarg`
      fi
      exec_prefix=$optarg
      exec_prefix_set=yes
      bindir=${exec_prefix}/bin
      libdir=${exec_prefix}/lib
      ;;
    --exec-prefix)
      ### Output the exec-prefix
      out="$out $prefix"
      ;;
    --nonew)
      ### Don't use the libNew library
      new_set="no"
      ;;
    --new)
      ### Use the libNew library
      new_set="yes"
      ;;
    --noauxlibs)
      noauxlibs="yes"
      ;;
    --noauxcflags)
      noauxcflags="yes"
      ;;
    --noldflags)
      noldflags="yes"
      ;;
    --version)
      ### Output the version number.  If RVersion.h can not be found, give up.
      if test -r ${incdir}/RVersion.h; then
         out="$out `sed -n 's,.*ROOT_RELEASE *\"\(.*\)\".*,\1,p' < ${incdir}/RVersion.h`"
      else
         echo "cannot read ${incdir}/RVersion.h"
         exit 1
      fi
      ;;
    --git-revision)
      ### Output the git revision number.  If RGitCommit.h can not be found, give up.
      if test -r ${incdir}/RGitCommit.h; then
         out="$out `sed -n 's,.*ROOT_GIT_COMMIT *\"\(.*\)\".*,\1,p' < ${incdir}/RGitCommit.h`"
      else
         echo "cannot read ${incdir}/RGitCommit.h"
         exit 1
      fi
      ;;
    --python-version)
      out="$out 3.8.2"
      ;;
    --python2-version)
      out="$out 2.7.16"
      ;;
    --python3-version)
      out="$out 3.8.2"
      ;;
    --cflags)
      ### Output the compiler flags
      if test ${incdir} != /usr/include; then
         ### In case we're on a Win32 system, we need to expand the
         ### path to a backslash seperated path
         if test "$platform" = "win32"; then
            includes=-I\'`cygpath -w ${incdir}`\'
         else
            includes=-I${incdir}
         fi
      fi
      if test "x$noauxcflags" = "xyes" ; then
         out="$out $includes"
      else
         out="$out ${auxcflags} $includes"
      fi
      ;;
   --auxcflags)
      ### Output auxiliary compiler flags
      out="$out $auxcflags"
      ;;
    --ldflags)
      ### Output linker flags
      out="$out $auxldflags"
      ;;
    --libs)
      ### Output regular ROOT libraries.  If the user said --glibs --libs,
      ### we've already output the libraries, so we skip this section
      if test "x$libsout" = "xyes" ; then
         shift
         continue
      fi
      ### Set the flag
      libsout="yes"
      ### See if we need the new library
      if test "x$new_set" = "xyes"; then
         libs="${newlib} ${rootlibs}"
      else
         libs=${rootlibs}
      fi
      ### If we're on a win32 system, we need to change the -l prefix
      ### into a .lib suffix, and expand the paths to a backslash
      ### separated path.
      if test "$platform" = "win32"; then
         nlibs=`echo $libs | sed "s@-l\([a-zA-Z0-9]*\)@${libdir}/lib\1.lib@g"`
         libs=
         for i in $nlibs; do
            libs="$libs '`cygpath -w $i`'"
         done
      else
         if test "x$noldflags" = "xno" ; then
            out="$out -L${libdir}"
         fi
      fi
      if test "x$noauxlibs" = "xyes" ; then
         out="$out $forcelibs $libs"
      else
         out="$out $forcelibs $libs ${auxlibs}"
      fi
      ;;
    --glibs)
      ### Output graphics and normal libraries.
      ### If the user said --evelibs --glibs,
      ### we've already output the libraries, so we skip this section
      if test "x$glibsout" = "xyes" ; then
         shift
         continue
      fi
      ### Set the flag
      glibsout="yes"
      ### If the user said --libs --glibs, we don't need to add the
      ### regular ROOT libraries.
      glibsonly="no"
      if test "x$libsout" = "xno" ; then
         ### Set the flag
         libsout="yes"
         if test "x$new_set" = "xyes" ; then
            glibs="${newlib} ${rootglibs} ${rootlibs}"
         else
            glibs="${rootglibs} ${rootlibs}"
         fi
      else
         glibs="${rootglibs}"
         glibsonly="yes"
      fi
      ### If we're on a win32 system, we need to change the -l prefix
      ### into a .lib suffix, and expand the paths to a backslash
      ### separated path.
      if test "$platform" = "win32"; then
         nlibs=`echo $glibs | sed "s@-l\([a-zA-Z0-9]*\)@${libdir}/lib\1.lib@g"`
         glibs=
         for i in $nlibs; do
            glibs="$glibs '`cygpath -w $i`'"
         done
      else
        if test "x$noldflags" = "xno" ; then
           out="$out -L${libdir}"
        fi
      fi
      if test "x$glibsonly" = "xyes" ; then
         out="$out $forceglibs $glibs"
      else
         if test "x$noauxlibs" = "xyes" ; then
            out="$out $forcelibs $forceglibs $glibs"
         else
            out="$out $forcelibs $forceglibs $glibs ${auxlibs}"
         fi
      fi
      ;;
    --evelibs)
      ### Output eve, graphics and normal libraries.
      ### we've already output the libraries, so we skip this section
      if test "x$evelibsout" = "xyes" ; then
         shift
         continue
      fi
      ### Set the flag
      evelibsout="yes"
      ### If the user said --libs --glibs --evelibs, we don't need to add the
      ### regular and glib ROOT libraries.
      evelibsonly="no"
      eveandglibsonly="no"
      if test "x$libsout" = "xno" ; then
         ### Set the flag
         libsout="yes"
         if test "x$new_set" = "xyes" ; then
            evelibs="${newlib} ${rootevelibs} ${rootglibs} ${rootlibs}"
         else
            evelibs="${rootevelibs} ${rootglibs} ${rootlibs}"
         fi
      elif test "x$glibsout" = "xno" ; then
         ### Set the flag
         glibsout="yes"
         evelibs="${rootevelibs} ${rootglibs}"
         eveandglibsonly="yes"
      else
         evelibs="${rootevelibs}"
         evelibsonly="yes"
      fi
      ### If we're on a win32 system, we need to change the -l prefix
      ### into a .lib suffix, and expand the paths to a backslash
      ### separated path.
      if test "$platform" = "win32"; then
         nlibs=`echo $evelibs | sed "s@-l\([a-zA-Z0-9]*\)@${libdir}/lib\1.lib@g"`
         evelibs=
         for i in $nlibs; do
            evelibs="$evelibs '`cygpath -w $i`'"
         done
      else
        if test "x$noldflags" = "xno" ; then
           out="$out -L${libdir}"
        fi
      fi
      if test "x$evelibsonly" = "xyes" ; then
         out="$out $forceevelibs $evelibs"
      elif test "x$eveandglibsonly" = "xyes" ; then
         out="$out $forceglibs $forceevelibs $evelibs"
      else
         if test "x$noauxlibs" = "xyes" ; then
            out="$out $forcelibs $forceglibs $forceevelibs $evelibs"
         else
            out="$out $forcelibs $forceglibs $forceevelibs $evelibs ${auxlibs}"
         fi
      fi
      ;;
    --auxlibs)
      ### output the auxiliary libraries
      out="$out $auxlibs"
      ;;
    --bindir)
      ### output the executable directory
      out="$out $bindir"
      ;;
    --libdir)
      ### output the library directory
      out="$out $libdir"
      ;;
    --incdir)
      ### output the header directory
      out="$out $incdir"
      ;;
    --etcdir)
      ### output the etc directory
      out="$out $etcdir"
      ;;
    --tutdir)
      ### output the tutorials directory
      out="$out $tutdir"
      ;;
    --srcdir)
      ### output the src directory
      out="$out $srcdir"
      ;;
    --config)
      ### output the configure arguments
      out="$out $configargs"
      ;;
    --features)
      ### output all supported features
      out="$out$features"  # no space, features starts with space
      ;;
    --ncpu)
      ### number of available cores
      ncpu=1
      case $arch in
      freebsd* | openbsd* | linux*)
         ncpu=$(awk '/^processor/ {++n} END {print n}' /proc/cpuinfo)
         ;;
      macosx*)
         ncpu=$(sysctl -n hw.ncpu)
         ;;
      aix*)
         ncpu=$(prtconf | grep 'Number Of Processors' | awk '{ print $4 }')
         ;;
      solaris*)
         ncpu=$(kstat cpu_info | grep core_id | awk '{ print $2}' | uniq | wc -l)
         ;;
      win32)
         ;;
      *)
         ;;
      esac
      out="$out $ncpu"
      ;;
    --cc)
      ### output used C compiler
      out="$out $altcc"
      ;;
    --cxx)
      ### output used C++ compiler
      out="$out $altcxx"
      ;;
    --f77)
      ### output used Fortran compiler
      out="$out $altf77"
      ;;
    --ld)
      ### output used Linker
      out="$out $altld"
      ;;
    --help)
      ### Print a help message
      echo "Usage: `basename $0` [options]"
      echo ""
      echo "  --arch                Print the architecture (compiler/OS)"
      echo "  --platform            Print the platform (OS)"
      echo "  --prefix[=dir]        Print or set prefix"
      echo "  --exec-prefix[=dir]   Print or set execution prefix"
      echo "  --libs                Print regular ROOT libraries"
      echo "  --glibs               Print regular + GUI ROOT libraries"
      echo "  --evelibs             Print regular + GUI + Eve libraries"
      echo "  --cflags              Print compiler flags and header path"
      echo "  --ldflags             Print linker flags"
      echo "  --bindir              Print the executable directory"
      echo "  --libdir              Print the library directory"
      echo "  --incdir              Print the header directory"
      echo "  --etcdir              Print the configuration directory"
      echo "  --tutdir              Print the tutorials directory"
      echo "  --srcdir              Print the top of the original source directory"
      echo "  --auxlibs             Print auxiliary libraries"
      echo "  --auxcflags           Print auxiliary compiler flags"
      echo "  --[no]new             Turn on[off] use of libNew.so"
      echo "  --noauxlibs           Do not print auxiliary/system libraries"
      echo "  --noauxcflags         Do not print auxiliary compiler flags"
      echo "  --noldflags           Do not print linker flags"
      echo "  --config              Print arguments used for configuration with CMake"
      echo "  --features            Print list of all supported features"
      echo "  --has-<feature>       Test if <feature> is compiled in"
      echo "  --version             Print the ROOT version"
      echo "  --git-revision        Print the ROOT git revision number"
      echo "  --python-version      Print the Python version used by ROOT"
      echo "  --python2-version     Print the Python2 version used by PyROOT"
      echo "  --python3-version     Print the Python3 version used by PyROOT"
      echo "  --ncpu                Print number of available (hyperthreaded) cores"
      echo "  --cc                  Print alternative C compiler specified when ROOT was built"
      echo "  --cxx                 Print alternative C++ compiler specified when ROOT was built"
      echo "  --f77                 Print alternative Fortran compiler specified when ROOT was built"
      echo "  --ld                  Print alternative Linker specified when ROOT was built"
      echo "  --help                Print this message"
      exit 0
      ;;
    *)
      ### Give an error
      echo "Unknown argument \"$1\"!" 1>&2
      echo "${usage}" 1>&2
      exit 1
      ;;
  esac
  shift
done

### Output the stuff
echo $out
if test "$errors" != "" ; then
   echo -en "$errors"
   exit 1
fi
