# $Id: Makefile,v 1.11 1996/06/18 06:50:15 dhb Exp $ #
# $Log: Makefile,v $
# Revision 1.11  1996/06/18 06:50:15  dhb
# Removed redundant CC and CPP defined which caused recursive
# macro definition errors on some systems.
#
# Revision 1.10  1996/05/23  23:06:23  dhb
# t3d/e port
#
# Revision 1.9  1996/05/17  19:44:09  venkat
# Removed the includes from the installation directory for the INCLUDE macro.
#
# Revision 1.8  1995/11/02  01:43:06  venkat
# Replaced-/tmp-with-TMPDIR-macro
#
# Revision 1.7  1995/02/13  21:13:21  dhb
# Removed checkout of RCSRELEASE versions.
#
# Revision 1.6  1995/02/13  21:01:23  dhb
# Removed dependencies on sys/code_... programs.
#
# Added @.h files to clean target.
#
# Revision 1.5  1994/12/19  22:25:43  dhb
# Added rules for RCS subdirectoy.
#
# Revision 1.4  1994/12/06  02:09:49  dhb
# Added install target.
#
# Revision 1.3  1994/12/06  00:37:16  dhb
# Nov 8 1994 changes from Upi Bhalla
#
# Revision 1.2.1.4  1994/04/11  21:42:10  dhb
# Proper include directories not present in RCS checkout actions
#
# Revision 1.2.1.3  1994/04/11  21:17:00  dhb
# Needed tabs on RCS checkout actions
#
# Revision 1.2.1.2  1994/04/11  21:11:38  dhb
# Added RCS checkout rules
#
# Revision 1.2.1.1  1994/04/11  17:49:03  dhb
# Update by Dave Bilitch
# 	code_g related changes
# #
# ============================================
#
# Makefile for creating a new user library
#
# It is recommended that each library have its own makefile and
# its own subdirectory for clarity of organization.
# This subdirectory should contain all of the object files
# needed to compile the library as well as all header files,
# support files, and the script file for loading the library (e.g. userlib.g).
#
# The user should specify the values of the following makefile variables :
#
# GENESIS 
#	set this to the directory in which the simulator was installed
# LIBRARY_NAME
#	set this to the desired name of the library 
# FUNCTIONS
#	set this to the name of the file containing the list of
#	public function names in the library
# STARTUP
#	set this to the name of the startup script which defines the
#	commands and objects for this library
# STRUCTURES
#	set this to the name of the file containing the structure definitions
#	for objects in the library
# EXT_HEADER
#	set this to the name of the header file containing the appropriate
#	include references needed to compile the library files
# TARGET_OBJ
#	set this to the name of the library object which will be compiled
#	This is normally just the LIBRARY_NAME with 'lib.o' appended to it
# OBJECTS
#	list the user object files (with the .o extension) which will be 
#	a part of the library
#
# ============================================

LIBRARY_NAME 	= 	xo
FUNCTIONS 	= 	xofuncs
STARTUP		=	xolib.g
STRUCTURES 	=	xo_struct.h
EXT_HEADER	= 	xo_ext.h
LIBBUILD	=	$(LD)
LIBBUILDFLAGS	=	-r -o
LIBORDER	=	echo no need to reorder
LIBEXT		=	o
TARGET_OBJ	=	xolib.$(LIBEXT)

OBJECTS = \
	xo_cmds.o \
	xo_cvt.o \
	xo_callb.o \
	xo_hash.o

# ============================================
# everything below here should maintain itself
# ============================================

# If you want to use the debug option (which will cost you in both
# speed and memory), use the alternate CFLAGS = -g.
# Otherwise use "-O" to optimize.

CFLAGS      =   $(TOPFLAGS) -D$(MACHINE)
LIBS 		=  	-lm
SYS			=	$(INSTALL)/src/sys
INCLUDE		= 	-I. -I.. -I../../sim -I../../shell -I../../sys
HEADERS 	=  	$(STRUCTURES)

default : $(TARGET_OBJ)

$(OBJECTS) : $(HEADERS) 


.c.o:
	$(CC) $(CFLAGS) $(INCLUDE) $< -c 

$(LIBRARY_NAME)_g@.c $(LIBRARY_NAME)_g@.h: $(STARTUP)
	$(SYS)/code_g $(STARTUP) $(EXT_HEADER) $(LIBRARY_NAME) -noobjects -cstartup xinit

# make the data structure section of the symbol table

$(LIBRARY_NAME)_d@.c : $(STRUCTURES)
	- $(CPP) $(INCLUDE) $(STRUCTURES) $(TMPDIR)/$(STRUCTURES)
	- $(SYS)/code_sym $(TMPDIR)/$(STRUCTURES) $(LIBRARY_NAME) \
	  -I $(EXT_HEADER) -NI -o $(LIBRARY_NAME)_d@.c
	- rm $(TMPDIR)/$(STRUCTURES)

# make the function list section of the symbol table

$(LIBRARY_NAME)_f@.c : $(FUNCTIONS)
	- $(SYS)/code_func $(FUNCTIONS) $(LIBRARY_NAME) \
	  > $(LIBRARY_NAME)_f@.c

# make the library header function

$(LIBRARY_NAME)_l@.c: $(LIBRARY_NAME)_g@.c $(LIBRARY_NAME)_d@.c $(OBJECTS)
	- $(SYS)/code_lib $(LIBRARY_NAME) -o $(LIBRARY_NAME)_l@.c

SYMBOLTAB = $(LIBRARY_NAME)_d@.o $(LIBRARY_NAME)_g@.o $(LIBRARY_NAME)_l@.o

$(TARGET_OBJ): $(SYMBOLTAB) $(OBJECTS)
	$(LIBBUILD) $(LIBBUILDFLAGS) $(TARGET_OBJ) $(OBJECTS) $(SYMBOLTAB)
	$(LIBORDER) $(TARGET_OBJ)

clean:
	-(rm -rf *.a *.o; rm -rf *@.[ch])

install:
	cp $(TARGET_OBJ) $(INSTALL)/lib
	$(LIBORDER) $(INSTALL)/lib/$(TARGET_OBJ)
	cp *.h $(INSTALL)/include
