#### insert configury here
# flags
BUILDTOP=$(C)$(S)$(U)$(U)

# hard coded srcdir/.. is so that ss/ss.h works

# hard coded .. is so that ss/ss_err.h works
# hard coded ../et is so com_err.h works
# CFLAGS= -I${INCDIR} -I. -I.. -I../et -g
LOCALINCLUDE= -I. -I$(srcdir)/.. -I$(srcdir)/../et -I..

# for the library

LIB=	libss.a

# with ss_err.o first, ss_err.h should get rebuilt first too.  should not
# 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  \
	ss_err.h
# ss_err.h here, so that make depend catches it.

CODE= $(SRCS) $(MKCMDSFILES)

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

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

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

depend:: mk_cmds.c utils.c options.c

# for sunmake
cmd_tbl.lex.c: cmd_tbl.lex.l
cmd_tbl.lex.o: cmd_tbl.lex.c
ct.tab.c: ct.y
mk_cmds.o: mk_cmds.c ss_err.h
utils.o: utils.c
options.o: options.c
ct.tab.o: ct.tab.c

HFILES=	ss.h ss_internal.h copyright.h

# for 'tags' and dependencies

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

# for building archives

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

#
# stuff to build
#

all::	mk_cmds libss.a # libss_p.a

dist:	archives

install:: install-prog install-lib install-headers

install-lib: 
	$(INSTALLLIB) libss.a ${DESTDIR}$(LIBDIR)/libss.a
	$(CHMOD) 644 $(DESTDIR)$(LIBDIR)/libss.a
	$(RANLIB)    $(DESTDIR)$(LIBDIR)/libss.a
	$(CHMOD) 444 $(DESTDIR)$(LIBDIR)/libss.a

install-headers: ss_err.h 
	@rm -rf ${DESTDIR}$(INCLDIR)/ss
	-if [ ! -d $(DESTDIR)$(INCLDIR) ]; then mkdir $(DESTDIR)$(INCLDIR); fi
	@mkdir ${DESTDIR}$(INCLDIR)/ss
	for i in $(HFILES) copyright.h; do \
		$(INSTALLFILE) $(srcdir)/$$i ${DESTDIR}$(INCLDIR)/ss/$$i; \
	done
	$(INSTALLFILE) ss_err.h ${DESTDIR}$(INCLDIR)/ss/ss_err.h
	$(INSTALLFILE) $(srcdir)/copyright.h ${DESTDIR}$(INCLDIR)/ss/mit-sipb-copyright.h

std_rqs.c: std_rqs.ct

ss_err.h: ss_err.et

ss_err.c: ss_err.et

clean:: clean-prog clean-old
	$(RM) ss_err.o ss_err.c ss_err.h
	$(RM) libss.a
	$(RM) $(OBJS)

distclean:: clean
	$(RM) *~ core
	$(RM) Makefile config.status 

depend:: ss_err.h

ct.tab.c ct.tab.h: ct.y
	rm -f ct.tab.* y.*
	yacc -d $(srcdir)/ct.y
	mv -f y.tab.c ct.tab.c
	mv -f y.tab.h ct.tab.h

# install_library_target(ss,$(OBJS),$(SRCS),)
all:: libss.a ss_err.h

libss.a: $(OBJS)
	$(RM) $@
	$(ARCHIVE) $@ $(OBJS)
	$(RANLIB) $@

## 


libss.o:	$(OBJS)
	$(LD) -r -s -o $@ $(OBJS)
	$(CHMOD) -x $@

# program(mk_cmds,$(MKCMDSOBJS), , LEXLIB BSDLIB,$(PROGDIR)) 
all:: mk_cmds

mk_cmds: $(MKCMDSOBJS)
	$(CC) $(CFLAGS) -o $@ $(MKCMDSOBJS) $(LEXLIB) $(BSDLIB)

install-prog:
	$(INSTALLPROG) mk_cmds ${DESTDIR}$(PROGDIR)/mk_cmds

clean-prog::
	$(RM) mk_cmds $(MKCMDSOBJS)

# 

clean-old::
	rm -f *.o *~ \#* *.bak core \
		ss_err.h ct.tab.c ct.tab.h cmd_tbl.lex.c \
		lex.yy.c y.tab.c \
		libss.a libss_p.a llib-lss.ln mk_cmds \
		ss.ar ss.tar \
		TAGS test_ss

