#
# Makefile for "project/lib/src"
#
# Define the position of the top-level project directory.
#
PROJECT		= ../..
#
# Define the program to be made.
#
PROGRAM		= lib
#
# Defines for various useful project directories.  These
# shouldn't need changing.
#
BIN		= $(PROJECT)/bin
PROGBASE	= $(PROJECT)/$(PROGRAM)
SRC		= $(PROGBASE)/src
OBJ		= $(PROGBASE)/obj
LIB		= $(PROJECT)/lib
LIBSRC		= $(LIB)/src
QLIBRARY	= $(LIB)/obj/quamlib.a
#
# Defines for various processing flags.
#
CPP		= $(CC)
DEBUG		= #-DEBUG
INCSRCS		= -I- 
CPPFLAGS	= $(DEBUG) $(INCSRCS) -I$(LIBSRC)
CFLAGS		= -O -g #-ansi -pedantic
CLIBRARY	= -ll
LDFLAGS		=
LINTFLAGS	= -ahqz
SHELL		= /bin/sh

HEADERS = \
	$(SRC)/cells.h \
	$(SRC)/code_area.h \
	$(SRC)/defs.h \
	$(SRC)/errors.h \
	$(SRC)/executable.h \
	$(SRC)/index.h \
	$(SRC)/indexing.h \
	$(SRC)/instructions.h \
	$(SRC)/link.h \
	$(SRC)/load.h \
	$(SRC)/name_table.h \
	$(SRC)/opcodes.h \
	$(SRC)/options.h \
	$(SRC)/pc.h \
	$(SRC)/pred_table.h \
	$(SRC)/primitives.h \
	$(SRC)/query_code.h \
	$(SRC)/resolve_object.h \
	$(SRC)/string_map.h \
	$(SRC)/string_table.h
SOURCES = \
	$(SRC)/name_table.c \
	$(SRC)/link.c \
	$(SRC)/errors.c \
	$(SRC)/pred_table.c \
	$(SRC)/executable.c \
	$(SRC)/load.c \
	$(SRC)/resolve_object.c \
	$(SRC)/string_map.c \
	$(SRC)/query_code.c \
	$(SRC)/string_table.c \
	$(SRC)/code_area.c \
	$(SRC)/indexing.c
OBJECTS = \
	$(OBJ)/name_table.o \
	$(OBJ)/link.o \
	$(OBJ)/errors.o \
	$(OBJ)/pred_table.o \
	$(OBJ)/executable.o \
	$(OBJ)/load.o \
	$(OBJ)/resolve_object.o \
	$(OBJ)/string_map.o \
	$(OBJ)/query_code.o \
	$(OBJ)/string_table.o \
	$(OBJ)/code_area.o \
	$(OBJ)/indexing.o

#
# Compile src/file.c to obj/file.o
#
$$(OBJ)/%.o:: $(SRC)/%.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<

$(QLIBRARY): $(OBJECTS)
	$(AR) cr $(QLIBRARY) $(OBJECTS)
	ranlib $(QLIBRARY)

lint:
	$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(SOURCES) $(HEADERS) >lint

clean:
	$(RM) $(OBJECTS) lint

clobber: clean
	$(RM) $(QLIBRARY)

depend:
	(echo '/^#.* PUT NO STUFF BELOW/,$$d'; echo w; echo q) | ed - Makefile
	echo '# Dependencies generated by make depend: PUT NO STUFF BELOW' >>Makefile
	for file in $(SOURCES);\
	do	gcc $(CPPFLAGS) -MM $$file |\
		sed 's| /.*\.c | |' |\
		sed 's=^\(.*:\)=$(OBJ)/\1=';\
	done >>Makefile

# Dependencies generated by make depend: PUT NO STUFF BELOW
../../lib/obj/name_table.o : ../../lib/src/name_table.c ../../lib/src/cells.h ../../lib/src/name_table.h \
  ../../lib/src/defs.h ../../lib/src/primitives.h ../../lib/src/string_table.h \
  ../../lib/src/errors.h 
