# $Id: Makefile.in,v 1.12 2002/02/20 07:53:34 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.
#  
#  
#  $

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

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

CC		=	@CC@

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

wrapper_prefix		=	@wrapperPrefix@
wrapper_exec_prefix	=	@wrapperExecPrefix@

wrapper_bindir		=	$(wrapper_exec_prefix)/bin
wrapper_libdir		=	$(wrapper_prefix)/lib

wrapper_ompcdir		=	$(wrapper_libdir)/openmp
wrapper_ompclibexecdir	=	$(wrapper_ompcdir)/libexec
wrapper_ompclibdir	=	$(wrapper_ompcdir)/lib
wrapper_ompcclassdir	=	$(wrapper_ompcdir)/java
wrapper_ompctempldir	=	$(wrapper_ompcdir)/template

WRAPPER_IS_DEFAULT	= @wrapperInstallDefault@
WRAPPER_INSTALLDIR	= $(wrapper_ompclibexecdir)

OMPC_DIR = $(prefix)

DRIVER		= omniDriver
LAUNCHER	= omf77 omcc omc++ @OGRCC_DRIVER@
TARGET		= $(DRIVER) $(LAUNCHER)

all: $(TARGET)

omniDriver:	omniDriver.in
	(cd ../..; sh ./config.status)
	chmod 755 $@

omf77:	launcher.c
	rm -f $@
	$(CC) $(CFLAGS) -DLANG_F77 -DDRIVER=\""omniDriver"\" \
		-DOMNI_INSTALL_DIR=\""$(ompclibexecdir)"\" launcher.c -o $@

omcc:	launcher.c
	rm -f $@
	$(CC) $(CFLAGS) -DLANG_C -DDRIVER=\""omniDriver"\" \
		-DOMNI_INSTALL_DIR=\""$(ompclibexecdir)"\" launcher.c -o $@

omc++:	launcher.c
	rm -f $@
	$(CC) $(CFLAGS) -DLANG_CXX -DDRIVER=\""omniDriver"\" \
		-DOMNI_INSTALL_DIR=\""$(ompclibexecdir)"\" launcher.c -o $@

ogrcc:	launcher.c
	rm -f $@
	$(CC) $(CFLAGS) -DLANG_C -DDRIVER=\""omniDriver"\" \
		-DOMNI_INSTALL_DIR=\""$(ompclibexecdir)"\" -DOGRCC launcher.c -o $@

ogrc++:	launcher.c
	rm -f $@
	$(CC) $(CFLAGS) -DLANG_CXX -DDRIVER=\""omniDriver"\" \
		-DOMNI_INSTALL_DIR=\""$(ompclibexecdir)"\" -DOGRCC launcher.c -o $@

install: $(TARGET) system.conf
	@if [ ! -d $(INSTALLDIR) ] ; then \
		(echo "Making directory $(INSTALLDIR)" ; \
		$(MKDIR) $(INSTALLDIR) ; \
		chmod 775 $(INSTALLDIR)); \
	else \
		true ; \
	fi
	for i in $(LAUNCHER); do \
		$(INSTALL) -m 755 $$i $(INSTALLDIR) ; \
	done
	( \
		cd $(INSTALLDIR) ; \
		for i in f77 cc; do \
			rm -f ./omp$$i; \
			ln -s ./om$$i ./omp$$i; \
		done; \
	)
	@if [ ! -d $(ompclibexecdir) ] ; then \
		(echo "Making directory $(ompclibexecdir)" ; \
		$(MKDIR) $(ompclibexecdir) ; \
		chmod 775 $(ompclibexecdir)); \
	else \
		true ; \
	fi
	$(INSTALL) -m 755 $(DRIVER) $(ompclibexecdir)
	@if [ ! -d $(ompctempldir) ] ; then \
		(echo "Making directory $(ompctempldir)" ; \
		$(MKDIR) $(ompctempldir) ; \
		chmod 775 $(ompctempldir)); \
	else \
		true ; \
	fi	
	$(INSTALL) -m 644 system.conf $(ompctempldir)
	@if [ "x$(wrapper_prefix)" != "x" ] ; then \
		if [ ! -d $(wrapper_ompclibexecdir) ] ; then \
			(echo "Making directory $(wrapper_ompclibexecdir)" ; \
			$(MKDIR) $(wrapper_ompclibexecdir) ; \
			chmod 775 $(wrapper_ompclibexecdir)); \
		else \
			true ; \
		fi ; \
	fi
	if [ "x$(wrapper_prefix)" != "x" ] ; then \
		if [ ! -x $(WRAPPER_INSTALLDIR)/${DRIVER} -o $(WRAPPER_IS_DEFAULT) = "yes" ] ; then \
			$(INSTALL) -m 755 $(DRIVER) $(WRAPPER_INSTALLDIR) ; \
		fi ; \
	fi

clean:
	rm -f $(TARGET) core *~ *.exe

distclean:	clean
	rm -f config.* Makefile .depend* $(TARGET) core *~ ./system.conf

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

depend:

test:
