# Compilation options
CSLC=cslc
CSLOPT=cslopt
CSLDEP=csldep
INCLUDES=
CSLFLAGS=$(INCLUDES)
CSLOPTFLAGS=$(INCLUDES)

# The directory where the public executable will be installed
BINDIR=/usr/local/bin

# The manual section where the manual pages will be installed
MANEXT=1

# The directory where the manual pages will be installed
MANDIR=/usr/local/man/man$(MANEXT)

##### End of configuration section


# The commands for bytecode compilation

# The list of object files in bytecode format
SYNGEN_BYTE_OBJS=lexer.cmo parser.cmo picture.cmo boxes.cmo latexcode.cmo\
                 main.cmo

byte:   $(SYNGEN_BYTE_OBJS)
	$(CSLC) -o syngen $(CSLFLAGS) $(SYNGEN_BYTE_OBJS)


# The commands for native-code compilation

# The list of object files in native-code format
SYNGEN_NATIVE_OBJS=lexer.cmx parser.cmx picture.cmx boxes.cmx\
                   latexcode.cmx main.cmx

native: $(SYNGEN_NATIVE_OBJS)
	$(CSLOPT) -o syngen $(CSLOPTFLAGS) $(SYNGEN_NATIVE_OBJS)


# Common rules

.SUFFIXES: .ml .mli .cmo .cmi .cmx

.ml.cmo:
	$(CSLC) $(CSLFLAGS) -c $<

.mli.cmi:
	$(CSLC) $(CSLFLAGS) -c $<

.ml.cmx:
	$(CSLOPT) $(CSLOPTFLAGS) -c $<


# Clean up

clean:
	rm -f *.cm[iox] *.o *~


# Installation

install:
	cp syngen $(BINDIR)/syngen
	cp syngen.m $(MANDIR)/syngen.$(MANEXT)


# Dependencies

depend:
	$(CSLDEP) $(INCLUDES) *.mli *.ml > depend

include depend