#====================================================================
#  NeXus - Neutron & X-ray Common Data Format
#  
#  Makefile for building Fortran 90 version of NeXus libraries
#  
#  Copyright (C) 2002 Mark Koennecke
#  
#  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>
#
# $Id$
#
#====================================================================

#Edit "makefile_options" to set compiler flags
include makefile_options

ifdef H4ROOT
	H4LIBS=-L$(H4ROOT)/lib -lmfhdf -ldf -ljpeg
else
	H4LIBS=
endif
ifdef H5ROOT
	H5LIBS=-L$(H5ROOT)/lib -lhdf5
else
	H5LIBS=
endif

LIBNEXUS90_OBJ=NXUmodule.o NXmodule.o
NXTEST_OBJ=NXtest.o
NXDUMP_OBJ=NXdump.o

all: libNeXus90.a NXtest NXdump

NXmodule.o: NXmodule.f90
	$(F90) $(F90FLAGS) -c $(FROOT)/NXmodule.f90

NXUmodule.o: NXUmodule.f90 NXmodule.o
	$(F90) $(F90FLAGS) -c $(FROOT)/NXUmodule.f90

NXtest.o: NXtest.f90
	$(F90) $(F90FLAGS) -c $(FROOT)/NXtest.f90

NXdump.o: NXdump.f90
	$(F90) $(F90FLAGS) -c $(FROOT)/NXdump.f90

libNeXus90.a : $(LIBNEXUS90_OBJ)
	@echo "*** Creating Fortran 90 NeXus interface  ***"
	cp libNeXus.a $@
	ar -r $@ $(LIBNEXUS90_OBJ)
	ranlib $@

NXtest: libNeXus90.a $(NXTEST_OBJ)
	$(F90) $(F90FLAGS) $(LDFLAGS) -o NXtest $(NXTEST_OBJ) $(FROOT)/libNeXus90.a \
	$(H4LIBS) $(H5LIBS) -lz 

NXdump: libNeXus90.a $(NXDUMP_OBJ)
	$(F90) $(F90FLAGS) $(LDFLAGS) -o NXdump $(NXDUMP_OBJ) $(FROOT)/libNeXus90.a \
	$(H4LIBS) $(H5LIBS) -lz 
