#
# $Id: Makefile.in,v 1.10.6.1 2000/10/08 03:17:50 lha Exp $
#

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@
AR = ar
RANLIB = @RANLIB@
DEFS = @DEFS@
CFLAGS = @CFLAGS@
YACC = @YACC@
LEX = @LEX@
LN_S = @LN_S@

INSTALL = @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@
MKINSTALLDIRS = @top_srcdir@/mkinstalldirs

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
bindir = @bindir@
includedir = @includedir@

KRB4_INC_FLAGS = @KRB4_INC_FLAGS@

LIBPREFIX = lib
LIBEXT = a
LIBNAME = $(LIBPREFIX)sl
sl_LIB = $(LIBNAME).$(LIBEXT)
LIBNAME2 = $(LIBPREFIX)ss
ss_LIB = $(LIBNAME2).$(LIBEXT)
PROGS = mk_cmds

LIB_SOURCES = sl.c ss.c
EXTRA_SOURCES = strtok_r.c snprintf.c

SOURCES = $(LIB_SOURCES) make_cmds.c $(EXTRA_SOURCES)

LIBADD = strtok_r.o snprintf.o

LIB_OBJECTS = sl.o ss.o $(LIBADD)

mk_cmds_OBJECTS = make_cmds.o parse.o lex.o snprintf.o

OBJECTS = $(LIB_OBJECTS) $(mk_cmds_OBJECTS)

all: $(sl_LIB) $(PROGS)

Wall:
	make CFLAGS="-g -Wall -Wno-comment -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__"

.c.o:
	$(CC) -c $(DEFS) -I../../include -I. -I$(srcdir) $(KRB4_INC_FLAGS) $(CFLAGS) $(CPPFLAGS) $(PICFLAGS) $<

install: all
	$(MKINSTALLDIRS) $(DESTDIR)$(includedir)/ss
	$(INSTALL_DATA) $(srcdir)/ss.h $(DESTDIR)$(includedir)/ss/ss.h
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
	$(INSTALL) -m 555 $(sl_LIB) $(DESTDIR)$(libdir)/$(sl_LIB)
	$(INSTALL) -m 555 $(sl_LIB) $(DESTDIR)$(libdir)/$(ss_LIB)
	$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
	$(INSTALL) -m 0555 $(PROGS) $(DESTDIR)$(bindir)/$(PROGS)

uninstall:
	rm -f $(DESTDIR)$(includedir)/ss/ss.h
	rm -f $(DESTDIR)$(libdir)/$(sl_LIB) $(DESTDIR)$(libdir)/$(ss_LIB)
	rm -f $(DESTDIR)$(bindir)/$(PROGS)

TAGS: $(SOURCES)
	etags $(SOURCES)

check:

clean:
	rm -f $(sl_LIB) $(PROGS) lex.c parse.c parse.h *.o *.a \
		strtok_r.c snprintf.c

mostlyclean: clean

distclean: clean
	rm -f Makefile *~

realclean: distclean
	rm -f TAGS

$(LIBNAME).a: $(LIB_OBJECTS)
	rm -f $@
	$(AR) cr $@ $(LIB_OBJECTS)
	-$(RANLIB) $@

$(OBJECTS): ../../include/config.h

$(mk_cmds_OBJECTS): parse.h

mk_cmds: $(mk_cmds_OBJECTS)
	$(CC) $(CFLAGS) -o $@ $(mk_cmds_OBJECTS) -L../roken -lroken

parse.c: parse.h
parse.h: $(srcdir)/parse.y
	$(YACC) -d $(srcdir)/parse.y
	mv -f y.tab.h parse.h
	mv -f y.tab.c parse.c

lex.c: $(srcdir)/lex.l
	$(LEX) $(srcdir)/lex.l
	mv -f lex.yy.c lex.c

strtok_r.c:
	test -f strtok_r.c || $(LN_S) $(srcdir)/../roken/strtok_r.c .
snprintf.c:
	test -f snprintf.c || $(LN_S) $(srcdir)/../roken/snprintf.c .

.PHONY: all Wall install uninstall check clean mostlyclean distclean realclean
