/*
 * Imakefile for htool 2.x
 *
 * $Id: Imakefile,v 1.2 1994/06/11 20:35:28 moore Exp $
 *
 * $Log: Imakefile,v $
 * Revision 1.2  1994/06/11  20:35:28  moore
 * add Bondo to SUBDIRS; delete eaccess.c from SRCS
 *
 * Revision 1.1  1994/02/17  20:17:05  moore
 * Initial revision
 *
 */

#include "../imake.defs"
DEFINES=-DARCHSTR=\"$(PVM_ARCH)\" -DIMA_$(PVM_ARCH) $(HENCE_DEFINES) -IBondo -I$(PVM_INCLUDEDIR)
LOCAL_LIBRARIES=Bondo/libbondo.a $(LIBPVM)
# Bondo/libefence.a
SYS_LIBRARIES=$(HENCE_LIBRARIES) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XEXTLIB) $(XLIB) -lm
SUBDIRS=Bondo

default: htool proxyd

depend:: graph_parse.y subdefs.y graph_parse.lex subdefs.lex
	make subdefs.c
	make graph_parse.c
	make psheader.c

SRCS=arches.c build.c config.c costmat.c dot_htool.c exp.c \
     filenames.c filever.c graph.c graph_critic.c graph_draw.c graph_edit.c \
     graph_panel.c graph_parse.c graph_print.c graph_unparse.c help.c \
     histo.c info_panel.c labels.c main.c menu.c msg.c mode.c param.c \
     proxy.c psheader.c pvmglue.c pvm_panel.c rb.c regexp.c regexp-glue.c \
     subdefs.c subproc.c text_sink.c tfread.c tilde.c trace_new.c xtglue.c \
     Canvas.c FileSelect.c Matrix.c
OBJS=arches.o build.o config.o costmat.o dot_htool.o exp.o \
     filenames.o filever.o graph.o graph_critic.o graph_draw.o graph_edit.o \
     graph_panel.o graph_parse.o graph_print.o graph_unparse.o help.o \
     histo.o info_panel.o labels.o main.o menu.o msg.o mode.o param.o \
     proxy.o psheader.o pvmglue.o pvm_panel.o rb.o regexp.o regexp-glue.o \
     subdefs.o subproc.o text_sink.o tfread.o tilde.o trace_new.o xtglue.o \
     Canvas.o FileSelect.o Matrix.o

ComplexProgramTarget(htool)

htool: Bondo/libbondo.a

Bondo/libbondo.a:
	(cd Bondo; make libbondo.a)

build_help: build_help.c
	$(CC) $(CFLAGS) -o build_help build_help.c

graph_parse.c: graph_parse.y graph_parse.lex.out
	yacc graph_parse.y
	sed -e 's/yy/y1y/g' < y.tab.c > $@
#if 0
	sed -e '/^# *[0-9]/d' -e '/^# *line/d' -e 's/yy/y1y/g' < y.tab.c > $@
#endif

graph_parse.lex.out: graph_parse.lex
	lex graph_parse.lex
	sed -e 's/yy/y1y/g' < lex.yy.c > $@

help.o: helptext.c help.c
	$(CC) $(CFLAGS) -c help.c

helptext.c: help.txt build_help
	./build_help < help.txt > helptext.c

subdefs.c: subdefs.y subdefs.lex.out
	yacc subdefs.y
	sed -e 's/yy/y2y/g' < y.tab.c > $@
	chmod o-w $@
#if 0
	sed -e '/^# *[0-9]/d' -e '/^# *line/d' -e 's/yy/y2y/g' < y.tab.c > $@
#endif

subdefs.lex.out: subdefs.lex
	lex subdefs.lex
	sed -e 's/yy/y2y/g' < lex.yy.c > $@

psheader.c: psheader.ps
	rm -f $@
	echo '/* This file generated by make from psheader.ps */' >> $@
	echo '' >> $@
	echo 'char *psheader[] = {' >> $@
	sed -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n",/' psheader.ps >> $@
	echo '0' >> $@
	echo '};' >> $@

proxyd: proxyd.c $(LOCAL_LIBRARIES)
	$(CC) -o proxyd $(DEFINES) proxyd.c $(LOCAL_LIBRARIES)

clean::
	rm -f graph_parse.c graph_parse.lex.out subdefs.c subdefs.lex.out
	rm -f build_help proxyd helptext.c psheader.c

clean::
	rm -f lex.yy.c y.tab.c

install:: proxyd
	@-[ -d $(HOME)/pvm3/bin ] || ( set -x ; mkdir $(HOME)/pvm3/bin )
	@-[ -d $(BINDIR) ] || (set -x ; mkdir $(BINDIR))
	-mv $(BINDIR)/proxyd $(BINDIR)/proxyd.old
	cp proxyd $(BINDIR)/proxyd
	rm -f $(BINDIR)/proxyd.old

tfdump:: tfdump.c tfread.c tfnew.h
	$(CC) $(CFLAGS) -o tfdump tfdump.c tfread.c

MakefileSubdirs($(SUBDIRS))

CleanSubdirs($(SUBDIRS))

NamedTargetSubdirs($(SUBDIRS),$(SUBDIRS),"making" all, ,all)
