
#ETDIR=../../et/src/

DEFINES=-I. 

LIB=	libss.a
COMERR=	-lcom_err

# with ss_err.o first, ss_err.h should get rebuilt first too.  shouldn't
# be relying on this, though.
OBJS=	ss_err.o \
	std_rqs.o \
	invocation.o help.o \
	execute_cmd.o listen.o parse.o error.o prompt.o \
	request_tbl.o list_rqs.o pager.o requests.o \
	data.o

SRCS=	invocation.c help.c \
	execute_cmd.c listen.c parse.c error.c prompt.c \
	request_tbl.c list_rqs.c pager.c requests.c \
	data.c

# for mk_cmds program

MKCMDSOBJS=	mk_cmds.o utils.o options.o ct.tab.o cmd_tbl.o

MKCMDSFILES=	mk_cmds.c utils.c options.c ct.y cmd_tbl.l

MKCMDSCSRCS=	mk_cmds.c utils.c options.c ct.tab.c cmd_tbl.c

# the include files

HFILES=	ss.h ss_internal.h copyright.h

# for 'tags' and dependencies

CFILES=	$(SRCS) $(MKCMDSCSRCS) test.c

# for building archives

FILES=	$(SRCS) $(MKCMDSFILES) $(HFILES) \
	ss_err.et std_rqs.ct Makefile \
	test.c commands.ct ss mit-sipb-copyright.h

create_dir($(ATHINCDIR)/ss)

ProfiledObjectRule()

SimpleLibrary(ss,$(OBJS),$(ATHLIBDIR))
SimpleLint(ss,$(SRCS))

SimpleProgram(mk_cmds, $(MKCMDSOBJS),-ll,$(ATHBINDIR))

install_file(ss.h,$(ATHINCDIR)/ss/)
install_file(ss_err.h,$(ATHINCDIR)/ss/)
install_file(ss_internal.h,$(ATHINCDIR)/ss/)
install_file(copyright.h,$(ATHINCDIR)/ss/)
install_file(copyright.h,$(ATHINCDIR)/ss/mit-sipb-copyright.h)

all::	mk_cmds


clean::
	rm -f \#* *.bak \
		ss_err.h ss_err.c ct.tab.c ct.tab.h cmd_tbl.c \
		lex.yy.c y.tab.c \
		ss.ar ss.tar std_rqs.c \
		TAGS test

.SUFFIXES:	.ct

std_rqs.c: mk_cmds std_rqs.ct
	./mk_cmds std_rqs.ct

ss_err.o ss_err.h : ss_err.et
	$(ETDIR)compile_et ss_err.et
	rm -f ss_err.o profiled/ss_err.o
	$(CC) $(CFLAGS) -c ss_err.c
	cp ss_err.o profiled/ss_err.o

ct.tab.c ct.tab.h: ct.y
	rm -f ct.tab.* y.*
	yacc -d ct.y
	mv -f y.tab.c ct.tab.c
	mv -f y.tab.h ct.tab.h

libss.o:	$(OBJS)
	ld -r -s -o $@ $(OBJS)
	chmod -x $@

../et/llib-lcom_err.ln:
	cd ../etc ; make ${MFLAGS} llib-lcom_err.ln

TAGS:	$(CFILES)
	-etags $(CFILES)

archives: ss.ar ss.tar

ss.ar:	$(FILES)
	ar cru $@ $(FILES)

ss.tar:	$(FILES)
	rm -f $@
	tar crf $@ $(FILES)

test:	test.o commands.o $(LIB)
	${CC} ${CFLAGS} -o test test.o commands.o $(LIB) $(COMERR)

commands.c: mk_cmds commands.ct
	./mk_cmds commands.ct

dist:	archives
tags:	TAGS

saber:	${SRCS} ss_err.o std_rqs.o
	saber ${SABEROPTS} ${SRCS} -I../et -G ss_err.o std_rqs.o -lcom_err

depend:: $(CFILES) ss_err.h
	makedepend $(CFLAGS) $(CFILES) 


