#
# $Id: Makefile,v 1.8 1999/09/02 18:37:55 gcla Exp $
#
# file       	: Makefile
# description	: PWB Makefile
# author     	: Graham Clark
# Time-stamp    : <02 Sep 99 19:36:16 gcla>
#
# Produced for building PEPA Workbench (pwb)
#

MOSSRCS =  CommandLine
SRCS	=  Error Options Files Expressions HashTable Pepa Identifiers \
           Sort \
           Semantic Prettyprinter Derivatives PepaParser

MOSBSRCS=  CommandLine
BSRCS	=  Error Options Files Expressions HashTable Pepa Identifiers \
           Sort \
           Semantic Prettyprinter Table Statespace Min Derivatives Graph \
           PepaParser PepaLexer Getopt
LNKOBJS =  Int Real Obj Word Word8 Word8Vector Word8Array CharVector \
           CharArray Lexing Parsing Location

#SRCS	=  CommandLine Error Options HashTable Files Pepa Lexer Sort Parser Semantic Prettyprinter Table Statespace Derivatives Graph Min PWB

#EXTRASRCS = mosmlpwb
EXTRASRCS = PWB mosmlpwb

SIGS	= $(MOSSRCS:%=%.sig) $(SRCS:%=%.sig)
SMLS	= $(MOSBSRCS:%=%.sml) $(BSRCS:%=%.sml) $(EXTRASRCS:%=%.sml) 
SIGO	= $(MOSSRCS:%=%.ui) $(SRCS:%=%.ui)
SMLO	= $(MOSBSRCS:%=%.uo) $(BSRCS:%=%.uo) $(EXTRASRCS:%=%.uo) 

ifeq ($(LOCATION),flat)
MOSMLHOME  = /tmp/mosml
else
MOSMLHOME  = /home/gcla/mosml
endif
MOSMLTOOLS = camlrunm $(MOSMLHOME)/tools

BCGFILES = linbcg nrutil dsprsax asolve \
           atimes snrm dsprstx pwbin timer \
           utilisation new_util throughput probabliest \
           sprsin pwbsolve

BASEDIR = $(shell pwd)/..

include $(BASEDIR)/Makefile.config

.SUFFIXES :
.SUFFIXES : .sml .sig .ui .uo .mlp .lex .c .o


all: pwb.$(ARCH) process_var.$(ARCH) pwbsolve.$(ARCH)

#pwb.$(ARCH) : $(SMLO)
#pwb.$(ARCH) : 
#	echo "disabled."
#	mosmlc -o pwb.out $(LNKOBJS:%=%.uo) $(SMLO) 
#	cat `which camlrunm` pwb.out > $@
#	chmod 755 $@

pwb.$(ARCH) nj : $(shell echo *.sig *.sml *.lex *.grm)
	echo "CM.make(); SMLofNJ.exportFn(\"njpwb\",njpwb.main);" | $(ML)
	-mv njpwb.x86-linux njpwb.$(ARCH)
	-mv njpwb.sparc-solaris njpwb.$(ARCH)
	heap2exec.$(ARCH) ./run.$(ARCH) ./njpwb.$(ARCH) njpwb
	-ln -sf njpwb pwb.$(ARCH)
	chmod 755 njpwb

process_var.$(ARCH): process_var.o
	gcc $< -lm -o $@

pwbsolve.$(ARCH): $(BCGFILES:%=%.o)
	gcc $(BCGFILES:%=%.o) -lm -o $@

process_var.o : process_var.c
	gcc -c $<

#%.o : %.c
#	gcc -c $<

.c.o:
	gcc -c $<


#pwb : mosmlpwb.sml $(SIGO) $(SMLO)
#	mosmlc -o pwb.out $(LNKOBJS:%=%.uo) $(SMLO) 
#	cat `which camlrunm` pwb.out > pwb
#	chmod 755 pwb

.sig.ui:
	mosmlc -c $<

.sml.uo:
	mosmlc -c $<

.lex.sml:
	mosmllex $<


#%.ui : %.sig
#	mosmlc -c $<

#mosmlpwb.uo : mosmlpwb.sml
#	mosmlc -c $<

#sources.cm : Makefile
#	d

#%.uo : %.sml %.ui
#%.uo : %.sml
#	mosmlc -c $<

PepaParser.sml PepaParser.sig: PepaParser.grm
	mosmlyac PepaParser.grm

#PepaLexer.sml: PepaLexer.lex
#	mosmllex PepaLexer.lex


