Include package batteries in makefile for Ocaml

317 views Asked by At

I would like to use functions of module List of Ocaml Batteries. I have installed Batteries, and a trivial code from Getting started works with ocamlfind ocamlc -package batteries -linkpkg euler001.ml -o euler001.

Now coming back to my project, I have a makefile as follows:

CMO=sib_lexer.cmo sib_parser.cmo sib_pp.cmo lattices.cmo abstract_interpreter.cmo main.cmo
GENERATED = sib_lexer.ml sib_parser.ml sib_parser.mli
BIN=Simpler-Basic
FLAGS= -g -annot

all: $(BIN)
    export OCAMLRUNPARAM=b
    ./$(BIN) test.sib -a zone

$(BIN):$(CMO)
    ocamlc $(FLAGS) -o $(BIN) graphics.cma $(CMO)

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

.mli.cmi:
    ocamlc $(FLAGS) -c $<

.ml.cmo:
    ocamlc $(FLAGS) -c $<

.mll.ml:
    ocamllex $<

.mly.ml:
    menhir -v $<

.mly.mli:
    ocamlyacc -v $<

clean:
    rm -f *.cm[io] *.o *~ $(BIN) $(GENERATED) sib_parser.output

.depend depend:$(GENERATED)
    rm -f .depend #3
    ocamldep *.ml *.mli > .depend #4

include .depend

I tried to replace all ocamlc $(FLAGS) with ocamlfind ocamlc -package batteries -linkpkg $(FLAGS), but it did not work...

Could anyone tell me how to modify the makefile so that it complies with batteries?

1

There are 1 answers

0
Stéphane Glondu On

Changing the compilation command is not enough. You need to add e.g. open Batteries_uni at the beginning of the files where you want to use Batteries' List.