####################################################################
#   Copyright (c) 1996 NPACT Working Group. You may copy,          #
#   distribute, and modify it freely as long as you preserve this  #
#   copyright and permission notice.                               #
#                                                                  #
#   NPACT Working Group is a joint force of                        #
#      NPAC at Syracuse University,                                #
#      PACT at Harbin Institute of Technology, and                 #
#      PACT at Peking University                                   #   
####################################################################

#
#  Makefile for HPF parser 
#

SHELL       = /bin/sh

VERSION     = @VERSION@

srcdir      = @srcdir@
top_srcdir  = @top_srcdir@

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

INCLUDEDIR= @top_srcdir@/src/include
config_dir = ../include 

VPATH = .:${srcdir}

LIBDIR = ../basicop

ULIBS = -lbasic 

SLIBS = -ll @YYLIB_L@


LEX     = @LEX@
LEX_OUT = @LEX_OUTPUT_ROOT@
LLFLAGS = @LLFLAG@

YACC = @YACC@
YYFLAGS = @YYFLAG_L@

CC =  @CC@
CFLAGS= @CFLAGS@ @DEFS@ -D_${LEX}_ -I. -I${srcdir} -I$(config_dir) -I$(INCLUDEDIR)

PROGRAM = java2dep

OBJS = java2dep.o javaDparser.o javalexer.o  makespec.o exec_part.o use.o

DEPENDENCES =   $(INCLUDEDIR)/defnodes.h \
		$(INCLUDEDIR)/tags.h \
		$(INCLUDEDIR)/bif.h  \
		$(INCLUDEDIR)/ll.h \
		$(INCLUDEDIR)/symb.h \
		$(INCLUDEDIR)/typedef.h \
		$(INCLUDEDIR)/makenodes.h


.SUFFIXES:
.SUFFIXES: .l .y .c .o

.l.o:
	$(LEX) $(LLFLAGS) $<
	mv lex.yy.c $*.c
	$(CC) -c $(CFLAGS) $*.c

.y.o:
	$(YACC) $(YYFLAGS) $<
	mv y.tab.c $*.c
	mv y.tab.h $*.tab.h
#
# begin	error report file generation
	@echo "+++ generating error.def from" $*.tab.h
	grep '^#[ |\t]*define' $*.tab.h | \
	sed 's/^#[ |\t]*define[ |\t]*/"/' | sed 's/$$/",/'> error.def
# end	
	$(CC) -c $(CFLAGS) $*.c

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


all: Makefile $(PROGRAM)

Makefile: ${srcdir}/Makefile.in
	@echo 
	@echo Please configure the package to generate new makefile ...
	@exit 1

$(PROGRAM) : $(OBJS) $(LIBDIR)/libbasic.a
	$(CC) -g -o $@ $(OBJS) -L$(LIBDIR) $(SLIBS) $(ULIBS) 

jpp: ${srcdir}/jpp.in
	@echo 
	@echo Please configure the package to generate new jpp file ...
	@exit 1
	
javaDparser.y : javaparser.y  jD.y  err.deal
	cat ${srcdir}/javaparser.y ${srcdir}/jD.y ${srcdir}/err.deal > javaDparser.y

clean:
	rm -f *.o javaDparser.tab.h
	rm -f y.output javaDparser.y javaDparser.c javalexer.c y.tab.* error.def
	rm -f $(PROGRAM) jpp
	rm -f core

install: $(PROGRAM)
	if [ ! -d ${bindir} ] ; then mkdir ${bindir} ; fi
	cp $(PROGRAM) ${bindir}
	cp jpp        ${libdir}

uninstall:
	rm -f ${bindir}/$(PROGRAM)
	rm -f ${libdir}/jpp

#       
# file dependence information
#

java2dep.o : java2dep.c $(DEPENDENCES)

javalexer.o : javalexer.l keywords.h $(INCLUDEDIR)/defnodes.h  javaDparser.tab.h

javaDparser.o : javaDparser.y err_token.h $(DEPENDENCES)

makespec.o : makespec.c extern.h $(DEPENDENCES)

exec_part.o: exec_part.c extern.h $(DEPENDENCES)

use.o :  use.c extern.h $(DEPENDENCES)







