#====================================================================
#  NeXus - Neutron & X-ray Common Data Format
#  
#  Makefile for building the NeXus library with the HDF4 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

LIBNEXUS_OBJ=napi.o napif.o
TEST4_OBJ=napi4_test.o
NXBROWSE_OBJ=NXbrowse.o
NXTOXML_OBJ=NXtoXML.o
NXTODTD_OBJ=NXtoDTD.o
NOPT=-DHDF4

all: libNeXus.a napi4_test napif_test NXbrowse NXtoXML NXtoDTD

.c.o :
	$(CC) $(CFLAGS) $(NOPT) -I$(H4ROOT)/include -c $(FROOT)/$*.c
.f.o:
	$(FC) $(FFLAGS) -c $(FROOT)/$*.f

libNeXus.a : $(LIBNEXUS_OBJ)
	@echo "*** Creating NeXus interface based on HDF4 library (libNeXus.a) ***"
	- rm $@
	ar -cr $@ $(LIBNEXUS_OBJ)
	ranlib $@
	
napi4_test: libNeXus.a $(TEST4_OBJ)
	$(CC) $(CFLAGS) -o napi4_test $(TEST4_OBJ) $(FROOT)/libNeXus.a \
	-L$(H4ROOT)/lib -lmfhdf -ldf -ljpeg -lz 

napif_test: libNeXus.a napif_test.o
	$(FC) $(FFLAGS) -o napif_test napif_test.o $(FROOT)/libNeXus.a \
	-L$(H4ROOT)/lib -lmfhdf -ldf -ljpeg -lz
	
NXbrowse: libNeXus.a $(NXBROWSE_OBJ) 
	$(CC) $(CFLAGS) -o NXbrowse $(NXBROWSE_OBJ) $(FROOT)/libNeXus.a \
	-L$(H4ROOT)/lib -lmfhdf -ldf -ljpeg -lz 

NXtoXML: libNeXus.a $(NXTOXML_OBJ) 
	$(CC) $(CFLAGS) -o NXtoXML $(NXTOXML_OBJ) $(FROOT)/libNeXus.a \
	-L$(H4ROOT)/lib -lmfhdf -ldf -ljpeg -lz 

NXtoDTD: libNeXus.a $(NXTODTD_OBJ) 
	$(CC) $(CFLAGS) -o NXtoDTD $(NXTODTD_OBJ) $(FROOT)/libNeXus.a \
	-L$(H4ROOT)/lib -lmfhdf -ldf -ljpeg -lz 