../../lib/obj/link.o : ../../lib/src/link.c ../../lib/src/name_table.h ../../lib/src/defs.h \
  ../../lib/src/primitives.h ../../lib/src/cells.h ../../lib/src/string_table.h \
  ../../lib/src/errors.h ../../lib/src/code_area.h ../../lib/src/index.h ../../lib/src/string_map.h \
  ../../lib/src/instructions.h ../../lib/src/link.h ../../lib/src/opcodes.h ../../lib/src/pc.h \
  ../../lib/src/query_code.h ../../lib/src/resolve_object.h 
../../lib/obj/errors.o : ../../lib/src/errors.c ../../lib/src/defs.h ../../lib/src/errors.h \
  ../../lib/src/string_table.h ../../lib/src/primitives.h 
../../lib/obj/pred_table.o : ../../lib/src/pred_table.c ../../lib/src/code_area.h ../../lib/src/defs.h \
  ../../lib/src/index.h ../../lib/src/string_map.h ../../lib/src/primitives.h \
  ../../lib/src/errors.h ../../lib/src/instructions.h ../../lib/src/pc.h ../../lib/src/pred_table.h \
  ../../lib/src/string_table.h ../../lib/src/cells.h ../../lib/src/name_table.h 
../../lib/obj/executable.o : ../../lib/src/executable.c ../../lib/src/code_area.h ../../lib/src/defs.h \
  ../../lib/src/index.h ../../lib/src/string_map.h ../../lib/src/primitives.h \
  ../../lib/src/errors.h ../../lib/src/executable.h ../../lib/src/instructions.h \
  ../../lib/src/name_table.h ../../lib/src/cells.h ../../lib/src/string_table.h \
  ../../lib/src/pred_table.h ../../lib/src/query_code.h 
../../lib/obj/load.o : ../../lib/src/load.c ../../lib/src/code_area.h ../../lib/src/defs.h \
  ../../lib/src/index.h ../../lib/src/string_map.h ../../lib/src/primitives.h \
  ../../lib/src/errors.h ../../lib/src/instructions.h ../../lib/src/load.h ../../lib/src/pc.h \
  ../../lib/src/query_code.h ../../lib/src/string_table.h 
../../lib/obj/resolve_object.o : ../../lib/src/resolve_object.c ../../lib/src/cells.h ../../lib/src/name_table.h \
  ../../lib/src/defs.h ../../lib/src/primitives.h ../../lib/src/string_table.h \
  ../../lib/src/errors.h ../../lib/src/index.h ../../lib/src/string_map.h ../../lib/src/indexing.h \
  ../../lib/src/instructions.h ../../lib/src/opcodes.h ../../lib/src/pc.h ../../lib/src/pred_table.h \
  ../../lib/src/resolve_object.h 
../../lib/obj/string_map.o : ../../lib/src/string_map.c ../../lib/src/defs.h ../../lib/src/errors.h \
  ../../lib/src/string_map.h ../../lib/src/primitives.h 
../../lib/obj/query_code.o : ../../lib/src/query_code.c ../../lib/src/errors.h ../../lib/src/instructions.h \
  ../../lib/src/opcodes.h ../../lib/src/pc.h ../../lib/src/primitives.h ../../lib/src/query_code.h \
  ../../lib/src/defs.h 
../../lib/obj/string_table.o : ../../lib/src/string_table.c ../../lib/src/errors.h ../../lib/src/instructions.h \
  ../../lib/src/name_table.h ../../lib/src/defs.h ../../lib/src/primitives.h ../../lib/src/cells.h \
  ../../lib/src/string_table.h 
../../lib/obj/code_area.o : ../../lib/src/code_area.c ../../lib/src/string_table.h ../../lib/src/defs.h \
  ../../lib/src/primitives.h ../../lib/src/code_area.h ../../lib/src/index.h ../../lib/src/string_map.h \
  ../../lib/src/errors.h ../../lib/src/instructions.h ../../lib/src/pc.h ../../lib/src/query_code.h 
../../lib/obj/indexing.o : ../../lib/src/indexing.c ../../lib/src/name_table.h ../../lib/src/defs.h \
  ../../lib/src/primitives.h ../../lib/src/cells.h ../../lib/src/string_table.h \
  ../../lib/src/errors.h ../../lib/src/indexing.h ../../lib/src/instructions.h 