depend:
	rm -f Makefile.bak
	mv Makefile Makefile.bak
	$(MOSMLTOOLS)/cutdeps < Makefile.bak > Makefile
	$(MOSMLTOOLS)/mosmldep >> Makefile

# A makefile for the PEPA Workbench
oldall:
	mosmlc -c Error.sig
	mosmlc -c Error.sml
	mosmlc -c Options.sig
	mosmlc -c Options.sml
	mosmlc -c HashTable.sig
	mosmlc -c HashTable.sml
	mosmlc -c Files.sig
	mosmlc -c Files.sml
	mosmlc -c Pepa.sig
	mosmlc -c Pepa.sml
	mosmlc -c Lexer.sig
	mosmlc -c Lexer.sml
	mosmlc -c Sort.sig
	mosmlc -c Sort.sml
	mosmlc -c Parser.sig
	mosmlc -c Parser.sml
	mosmlc -c Semantic.sig
	mosmlc -c Semantic.sml
	mosmlc -c Prettyprinter.sig
	mosmlc -c Prettyprinter.sml
	mosmlc -c Table.sig
	mosmlc -c Table.sml
	mosmlc -c Statespace.sig
	mosmlc -c Statespace.sml
	mosmlc -c Derivatives.sig
	mosmlc -c Derivatives.sml
	mosmlc -c Graph.sig
	mosmlc -c Graph.sml
	mosmlc -c PWB.sig
	mosmlc -c PWB.sml
	mosmlc -o pwb mosmlpwb.sml

clean:	
	-rm *.ui *.uo
	-rm PepaParser.sig PepaParser.sml
	-rm PepaParser.grm.sig PepaParser.grm.sml PepaParser.grm.desc
	-rm PepaParser.output
	-rm PepaLexer.sml PepaLexer.lex.sml
	-rm A.var A.size test.maple test.hash test.table
	-rm pwb pwb.out pwb.linux-x86 pwb.sun4-51
	-rm njpwb njpwb.linux-x86 njpwb.sun4-51
	-rm CM/x86-unix/*.bin
	-rm CM/sparc-unix/*.bin
	-rm Makefile.bak
	-rm *.o
	-rm process_var.linux-x86 process_var.sun4-51
	-rm pwbsolve.linux-x86 pwbsolve.sun4-51


### DO NOT DELETE THIS LINE
Getopt.uo: Getopt.ui 
PepaParser.ui: Pepa.ui 
PepaParser.uo: PepaParser.ui HashTable.ui Identifiers.ui Pepa.ui \
    Expressions.ui 
pwb.uo: PWB.uo CommandLine.ui Error.ui 
mosmlpwb.uo: PWB.uo 
Test.uo: Semantic.ui Files.ui 
Table.uo: Error.ui Files.ui Prettyprinter.ui 
Statespace.uo: HashTable.ui Options.ui Error.ui Files.ui Prettyprinter.ui \
    Table.uo Expressions.ui 
Sort.uo: Sort.ui 
Semantic.uo: Semantic.ui Sort.ui HashTable.ui Error.ui Pepa.ui 
Semantic.ui: Pepa.ui 
Prettyprinter.uo: Prettyprinter.ui HashTable.ui Pepa.ui Expressions.ui 
Prettyprinter.ui: Pepa.ui 
Pepa.uo: Pepa.ui HashTable.ui Expressions.ui 
Pepa.ui: HashTable.ui Expressions.ui 
PWB.uo: CommandLine.ui Statespace.uo Min.uo Graph.uo Semantic.ui \
    HashTable.ui Options.ui Error.ui Identifiers.ui Files.ui PepaParser.ui \
    Prettyprinter.ui Table.uo Expressions.ui 
Options.uo: Options.ui 
Min.uo: HashTable.ui Pepa.ui Prettyprinter.ui Expressions.ui 
Main.uo: Main.ui CommandLine.ui 
Identifiers.uo: Identifiers.ui HashTable.ui Pepa.ui Prettyprinter.ui \
    Expressions.ui 
Identifiers.ui: Pepa.ui Expressions.ui 
HashTable.uo: HashTable.ui Options.ui Error.ui 
Graph.uo: Statespace.uo HashTable.ui Error.ui Derivatives.ui Pepa.ui \
    Table.uo 
Files.uo: Files.ui Options.ui Error.ui 
Expressions.uo: Expressions.ui 
Error.uo: Error.ui 
Derivatives.uo: Derivatives.ui Min.uo HashTable.ui Error.ui Pepa.ui \
    Prettyprinter.ui Expressions.ui 
Derivatives.ui: Pepa.ui Expressions.ui 
CommandLine.uo: CommandLine.ui 
