#!/bin/csh -f
#
#   $Id: MakeNcl.csh,v 1.5 2008-07-27 04:12:48 haley Exp $
#                                                                      
#                Copyright (C)  2004
#        University Corporation for Atmospheric Research
#                All Rights Reserved
#
# The use of this Software is governed by a License Agreement.
#
# Use this script to make an ncl executable from installed libraries.
#

set cc_ld         = "/usr/bin/clang++"
set cc_opts       = "-fPIC -D_DARWIN_C_SOURCE -Os -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -DH5_USE_110_API -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -std=c99"
set ld_libs       = "-L/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_ncarg/ncarg/work/destroot/opt/local/lib -L/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_ncarg/ncarg/work/ncl-6.6.2 -L/opt/local/lib/hdfeos5/lib -L/opt/local/lib/proj5/lib -L/opt/local/lib -lnetcdf -lhe5_hdfeos -lGctp -lhdf5_hl -lhdf5 -lhdfeos -lGctp -lmfhdf -ldf -lhdf5_hl -lhdf5 -lgdal -lproj -ljpeg   -ludunits2 -lexpat -lv5d -lgrib2c -ljasper -lpng -lz -ljpeg -lpng -lz -lcairo -lXrender -lfontconfig -lpixman-1 -lfreetype -lexpat -lpng -lz -lbz2 -lgsl -lgslcblas ../../.././external/sphere3.1_dp/libsphere3.1_dp.a ../../.././external/fftpack5_dp/libfftpack5_dp.a ../../.././external/lapack/liblapack_ncl.a ../../.././external/blas/libblas_ncl.a"
set extra_ld_libs = "-lXpm -lX11 -lXext -L /opt/local/lib/libgcc -lgfortran -lgomp -lm  -ldl  "
set libpath       = "/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_ncarg/ncarg/work/destroot/opt/local/lib"
set incpath       = "/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_ncarg/ncarg/work/destroot/opt/local/include"
set libdir        = "-L$libpath"
set incdir        = "-I$incpath"
set libncl        = "-lncl"
set libnfp        = "-lnfp -lnfpfort"
set libhlu        = "-lhlu"
set libncarg      = "-lncarg"
set libgks        = "-lncarg_gks"
set libncarg_c    = "-lncarg_c"
set libmath       = "-lngmath"
set ncarg_libs    = "$libncl $libnfp $libhlu $libncarg $libgks $libncarg_c $libmath"

set files      = ""
set extra_opts = ""

foreach arg ($argv)

    switch ($arg)

    case "-*":
        set extra_opts = "$extra_opts $arg"
        breaksw

    default:
        set files = "$files $arg"
        breaksw
    endsw
end

if ("$files" == "") then
  echo "MakeNcl error: You must input one or more *.o files"
  exit 1
endif

set newargv = "$cc_ld $cc_opts $extra_opts -o ncl $files $incdir $libdir $ncarg_libs $ld_libs $extra_ld_libs"

echo $newargv
eval $newargv
