# Copyright (C) 1996 Hughes and Applied Research Corporation
#
# Permission to use, modify, and distribute this software and its
# documentation for any purpose without fee is hereby granted, provided that
# the above copyright notice appear in all copies and that both that copyright
# notice and this permission notice appear in supporting documentation.
#
# Makefile
# 
# Makefile for field build of HDFEOS
#
# The following environment variables must be defined:
#
#   Flags:
#     AR           library archiving program and flags (e.g.: ar -r)
#     CC           C language compiler (e.g.: cc)
#     CFHFLAGS     C compiler flags and cfortran.h switches
#                  (e.g.: -Xa -O -DsunFortan)
#     RANLIB       ranlib program (e.g. ranlib)
#
#   Directories:
#     HDFEOS5_INC   HDF-EOS include directory ($HDFEOS5_HOME/include)
#     HDFEOS5_LIB   HDF-EOS library directory ($HDFEOS5_HOME/lib/$BRAND)
#     HDFEOS5_OBJ   HDF-EOS object directory ($HDFEOS5_HOME/obj/$BRAND)

# force make program to use bourne shell
SHELL=/bin/sh

# define remove utility
RM = rm -f 

AR = ar -r

# define C preprocessor symbols 
DFLAGS = -D$(HDFSYS)

# location of include files need to compile source code
IFLAGS = -I. -I$(HDFEOS5_INC) -I$(HDF5INC)

# object files needed to build library
LIBOFILES = \
	$(HDFEOS5_OBJ)/EHapi.o \
	$(HDFEOS5_OBJ)/TSapi.o \
	$(HDFEOS5_OBJ)/PTapi.o \
	$(HDFEOS5_OBJ)/GDapi.o \
	$(HDFEOS5_OBJ)/SWapi.o \
	$(HDFEOS5_OBJ)/ZAapi.o

# default target, this just builds the hdfeos5 library
all:
	@if [ "$(BRAND)" = "sun4" ] ; then				\
		$(MAKE) $(MFLAGS) $(HDFEOS5_LIB)/libhe5_hdfeos.a ranlib;	\
	else								\
		$(MAKE) $(MFLAGS) $(HDFEOS5_LIB)/libhe5_hdfeos.a;		\
	fi

$(HDFEOS5_LIB)/libhe5_hdfeos.a: $(LIBOFILES)
	$(AR) $@ $?

ranlib:
	$(RANLIB) $(HDFEOS5_LIB)/libhe5_hdfeos.a

install: 
	@echo "no binaries to move"
	@echo "don't worry"

clean:
	$(RM) *.o $(HDFEOS5_OBJ)/*.o


$(HDFEOS5_OBJ)/EHapi.o : EHapi.c 
	$(CC) $(CFHFLAGS) $(DFLAGS) $(IFLAGS) -c $? -o $@

$(HDFEOS5_OBJ)/TSapi.o : TSapi.c
	$(CC) $(CFHFLAGS) $(DFLAGS) $(IFLAGS) -c $? -o $@

$(HDFEOS5_OBJ)/PTapi.o : PTapi.c
	$(CC) $(CFHFLAGS) $(DFLAGS) $(IFLAGS) -c $? -o $@

$(HDFEOS5_OBJ)/SWapi.o : SWapi.c
	$(CC) $(CFHFLAGS) $(DFLAGS) $(IFLAGS) -c $? -o $@

$(HDFEOS5_OBJ)/GDapi.o : GDapi.c
	$(CC) $(CFHFLAGS) $(DFLAGS) $(IFLAGS) -c $? -o $@

$(HDFEOS5_OBJ)/ZAapi.o : ZAapi.c
	$(CC) $(CFHFLAGS) $(DFLAGS) $(IFLAGS) -c $? -o $@

.c.o:
	$(MAKE) $(MFLAGS) $(HDFEOS5_OBJ)/$@


