OBJ = main.o       phase1.o    phase2.o       phase3.o \
      list.o       util.o      exp.o          pseudo.o \
      inst.o       glob.o

SRC1 = main.c       phase1.c    phase2.c       phase3.c \
       list.c       util.c

SRC2 = exp.c        pseudo.c    inst.c       glob.c

SRC = $(SRC1) $(SRC2)

INC = glob.h

INCDIR = ../include
# define BIG_ENDIAN if assembler is hosted on big-endian machine (msb first)
CFLAGS = -I$(INCDIR) -DBIG_ENDIAN

as: $(OBJ)
# make sure we have today's date in the version field
	sed -e "s/XXX/`date`/" version > version.c
	cc -c version.c
	rm version.c
# then do the link	
	cc -o as $(OBJ) version.o -lBSD
	rm version.o

as_shar1: $(SRC1)
	shar -b -C $(SRC1) > as_shar1

as_shar2: $(SRC2) $(INC) init_in mk_init.c version Makefile
	shar -b -C $(SRC2) $(INC) init_in mk_init.c version Makefile > as_shar2

main.o: glob.h $(INCDIR)/a.out.h

phase1.o: glob.h $(INCDIR)/a.out.h

phase3.o: glob.h $(INCDIR)/a.out.h $(INCDIR)/conv.h

util.o: glob.h $(INCDIR)/a.out.h

glob.o: glob.h hashinit.h $(INCDIR)/a.out.h $(INCDIR)/magic.h

list.o: glob.h $(INCDIR)/a.out.h

phase2.o: glob.h $(INCDIR)/a.out.h

pseudo.o: glob.h $(INCDIR)/a.out.h

inst.o: glob.h $(INCDIR)/a.out.h

exp.o: glob.h $(INCDIR)/a.out.h

hashinit.h: init_in mk_init
	mk_init < init_in > hashinit.h

mk_init: mk_init.c
	cc -o mk_init mk_init.c

as.lst: $(SRC) $(INC)
	pr -l60 $(SRC) $(INC) > as.lst

lint.out: $(SRC) $(INC)
	lint -I$(INCDIR) $(SRC) > lint.out

clean:
	rm -f *.o as hashinit.h mk_init as.lst core *~

glob.h:	hashinit.h

