#!/bin/sh
#====================================================================
#  NeXus - Neutron & X-ray Common Data Format
#  
#  $Id: nxbuild.in 1636 2011-10-13 21:09:07Z Pete Jemian $
#
#  scripts/nxbuild.  Generated from nxbuild.in by configure.
#  
#  Script for building NeXus applications
#
#  Copyright (C) 2004 Freddie Akeroyd
#  
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
# 
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
# 
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free 
#  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
#  MA  02111-1307  USA
#             
#  For further information, see <http://www.nexusformat.org>
#
#====================================================================
SHELL="/bin/sh"
srcdir="."
top_srcdir=".."
VPATH="."
prefix="/usr"
exec_prefix="${prefix}"
bindir="${exec_prefix}/bin"
sbindir="${exec_prefix}/sbin"
libexecdir="${exec_prefix}/libexec"
datadir="${datarootdir}"
datarootdir="${prefix}/share"
libdir="/usr/lib64"
infodir="${datarootdir}/info"
mandir="${datarootdir}/man"
includedir="${prefix}/include"
#pkgdatadir=$(datadir)/nexus
#pkglibdir=$(libdir)/nexus
#pkgincludedir=$(includedir)/nexus
#top_builddir=..
host_alias=""
host_triplet="x86_64-unknown-linux-gnu"
CC="gcc"
CFLAGS="-I${includedir} -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fno-strict-aliasing -Wall"
F77="gfortran"
F77FLAGS="-I${includedir} -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables"
F90="gfortran"
F90FLAGS="-I${includedir}  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables"
H4ROOT=""
H5ROOT="/usr"
PACKAGE="nexus"
RANLIB="ranlib"
STRIP="strip"
VERSION="4.3.1"
LIBNEXUS="-lNeXus"
LIBNEXUS77="-lNeXus77 -lNeXus"
LIBNEXUS90="-lNeXus90 -lNeXus"
DEFS="-DHAVE_CONFIG_H"
CPPFLAGS=" -fno-common -I${includedir}"
LDFLAGS="-L${libdir}   -L/usr/lib64 -L/usr/lib  -L/usr/local/lib"
LIBS="-lhdf5 -lmfhdf -ldf -ljpeg -lz -lpthread -ldl -lm "

OBJS=""
TARGET="a.out"
LD=$CC
while [ $# -ne 0 ]; do
    case $1 in
	-o)
	    shift
	    TARGET=$1
	    ;;
	*.f90)
	    echo $F90 $F90FLAGS -c $1
	    $F90 $F90FLAGS -c $1
	    OBJS="$OBJS `basename $1 .f90`.o"
	    LIBNEXUS=$LIBNEXUS90
	    LD=$F90
            ;;
	*.c)
	    echo $CC $CPPFLAGS $DEFS $CFLAGS -c $1
	    $CC $CPPFLAGS $DEFS $CFLAGS -c $1
	    OBJS="$OBJS `basename $1 .c`.o"
            ;;
	*.f)
	    echo $F77 $F77FLAGS -c $1
	    $F77 $F77FLAGS -c $1
	    OBJS="$OBJS `basename $1 .f`.o"
	    LIBNEXUS=$LIBNEXUS77
	    LD=$F77
            ;;
	--help|-h)
	    echo "usage: nxbuild [-o target] file [file...]"
	    echo "usage: nxbuild --help"
	    echo "usage: nxbuild --version"
	    exit
	    ;;
	--version|-V)
	    echo 'nxbuild $Revision: 1636 $ for NeXus release' $VERSION
	    echo "Type   nxbuild --help   for usage"
	    exit
	    ;;
	*)		# *.o, *.a etc
	    OBJS="$OBJS $1"
	    ;;
    esac
    shift
done
echo $LD -o $TARGET $LDFLAGS $OBJS $LIBNEXUS $LIBS
$LD -o $TARGET $LDFLAGS $OBJS $LIBNEXUS $LIBS
