# $Id: Makefile,v 1.23 2001/04/25 17:17:04 mhucka Exp $
# $Log: Makefile,v $
# Revision 1.23  2001/04/25 17:17:04  mhucka
# Misc. small changes to improve portability and address compiler warnings.
#
# Revision 1.22  2000/09/07 05:19:34  mhucka
# Had to add some more directories to a -I argument on the CFLAGS, in order
# to allow eval.c to compile properly after the addition of function calls to
# functions defined in ../sim.
#
# Revision 1.21  2000/07/13 18:58:51  mhucka
# Removed RCS directives, because we don't use RCS anymore.
#
# Revision 1.20  2000/07/03 18:06:31  mhucka
# Added LDFLAGS to LIBBUILDFLAGS.
#
# Revision 1.19  2000/06/12 04:54:42  mhucka
# Added IRIX_HACK.  See src/Makefile.dist for info.
#
# Revision 1.18  1999/11/29 07:50:19  mhucka
# Removed needless subshell () wrappers and performed other related cleanup.
#
# Revision 1.17  1999/10/18 01:30:41  mhucka
# Added y.output to the list of things removed by make clean.
#
# Revision 1.16  1999/10/17 23:56:19  mhucka
# Fixed silly annoying duplicate messages about "no lib ordering needed"
# during compilation.  It just required putting an '@' sign in front of
# the echo command for that message.
#
# Revision 1.15  1996/06/28 23:06:53  dhb
# added yyless.o to OBJECTS macro: needed for systems without
# a lex library for yyless() and yywrap() functions
#
# Revision 1.14  1996/05/23  23:01:13  dhb
# t3d/e port
#
# Revision 1.13  1995/11/01  22:33:55  venkat
# Removed-install-target-dependencies
#
# Revision 1.12  1995/05/08  21:45:39  dhb
# Now removes y.tab.[ch] and lex.yy.c on make clean.
#
# Revision 1.11  1995/04/29  01:13:34  dhb
# Added use of YACC and LEX macros to control what program to use for
# the yacc and lex files.
#
# Revision 1.10  1995/02/13  23:00:22  dhb
# Removed RCSWcheckout of RCSRELEASE versions.
#
# Revision 1.9  1994/12/19  22:14:35  dhb
# Added dependency rules for RCS files under RCS directory.  These
# rules aren't suported by all makes, but were ignored by the only
# make (SGI) which didn't support % matching.  So hopefully, this
# won't break things when distributed.
#
# Revision 1.8  1993/09/17  18:41:28  dhb
# Added -D$(MACHINE) to CFLAGS macro.
# This is part of the Solaris comparability changes.  I don't know
# why this is necessary.
#
# Revision 1.7  1993/07/17  00:32:44  dhb
# Separate clean and rcsclean targets
#
# Revision 1.6  1993/07/01  16:38:44  dhb
# clean target was not keeping script.y and script.l chacked out.  Fixed.
#
# Revision 1.5  1993/07/01  15:55:06  dhb
# Added RCSRELEASE stuff
#
# Revision 1.4  1993/03/10  23:35:06  dhb
# Added script.y and script.l to the list of files to keep checked out from
# their respective rcs files.
#
# Revision 1.3  1993/02/12  17:30:24  dhb
# added freeze target to create rcs configurations
# added rcsclean to clean target
# both targets ensure .h .g Makefile and funcs files exist
#
# Revision 1.2  1992/12/11  19:59:07  dhb
# Added RCS check out rules
#
# Revision 1.1  1992/12/11  19:05:14  dhb
# Initial revision
#

SYS  		= 	../sys
SH  		= 	../shell
INCLUDE		= 	-I. -I$(SYS) -I$(SH)

# Makefile for 'ss' library (Script Language Interpreter)
# Altered by Michael D. Speight, 1991
CFLAGS = $(COPT) $(INCLUDE) -D$(OS) $(DEC_HACK) -D$(MACHINE)
INSTALL_DIR =	$(INSTALL)

LIBBUILD	=	$(LD)
LIBBUILDFLAGS	=	$(LDFLAGS) -r -o
LIBORDER	=	@echo no lib ordering needed for
LIBEXT		=	o
TARGET_OBJ	=	ss.$(LIBEXT)

OBJ = \
      eval.o \
      parse.o \
      script.o \
      strsave.o \
      symtab.o \
      yyless.o

default: $(TARGET_OBJ)

.SUFFIXES: .c,v .c .h,v .h

.h,v.h:
	co $*.h

.c,v.o:
	co $*.c
	cc -c $(CFLAGS) $(SIMINCLUDE) $*.c
	rm -f $*.c

$(TARGET_OBJ): $(OBJ)
	$(LIBBUILD) $(LIBBUILDFLAGS) $(TARGET_OBJ) $(OBJ)
	$(LIBORDER) $(TARGET_OBJ)

eval.o: y.tab.h

# 2000-06-10 <mhucka@bbb.caltech.edu>
# IRIX_HACK is a bletcherous hack to avoid getting two hundred warnings 
# under the IRIX cc compiler.  The warnings are generated for things like
# "statement is unreachable", but it's in code that's generated by lex,
# so there's nothing we can do.  I wish there was a cleaner way of
# supplying a flag selectively like this, without resorting to passing
# IRIX_HACK all over the place just for this one thing.

script.o: y.tab.c lex.yy.c
	$(CC) -c $(CFLAGS) $(IRIX_HACK) y.tab.c
	mv y.tab.o script.o

lex.yy.c: script.l
	$(LEX) script.l

y.tab.h y.tab.c: script.y
	$(YACC) -dv script.y

realclean:
	-rm -f *.a *.o y.tab.h y.tab.c lex.yy.c

install:
	-cp $(TARGET_OBJ) $(INSTALL_DIR)/lib
	-$(LIBORDER) $(INSTALL_DIR)/lib/$(TARGET_OBJ)

freeze:
	rcsclean
	rcsfreeze $(VERSION)
	co Makefile *.h,v script.y script.l

clean:
	-rm -f *.a *.o y.tab.h y.tab.c y.output lex.yy.c

rcsclean: clean
	- rcsclean
	co Makefile *.h,v script.y script.l

# mds3
# New line needed to prevent getting default rule if using cross compilers
.c.o:
	$(CC) $(CFLAGS) $(SIMINCLUDE) $< -c
