#!/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         = "g++"
set cc_opts       = "-g -O2 -ffile-prefix-map=/build/ncl-WMPwNG/ncl-6.6.2.dfsg.1=. -fstack-protector-strong -Wformat -Werror=format-security  -I/usr/include/hdf5/serial -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
set ld_libs       = "-L/build/ncl-WMPwNG/ncl-6.6.2.dfsg.1/debian/tmp//lib -L/usr/lib/mips64el-linux-gnuabi64/hdf5/serial/lib -lnetcdf -lcurl -lhe5_hdfeos -lgctp -Wl,-L/usr/lib/mips64el-linux-gnuabi64/hdf5/serial  -lhdf5_hl -lhdf5 -lsz -lhdfeos -lgctp -lmfhdfalt -ldfalt -ljpeg -lz -Wl,-L/usr/lib/mips64el-linux-gnuabi64/hdf5/serial -lhdf5_hl -lhdf5 -lz -lsz -lgdal   -ludunits2 -lexpat  -lgrib2c  -lpng -lz -ljpeg -lpng -lz -lcairo -lXrender -lfontconfig -lpixman-1 -lfreetype -lexpat -lpng -lz -lbz2 -lgsl -lgslcblas -lsphere-gfortran -lfftpack5_dp -llapack -lblas"
set extra_ld_libs = "-lX11 -lXext -lgfortran -lm -lm  -lproj -lgomp -ldl -lgfortran -lpng"
set libpath       = "/build/ncl-WMPwNG/ncl-6.6.2.dfsg.1/debian/tmp//lib"
set incpath       = "/build/ncl-WMPwNG/ncl-6.6.2.dfsg.1/debian/tmp//usr/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"

if (! -d "$libpath") then
  echo "Library directory <$libpath> does not exist."
  exit 1
endif

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
