# For detailed installation instructions, read the README file.
#
# This version of `slsc' uses the S-Lang library for most of its 
# functionality.  S-Lang has been distributed with this program (see ../slang).
# Build it first.  

# Directory where libslang.a is located
SLANGDIR = ../../slang/src

# Root directory where slsc files are going to be kept.  Currently, it 
# only holds the file slsc.hlp.  In the future, it might be used for more.
# MAKE SURE THAT THE '#'IMMEDIATELY FOLLOWS THE PATH.  THERE CAN BE NO 
# WHITESPACE HERE!
SLSC_ROOT = /usr/local/lib/slsc#  <--- Note location of the `#' !!!

CFLAGS = -O
# Your C compiler.  
CC = cc
#CC = gcc -Wall -fstrict-prototypes         #  <---- Linux
#CC = gcc -traditional-cpp                  #  <---- use this form for SunOS

#YACC=bison -y
YACC = yacc

# Miscellaneous options
# Set SIGVOID if signal routines are type void.  System 5.3, VMS and ANSI C
# Compliant systems use this.  Most BSD systems do not.
SIGVOID=-DSIGVOID


# Some systems require you to link to curses to get at the termcap functions.
LIB = -lm -ltermcap

NAME = slsc


# This is the name of a pager like "more" If the line is commented out
# then "more" will be used. "pg" may be appropriate for SYSV
PAGER=-DDFLT_PAGER=\"most\"

# The objects
OBJS=sc.o interp.o cmds.o crypt.o range.o lex.o gram.o\
   scdokey.o schelp.o

CFLAGS1 = $(CFLAGS) $(SIGVOID)

$(NAME): $(OBJS) $(SLANGDIR)/libslang.a
	$(CC) ${CFLAGS1} ${LDFLAGS} ${OBJS} -L$(SLANGDIR) -lslang $(LIB) -o $(NAME)

$(SLANGDIR)/libslang.a:
	@echo You need to build $(SLANGDIR)/libslang.a
	(cd $(SLANGDIR); make)
	

.c.o:
	$(CC) -c $(CFLAGS1) -I$(SLANGDIR) $*.c

lex.o:	sc.h y.tab.h gram.o
	$(CC) $(CFLAGS1) -I$(SLANGDIR) -c lex.c

sc.o:	sc.h sc.c
	$(CC) $(CFLAGS1) -DSLSC_ROOT='"$(SLSC_ROOT)"' -I$(SLANGDIR) $(PAGER) -c sc.c

interp.o:	interp.c sc.h

gram.o:	sc.h y.tab.h

cmds.o: cmds.c sc.h

crypt.o: crypt.c sc.h

range.o: range.c sc.h

help.o: help.c sc.h

y.tab.h:	gram.y

gram.o:	sc.h y.tab.h gram.c
	$(CC) ${CFLAGS1} -I$(SLANGDIR) -c gram.c
	sed<gram.y >experres.h -f eres.sed;sed < gram.y > statres.h -f sres.sed

gram.c:	gram.y
	$(YACC) -d gram.y; mv y.tab.c gram.c

clean:
	rm -f *.o *res.h y.tab.h $(NAME) debug core gram.c y.output *~

install:
	echo Read README for instructions.  If you care to modiify this
	echo makefile to do the install, do not hesitate to send me the
	echo patches.

vprint:	vprint.o
	$(CC) $(CFLAGS) -o vprint vprint.o
