#
# Makefile for zotnet/tws subdirectory
#
# $Id: Makefile.in,v 1.1.1.1 1999/04/01 00:01:53 nathanw Exp $
#

SHELL = /bin/sh

top_srcdir = @top_srcdir@
srcdir     = @srcdir@
VPATH      = @srcdir@

CC         = @CC@
CFLAGS     = @CFLAGS@
DEFS       = @DEFS@
INCLUDES   = -I../.. -I$(srcdir) -I$(top_srcdir)

COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) $(INCLUDES) $(CFLAGS)

AWK = @AWK@
# LEX = @LEX@
LEX = lex
SED = sed

.SUFFIXES:
.SUFFIXES: .c .o

.c.o:
	$(COMPILE) $<

# header files
HDRS = tws.h

# source files
SRCS = dtime.c lexstring.c

# object files
OBJS = dtimep.o dtime.o lexstring.o

# auxiliary files
AUX = Makefile.in dtimep.lex lexedit.sed dtimep.c-lexed

# all files in this directory included in the distribution
DIST = $(HDRS) $(SRCS) $(AUX)

# ========= DEPENDENCIES FOR BUILDING ==========

all: $(OBJS)

# This will bomb if lex is really flex, so check
# file and use pre-generated version if necessary
dtimep.c: $(srcdir)/dtimep.lex $(srcdir)/lexedit.sed
	$(LEX) -nt $(srcdir)/dtimep.lex | $(SED) -f $(srcdir)/lexedit.sed > $@
	-@len=`wc -l $@ | $(AWK) ' { print $$1 } '`; \
	if [ $$len -gt 500 ]; \
	  then exit 0; \
	else \
	  echo "LEX FAILED: using pre-lexed $@"; \
	  cp $(srcdir)/$@-lexed $@; \
	fi

# This needs to be generated by lex, not flex
dtimep.c-lexed: $(srcdir)/dtimep.lex $(srcdir)/lexedit.sed
	$(LEX) -nt $(srcdir)/dtimep.lex | $(SED) -f $(srcdir)/lexedit.sed > $(srcdir)/$@

install:

uninstall:

# ========== DEPENDENCIES FOR CLEANUP ==========

mostlyclean:
	rm -f *.o *~

clean: mostlyclean
	rm -f dtimep.c

distclean: clean
	rm -f Makefile

realclean: distclean
	rm -f dtimep.c-lexed

superclean: realclean

# ========== DEPENDENCIES FOR MAINTENANCE ==========

subdir = zotnet/tws

Makefile: Makefile.in ../../config.status
	cd ../.. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
 
distdir = ../../`cat ../../distname`/$(subdir)
nmhdist: $(DIST)
	@echo "Copying distribution files in $(subdir)"
	@for file in $(DIST); do \
	  cp -p $(srcdir)/$$file $(distdir); \
	done

