Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 177 lines (122 sloc) 3.609 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
# vim:ts=8 sw=4 noet:
#

TOP := ..
include $(TOP)/config.mk

PATH := $(PATH):$(TOP)/tools

INCLUDES := -I .
OCAMLC_FLAGS := -g -dtypes $(INCLUDES)
OCAMLOPT_FLAGS := -p -dtypes $(INCLUDES)
OCAMLOPT_FLAGS := -dtypes $(INCLUDES)

BINDIR := $(PREFIX)/bin
MAN1DIR := $(PREFIX)/man/man1

# -- high-level targets
.PHONY: all doc clean pdf test install clobber

all: load.ml $(NAME).$(BINEXT)

clean:
rm -f *.cmx *.cmo *.cmi *.o *.ml *.mli quest.opt quest.byte
rm -f *.log *.pdf *.aux *.inc *.tex *.out
rm -f *.mll *.mly
rm -f DEPEND
rm -f load.ml *.annot
rm -f pod2*
rm -f test.out

clobber: clean
rm -f $(NAME).byte $(NAME).opt
rm -f $(NAME).1
rm -f config.mk

install: $(NAME).$(BINEXT) $(NAME).1 $(BINDIR) $(MAN1DIR)
cp $(NAME).$(BINEXT) $(BINDIR)/$(NAME)
cp $(NAME).1 $(MAN1DIR)


test: test.annot test.in
rm -f test.out
while read LINE COL; do \
./$(NAME).$(BINEXT) -type $$LINE $$COL test.annot >> test.out;\
done < test.in
diff test.ref test.out

$(BINDIR):
mkdir -p $@

$(MAN1DIR):
mkdir -p $@


# -- important files

ML := \
intervalmap.ml \
annot.ml \
parser.ml \
scanner.ml \
main.ml \


MLI := $(patsubst %.ml, %.mli, $(ML))
CMO := $(patsubst %.ml, %.cmo, $(ML))
CMX := $(patsubst %.ml, %.cmx, $(ML))
OBJ := $(patsubst %.ml, %.o , $(ML))

TEX := annot.tex intervalmap.tex main.tex \
position.tex syntax.tex
INC := $(patsubst %.tex, %.inc, $(TEX))
PDF := $(patsubst %.tex, %.pdf, $(TEX))

# --

cmo: $(CMO)
cmi: $(CMI)
obj: $(OBJ)

# --

LIBCMO :=
LIBCMX :=

# -- binaries

$(NAME).byte: $(CMO) $(LIBCMO)
$(OCAMLC) $(OCAMLC_FLAGS) -o $@ $(LIBCMO) $(CMO)

$(NAME).opt: $(CMX) $(LIBCMX)
$(OCAMLOPT) $(OCAMLOPT_FLAGS) -o $@ $(LIBCMX) $(CMX)

# -- debugging support

load.ml: $(CMO)
echo $(CMO) | tr ' ' \\012 | sed 's/^.*$$/#load "&";;/' > $@

# -- rules

%.ml: %.nw
$(NOTANGLE) '-L# %L "%F"%N' -R$@ $< > $@

%.mli: %.nw
$(NOTANGLE) '-L# %L "%F"%N' -R$@ $< > $@

%.sig: %.ml
$(OCAMLC) $(OCAMLC_FLAGS) -c -i $< > $@

%.cmo: %.ml
$(OCAMLC) $(OCAMLC_FLAGS) -c $<

%.cmx: %.ml
$(OCAMLOPT) $(OCAMLOPT_FLAGS) -c $<

%.cmi: %.mli
$(OCAMLC) $(OCAMLC_FLAGS) -c $<

%.mli %.ml: %.mly
$(OCAMLYACC) $<

%.ml: %.mll
$(OCAMLLEX) $<

# -- manual page

%.1: %.pod
$(POD2MAN) $< > $@


# -- special rules

scanner.mli: syntax.nw
$(NOTANGLE) '-L# %L "%F"%N' -R$@ $< > $@

scanner.mll: syntax.nw
$(NOTANGLE) '-L# %L "%F"%N' -R$@ $< > $@

parser.mly: syntax.nw
$(NOTANGLE) '-L# %L "%F"%N' -R$@ $< > $@

# -- documentation

RERUN = Rerun (LaTeX|to get cross-references right)

pdf: $(PDF)

%.pdf: %.tex
$(PDFLATEX) $<
if egrep -s '$(RERUN)' $*.log ;then $(PDFLATEX) $<; fi
if egrep -s '$(RERUN)' $*.log ;then $(PDFLATEX) $<; fi

%.inc: %.nw
$(NOWEAVE) -delay $< > $@

%.tex: %.inc
echo " \documentclass[11pt]{article} " > $@
echo " \usepackage{a4wide} " >> $@
echo " \usepackage{hyperref} " >> $@
echo " \usepackage{noweb} " >> $@
echo " \noweboptions{breakcode} " >> $@
echo " \begin{document} " >> $@
echo " \input{$<} " >> $@
echo " \end{document} " >> $@

# -- configure

$(TOP)/config.mk:
echo "Have you run ./configure?"
exit 1

# -- dependencies

DEPEND: $(ML) $(MLI)
$(OCAMLDEP) $(INCLUDES) $(ML) $(MLI) > DEPEND

include DEPEND
Something went wrong with that request. Please try again.