#
# $Id: Makefile.in,v 1.31 1999/03/10 19:01:17 joda Exp $
#

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

top_builddir=../..

CC = @CC@
LINK = @LINK@
AR = ar
RANLIB = @RANLIB@
LN_S = @LN_S@
DEFS = @DEFS@ -DROKEN_RENAME
CFLAGS = @CFLAGS@ $(WFLAGS)
WFLAGS = @WFLAGS@
LD_FLAGS = @LD_FLAGS@
YACC = @YACC@
LEX = @LEX@

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

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

LIB_DEPS = @lib_deps_yes@ @LIB_readline@ -lc
build_symlink_command   = @build_symlink_command@
install_symlink_command = @install_symlink_command@
install_symlink_command2 = @install_symlink_command2@

PICFLAGS = @PICFLAGS@
EXECSUFFIX = @EXECSUFFIX@
 
LIBEXT = @LIBEXT@
SHLIBEXT = @SHLIBEXT@
LIBPREFIX = @LIBPREFIX@
LIBNAME = $(LIBPREFIX)sl
sl_LIB = $(LIBNAME).$(LIBEXT)
LIB = $(sl_LIB)
LIBNAME2 = $(LIBPREFIX)ss
ss_LIB = $(LIBNAME2).$(LIBEXT)
LIB2 = $(ss_LIB)
LDSHARED = @LDSHARED@
PROGS = mk_cmds$(EXECSUFFIX)

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) -I$(srcdir)/../des $(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)
	@install_symlink_command@
	@install_symlink_command2@
	$(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 *.so *.so.* so_locations

mostlyclean: clean

distclean: clean
	rm -f Makefile *~

realclean: distclean
	rm -f TAGS

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

$(LIBNAME).$(SHLIBEXT): $(LIB_OBJECTS)
	rm -f $@
	$(LDSHARED) -o $@ $(LIB_OBJECTS) $(LIB_DEPS)
	@build_symlink_command@

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

$(mk_cmds_OBJECTS): parse.h

mk_cmds$(EXECSUFFIX): $(mk_cmds_OBJECTS)
	$(LINK) $(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:
	$(LN_S) $(srcdir)/../roken/strtok_r.c .
snprintf.c:
	$(LN_S) $(srcdir)/../roken/snprintf.c .

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