# $Id: Makefile.in,v 1.3 2001/10/26 22:13:02 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
ompcincdir	=	$(ompcdir)/include
ompclibexecdir	=	$(ompcdir)/libexec
ompclibdir	=	$(ompcdir)/lib
ompcclassdir	=	$(ompcdir)/java
ompctempldir	=	$(ompcdir)/template

INSTALLDIR	=	$(ompclibdir)
INSTALLHDRDIR	=	$(ompcincdir)
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 @SCASH_INC@ @DEFS@ @CPPFLAGS@ @SHMEM_FLAGS@
CFLAGS		=	$(CC_OPT_SWITCH) $(CPPFLAGS)

CC		=	@CC@ 
AR		=	@AR@
RANLIB		=	@RANLIB@

YACC		=	@YACCCOM@

DEPEND_SWITCH	=	$(CPPFLAGS)

SRCS		= ompsm_thread.c ompsm_data.c ompsm_runtime.c @SHMEM_SRC@.c \
			ompsm_lib.c

OBJS		= ompsm_thread.o ompsm_data.o ompsm_runtime.o @SHMEM_SRC@.o \
			ompsm_lib.o

TARGET		= libompc_sm.a

RUNTIME		= ompc_main_sm.o
RUNTIME_SRC	= ompsm_main.c

all:	$(TARGET) $(RUNTIME)

$(TARGET): $(OBJS)
	@rm -f $(TARGET)
	$(AR) $(TARGET) $(OBJS)
	$(RANLIB) $(TARGET)

$(RUNTIME): $(RUNTIME_SRC)
	$(CC) -c $(CFLAGS) -o $(RUNTIME) $(RUNTIME_SRC)

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

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

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

depend: omp.h ompclib.h timer.h $(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)
