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

HFILES = \
  flt.h

HOFILES = \
  flt.ho

OFILES = \
  flt.o \
  fltasm.o
  
LIBFILE = \
  libflt.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
  
%.o: %.s ;\
  gcc -c $(GCCFLAGS) $*.s
  
%.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:
  
flt.ho:: flt.h

# Dependencies of .c files:

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

fltasm.o:: fltasm.s flt.ho