# $Id: Makefile.in,v 1.17 2000/03/25 10:34:23 assar Exp $

srcdir		= @srcdir@
VPATH		= @srcdir@

CC		= @CC@
YACC		= @YACC@
LEX		= @LEX@
YFLAGS		= -d

INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
MKINSTALLDIRS 	= @top_srcdir@/mkinstalldirs
ETAGS		= etags
MAKEDEPEND	= makedepend

prefix 		= @prefix@
exec_prefix 	= @exec_prefix@
bindir 		= @bindir@

DEFS		= @DEFS@ -DCPP="\"@CPP@\""

SHELL		= /bin/sh

CFLAGS		= @CFLAGS@
REALCFLAGS	= -I$(srcdir) \
		  -I$(srcdir)/../util \
		  -I../include \
		  -I$(srcdir)/../include \
		  -I. \
		  $(CFLAGS) $(DEFS)
ydr_SRCS	= parse.y lex.l main.c symbol.c types.c output.c
ydr_OBJS	= parse.o lex.o main.o symbol.o types.o output.o
HDRS		= sym.h types.h output.h lex.h parse.h
bin_PROGRAMS	= ydr

SRCS		= $(ydr_SRCS)
OBJS		= $(ydr_OBJS)

all:		$(bin_PROGRAMS)

.PHONY: all install uninstall depend tags clean

.c.o:
		$(CC) -c $(CPPFLAGS) $(REALCFLAGS) $<

.l.c:
		$(LEX) $(LFLAGS) -t $< >$@

install:	all
		$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
		for x in $(bin_PROGRAMS); do \
			f=`echo $$x | sed '$(transform)'`; \
			$(INSTALL_PROGRAM) $$x $(DESTDIR)$(bindir)/$$f; \
		done

uninstall:
		for x in $(bin_PROGRAMS); do \
			f=`echo $$x | sed '$(transform)'`; \
			rm -f $(DESTDIR)$(bindir)/$$f; \
		done

ydr:		$(ydr_OBJS) ../util/libutil.a
		$(CC) $(LDFLAGS) -o $@ $(ydr_OBJS) ../util/libutil.a -L../lib/roken -lroken $(LIBS)

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

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

lex.o:		parse.h

Makefile:	Makefile.in ../config.status
		cd ..; CONFIG_FILES=ydr/Makefile CONFIG_HEADERS= $(SHELL) config.status

depend:		$(SRCS) $(HDRS)
		$(MAKEDEPEND) -- $(REALCFLAGS) -- $^

tags:		TAGS

TAGS:		$(SRCS) $(HDRS)
		$(ETAGS) -t $(SRCS) $(HDRS)

clean		:
		rm -f $(OBJS) $(bin_PROGRAMS) lex.c parse.c parse.h *~ *.o core

mostlyclean:	clean

distclean:	clean
		rm -f Makefile config.status

realclean:	distclean
		rm -f TAGS
