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

HFILES = \
  aa.h

HOFILES = \
  aa.ho

OFILES = \
  aa.o
  
LIBFILE = \
  libaa.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: ;\
  rm -f $(OFILES) $(HOFILES) $(LIBFILE)

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: 
  
aa.ho:: aa.h $(INC)/js.ho $(INC)/flt.ho $(INC)/ia.ho

# Dependencies for .c files:

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