# $Id: Makefile.in,v 1.13 2001/11/15 09:32:38 m-hirano Exp $
# $RWC_Release: Omni-1.6 $
# $RWC_Copyright:
#  Omni Compiler Software Version 1.5-1.6
#  Copyright (C) 2002 PC Cluster Consortium
#  
#  This software is free software; you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License version
#  2.1 published by the Free Software Foundation.
#  
#  Omni Compiler Software Version 1.0-1.4
#  Copyright (C) 1999, 2000, 2001.
#   Tsukuba Research Center, Real World Computing Partnership, Japan.
#  
#  Please check the Copyright and License information in the files named
#  COPYRIGHT and LICENSE under the top  directory of the Omni Compiler
#  Software release kit.
#  
#  
#  $
#
#	Makefile for a C compiler front-end
#	using the second pass of the exc back-end as code generator.
#

TOPDIR		=	..
prefix		=	@prefix@
exec_prefix	=	@exec_prefix@

bindir		=	$(exec_prefix)/bin
libdir		=	$(prefix)/lib

ompcdir		=	$(libdir)/openmp
ompclibexecdir	=	$(ompcdir)/libexec
ompclibdir	=	$(ompcdir)/lib
ompcclassdir	=	$(ompcdir)/java
ompctempldir	=	$(ompcdir)/template

INSTALLDIR	=	$(ompclibexecdir)
INSTALL		= 	@INSTALLCOM@
MKDIR		=	@MKDIRCOM@

GCCINC		=	-I`case "$(CC)" in *gcc) echo \`$(CC) -v 2>&1 | grep specs | sed 's/specs$$/include/' | awk '{ print $$NF }'\`;; esac`


CC_OPT_SWITCH	=	@CFLAGS@
CPPFLAGS	=	-I. -I$(TOPDIR)/include @DEFS@ @CPPFLAGS@ @OPENGR_DEF@
CFLAGS		=	$(CC_OPT_SWITCH) $(CPPFLAGS)

CC		=	@CC@ 

YACC		=	@YACCCOM@

DEPEND_SWITCH	=	$(CPPFLAGS)

#
# C Frontend for exc
#

SRCS	= C-compile-decl.c C-compile-expr.c C-expr-mem.c C-main.c \
	C-mem.c C-opt-expv.c C-pragma.c C-tea-pragma.c X-decompile.c \
	X-io.c machine-dep.c C-omp-pragma.c \
	C-exprcode.c C-parser.c @OPENGR_SRCS@

OBJS	= C-compile-decl.o C-compile-expr.o C-expr-mem.o C-main.o \
	C-mem.o C-opt-expv.o C-pragma.o C-tea-pragma.o X-decompile.o \
	X-io.o machine-dep.o C-omp-pragma.o \
	C-exprcode.o C-parser.o @OPENGR_OBJS@

TARGET	= C-front

all:	$(TARGET)

C-front : C-exprcode.h C-exprcode.c C-parser.c $(OBJS)
	$(CC) $(CC_OPT_SWITCH) $(OBJS) -o C-front

C-parser.c: C-parser.y C-lex.c
	$(YACC) -v C-parser.y
	@echo "(expect 8 shift/reduce, 6 reduce/reduce)"
	mv y.tab.c C-parser.c

C-exprcode.h: C-exprcode.def C-exprcode.h.awk
	awk -f C-exprcode.h.awk < C-exprcode.def > C-exprcode.h

C-exprcode.c: C-exprcode.def C-exprcode.c.awk
	awk -f C-exprcode.c.awk < C-exprcode.def > C-exprcode.c

install: $(TARGET)
	@if [ ! -d $(INSTALLDIR) ] ; then \
		(echo "Making directory $(INSTALLDIR)" ; \
		$(MKDIR) $(INSTALLDIR) ; \
		chmod 775 $(INSTALLDIR)); \
	else \
		true ; \
	fi
	$(INSTALL) -m 755 $(TARGET) $(INSTALLDIR)

clean:
	rm -f C-parser.c y.tab.c y.output *.o *~ $(OBJS) C-front *.exe \
		C-exprcode.[ch] core *.core

distclean:	clean
	rm -f config.* Makefile .depend*

depend: C-exprcode.h C-exprcode.c $(SRCS)
	touch .depend.tmp
	makedepend -f ./.depend.tmp -a -- $(GCCINC) $(DEPEND_SWITCH) -- $(SRCS)
	sed 's:^$(PLATFORMDIR)/:./:' ./.depend.tmp > ./.depend
	cat Makefile ./.depend > ./Makefile.tmp
	mv Makefile.tmp Makefile
	rm -f ./.depend ./.depend.tmp .depend.tmp.bak

Makefile::
	(cd ../; sh ./config.status)
