# building hdf5 utilities
# version - linux-32 static ubuntu-8 gcc-4.2
# Ron Ghosh, November 2014
LROOT = ../lb32/
SRC = ../utisrc/
LIBP = $(LROOT)libpgplot.a 
LIBH = $(LROOT)libhdf5_fortran.a $(LROOT)libhdf5.a $(LROOT)libz.a
COML = gfortran -c 
LINK = gfortran 
# static link for non-X11
LINKS = gfortran -static


all: h5pp h5nopp scannxs nxs2as runnex metnxs nx_names
h5pp: h5bits.o $(SRC)h5pp.f h5visc.o
	$(LINK) -o h5pp $(SRC)h5pp.f h5visc.o h5bits.o $(LIBP) $(LIBH) -lX11 
h5nopp: $(SRC)h5nopp.f h5visc.o h5bits.o $(LIBH)
	$(LINKS) -o h5nopp $(SRC)h5nopp.f h5visc.o h5bits.o  $(LIBH)  
metnxs: $(SRC)metnxs.f  h5bits.o $(LIBH)
	$(LINKS) -o metnxs $(SRC)metnxs.f  h5bits.o  $(LIBH)  
runnex: $(SRC)runnex.f  h5bits.o $(LIBH)
	$(LINKS) -o runnex $(SRC)runnex.f  h5bits.o  $(LIBH)  
scannxs: $(SRC)scannxs.f h5bits.o
	$(LINKS) -o scannxs $(SRC)scannxs.f h5bits.o $(LIBH) 
nxs2as: $(SRC)nxs2as.f h5bits.o sasanx.o
	$(LINKS) -o nxs2as $(SRC)nxs2as.f sasanx.o h5bits.o $(LIBH) 
nx_names: $(SRC)nx_names.f h5bits.o 
	$(LINKS) -o nx_names $(SRC)nx_names.f h5bits.o $(LIBH) 

h5bits.o: $(SRC)h5bits.f90 hdf5.mod
	$(COML) $(SRC)h5bits.f90
sasanx.o: $(SRC)sasanx.f
	$(COML) $(SRC)sasanx.f
h5visc.o: $(SRC)h5visc.c
	/usr/local/hdf5/bin/h5cc -c $(SRC)h5visc.c
clean:
	rm h5pp h5nopp scannxs nxs2as runnex metnxs \
	nx_names
	
		
