#
# Makefile for induce
#
TOPDIR := ..
include $(TOPDIR)/make.common

CFILES	= bytecode.c induce.c mainduce.c memoize.c parser.c
HFILES	= induce.h parser.h
OFILES	= $(CFILES:.c=.o)
PFILES	= $(CFILES:.c=.op)

# The following defines are relevant to induce:
#
#  _PATH_M4
#   Contains the complete path of the m4(1) executable. If undefined,
#   defaults to "/usr/bin/m4". On SunOS machines, this version of m4(1) is
#   broken; choose "/usr/5bin/m4" instead.
#
#  _PATH_TMPDIR
#   The pathname of a temporary directory, without a trailing slash. It will
#   default to "/tmp" if undefined.
#
#  _PATH_RULES
#   A colon-separated list of filenames, which is the default search list
#   when the environment variable INDUCEFILES is undefined. If undefined,
#   defaults to "my_rules.m4:my_rules".
#
#  _PATH_MEMO
#   The default filename of the memo file. Default value is "memo.gdbm".
#

# for SunOS only:
#CPPFLAGS += -D_PATH_M4=\"/usr/5bin/m4\"

all: induce
profil: induce_p

induce: $(OFILES) $(LIBDIR)/libsaml.a
	$(CC) $(LDFLAGS) -o $@~ $(OFILES) -lsaml -lgdbm
	mv $@~ $@

induce_p: $(PFILES) $(LIBDIR)/libsaml_p.a
	$(CC) $(LDFLAGS) -pg -static -o $@~ $(PFILES) -lsaml_p -lgdbm
	mv $@~ $@

veryclean: clean
	rm -f *.s *.orig parser.[ch] induce induce_p

parser.h: parser.c
parser.c: rules.y
	$(YACC) -dv $<
	cmp -s y.tab.h parser.h || mv y.tab.h parser.h
	rm -f y.tab.h
	mv y.tab.c parser.c

include .depend
