# Installation directories:
INSTALLDIR = INSTALLDIR_IS_UNDEFINED
INC = $(INSTALLDIR)/gcc/include
LIB = $(INSTALLDIR)/lib

HFILES = \
  ia.h \
  zerofind.h

HOFILES = \
  ia.ho \
  zerofind.ho

OFILES = \
  ia.o \
  zerofind.o
  
LIBFILE = \
  libia.a
  
OPTFLAGS = -g
  
GCCFLAGS = \
  -I. -I$(INC) \
  $(OPTFLAGS) \
  -ansi \
  -Wall -Wtraditional -Wpointer-arith -Wmissing-prototypes \
  -mfpu

.PHONY: all cleanup uninstall install

all:   uninstall $(HOFILES) $(LIBFILE) install

cleanup: ;\
  /bin/rm -f *~ *.ho *.o *.a

uninstall: ;\
  ( cd $(INC) && rm -f $(HFILES) $(HOFILES) ) ;\
  ( cd $(LIB) && rm -f $(LIBFILE) )

install: ;\
  cp -p $(HFILES) $(HOFILES) $(INC) ;\
  cp -p $(LIBFILE) $(LIB)
  
%.o: %.c ;\
  gcc -c $(GCCFLAGS) $*.c
  
%.ho: %.h ;\
  gcc -o $*.ho -c $(GCCFLAGS) -x c $*.h \
  || /bin/rm -f $*.ho
  
$(LIBFILE): $(OFILES) ;\
  rm -f $*.a && ar crv $*.a $(OFILES) && ranlib $*.a

# Dependencies of .h files: 
  
ia.ho:: ia.h $(INC)/flt.ho

zerofind.ho:: zerofind.h ia.ho $(INC)/flt.ho 

# Dependencies for .c files:

ia.o:: ia.c ia.ho $(INC)/flt.ho $(INC)/js.ho $(INC)/ioprotos.ho

zerofind.o:: zerofind.c zerofind.ho ia.ho $(INC)/js.ho $(INC)/ioprotos.ho \
             $(INC)/flt.ho