# Generated automatically from Makefile.in by configure.
#
# $Id: Makefile,v 1.7 1999/12/06 17:10:15 lindig Exp $
# 
# Targets
#
# all		bytecode binaries (default)
# all.opt	native code binaries
# clean		removes intermediate files
# realclean	removes additionally binaries and libraries
# depend	updates dependencies
# doc		create XML files from MLI files

SHELL =		/bin/sh

# -----------------------------------------------------------------------------
# Name and version for binaries and tar files
# -----------------------------------------------------------------------------

NAME =		mylib

# -----------------------------------------------------------------------------
# default target
# -----------------------------------------------------------------------------

all::		ALWAYS

# -----------------------------------------------------------------------------
# All paths and system dependent settings are defined in config
# -----------------------------------------------------------------------------

include config

# -----------------------------------------------------------------------------
# compilation rules
# -----------------------------------------------------------------------------

.SUFFIXES:
.SUFFIXES:	.ml .mli .cmo .cmi .cmx .mll .mly .sig

.mli.cmi:
		$(CAMLC) $(CFLAGS) -c $<
.ml.cmo:
		$(CAMLC) $(CFLAGS) -c $<
.ml.cmx:	
		$(CAMLOPT) $(OFLAGS) -c $<

.mll.ml:
		$(CAMLLEX) $<
.mly.mli:	
		$(CAMLYACC) -v $<
.mly.ml:	
		$(CAMLYACC) -v $<

# infer signature of a module - can be used to create interface .mli

.ml.sig:
		$(CAMLC) $(CFLAGS) -c -i $< > $@ || rm -f $@

# -----------------------------------------------------------------------------
# Compiler flags
# -----------------------------------------------------------------------------

INCLUDE =
CFLAGS = 	$(INCLUDE) -g 
OFLAGS = 	$(INCLUDE) -unsafe -noassert
OFLAGS = 	$(INCLUDE) -verbose
OFLAGS = 	$(INCLUDE)


# -----------------------------------------------------------------------------
# default target
# -----------------------------------------------------------------------------

all::           mylib.cma 
all.opt::	mylib.cmxa

realclean::	clean

# -----------------------------------------------------------------------------
# File generated by some tool 
# -----------------------------------------------------------------------------

GENERATED =	rc_scan.ml rc_parse.ml rc_parse.mli

realclean::;	rm -f $(GENERATED)

# -----------------------------------------------------------------------------
# important file sets 
# -----------------------------------------------------------------------------


ML =            pp.ml		\
		pc.ml		\
		lc.ml		\
		pc2.ml		\
		std.ml		\
		rc_ast.ml	\
		rc_scan.ml	\
		rc_parse.ml	\
		rc.ml		\
		rx.ml

CMO =           $(ML:.ml=.cmo)
CMX =           $(ML:.ml=.cmx)
CMI =           $(ML:.ml=.cmi)
OBJ =           $(ML:.ml=.o)

clean::;     	rm -f $(CMO) $(CMX) $(OBJ) $(CMI) 

# -----------------------------------------------------------------------------
# build the library
# -----------------------------------------------------------------------------

LIBCMO =        $(CMO)
LIBCMX =        $(CMX)

mylib.cma:	$(LIBCMO)
		$(CAMLC) $(CFLAGS) -a -o $@ $(LIBCMO)

mylib.cmxa:	$(LIBCMX)
		$(CAMLOPT) $(OFLAGS) -a -o $@ $(LIBCMX)

realclean::;	rm -f mylib.cma mylib.cmxa mylib.a

# -----------------------------------------------------------------------------
# generate XML documentation from the MLI files
# -----------------------------------------------------------------------------

.SUFFIXES:	.xml

.mli.xml:	
		ocmarkup -xml -title "$<" $< > $@

XML =           pp.xml		\
		pc.xml		\
		lc.xml		\
		pc2.xml		\
		std.xml		\
		rc_ast.xml	\
		rc.xml

doc::		$(XML)

clean::;	rm -f $(XML)

# -----------------------------------------------------------------------------
# autoconf 
# -----------------------------------------------------------------------------

clean::;	rm -f config.log config.status config.cache
realclean::;	rm -f configure

# -----------------------------------------------------------------------------
# update version
# -----------------------------------------------------------------------------

version:
		etc/shtool version -n $(NAME) VERSION

# -----------------------------------------------------------------------------
# build a source distribution
# -----------------------------------------------------------------------------

DIST =          $(NAME)-$(VERSION).tar.gz

dist:           $(DIST)

$(DIST):	FILES
		ln -s . $(NAME)-$(VERSION) 
		tar cvf - `cat FILES` | gzip > $@
		rm -f $(NAME)-$(VERSION)
		rm -f FILES 

FILES:	        ALWAYS
		find .							\
			   -name 'config.in'			-print	\
			   						\
			-o -path '*/CVS/*' 			-prune	\
			-o -name 'config.*'			-prune	\
			-o -name '*.o' 				-prune	\
			-o -name '*.cmi' 			-prune	\
			-o -name '*.cmo'			-prune 	\
			-o -name '*.cma'			-prune 	\
			-o -name '*.html'			-prune 	\
			-o -name '*.xml'			-prune  \
			-o -name '*.cmxa'			-prune 	\
			-o -name '*.cmx'			-prune  \
			-o -name '*.tar*'			-prune  \
			-o -name '*.tmp*'			-prune  \
                        -o -name 'FILES'                        -prune  \
			-o -type f -print | sort | 			\
		sed 	-e 's|^\./|$(NAME)-$(VERSION)/|'  > $@

WWW =		$(HOME)/www/lindig/software

www:		$(DIST)
		cp $(DIST) $(WWW)/download

 
# -----------------------------------------------------------------------------
# misc
# -----------------------------------------------------------------------------


# dummy target 

ALWAYS:


# recalculate dependencies
# make sure that generators are run first

depend:		$(GENERATED)
		$(CAMLDEP) *.mli *.ml > DEPEND


# include dependencies

-include DEPEND

