Replaced OCamlBackend
[SXSI/xpathcomp.git] / Makefile
1 DEBUG=false
2 PROFILE=true
3
4 MLSRCS = memory.ml tag.ml tagSet.ml  tree.ml automaton.ml ulexer.ml  xPath.ml main.ml
5 MLISRCS = memory.mli automaton.mli  tag.mli tagSet.mli tree.mli ulexer.mli xPath.mli
6 MLOBJS = $(MLSRCS:.ml=.cmx)
7 MLCINT = $(MLISRCS:.mli=.cmi)
8
9
10 OCAMLPACKAGES = unix,ulex,camlp4
11
12 PPINCLUDES=$(OCAMLINCLUDES:%=-ppopt %)
13
14 CXXSOURCES =  XMLDocShredder.cpp SXSIStorageInterface.cpp StorageInterface.cpp OCamlDriver.cpp
15 CXXOBJECTS = $(CXXSOURCES:.cpp=.o)
16
17 CXXINCLUDES =   \
18         -I/usr/include/libxml++-2.6 \
19         -I/usr/include/libxml2 \
20         -I/usr/include/glibmm-2.4 \
21         -I/usr/include/glib-2.0 \
22         -I/usr/include/sigc++-2.0 \
23         -I/usr/lib/libxml++-2.6/include \
24         -I/usr/lib/glibmm-2.4/include \
25         -I/usr/lib/sigc++-2.0/include \
26         -I/usr/lib/glib-2.0/include\
27         -I`ocamlc -where`\
28         -IXMLTree \
29         -IXMLTree/libcds/includes \
30         -IXMLTree/TextCollection 
31
32 CXXFLAGS = -O3 -Wall $(INCLUDEDIRS) -fPIC -std=c++0x
33
34 ifeq ($(DEBUG), true)
35 CXX = g++ -DDEBUG
36 OCAMLOPT = ocamlopt -g -cc "$(CXX)" 
37 SYNT_DEBUG = -ppopt -DDEBUG
38 else
39 CXX = g++
40 OCAMLOPT = ocamlopt -cc "$(CXX)" -noassert -inline 10000
41 endif
42
43 ifeq ($(PROFILE), true)
44 SYNT_PROF = $(SYNT_DEBUG) -ppopt -DPROFILE
45 endif
46
47
48 OCAMLFIND = ocamlfind
49 OCAMLMKLIB = ocamlmklib
50 OCAMLDEP = ocamldep
51 LINK=$(OCAMLOPT) -linkpkg camlp4lib.cmxa
52 SYNTAX= -syntax camlp4o $(PPINCLUDES) -ppopt pa_macro.cmo $(SYNT_PROF) 
53
54
55
56 LIBS=-lxml2 -lxml++-2.6 -lglibmm-2.4 -lgobject-2.0 -lglib-2.0 -lsigc-2.0 
57
58 all: libcamlshredder.a  $(MLOBJS)
59         $(OCAMLFIND) $(LINK) -o main -package "$(OCAMLPACKAGES)" $(SYNTAX) -cclib \
60         "$(LIBS) ./libcamlshredder.a"  $(MLOBJS)
61
62 .SUFFIXES: .ml .mli .cmx .cmi .cpp
63 .PHONY:compute_depend
64
65 .cpp.o:
66         $(CXX) $(CXXINCLUDES) -c $(CXXFLAGS)  $<
67 .ml.cmx:
68         $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
69 .mli.cmi:
70         $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
71
72 libcamlshredder.a: $(CXXOBJECTS)
73         mkdir -p .libs/
74         cd .libs/ && ar x ../XMLTree/XMLTree.a
75         $(OCAMLMKLIB) -o camlshredder -custom $(CXXOBJECTS) ./.libs/*.o $(LIBS)
76         rm -rf .libs
77
78 clean:
79         rm -f *~ *.cm* *.[oa] *.so main .libs
80
81
82 SXSIStorageInterface.o: SXSIStorageInterface.h SXSIStorageInterface.cpp StorageInterface.h
83 StorageInterface.o: StorageInterface.h
84 XMLDocShredder.o: XMLDocShredder.h XMLDocShredder.cpp OCamlStorageInterface.h StorageInterface.h
85 OCamlDriver.o: XMLDocShredder.h StorageInterface.h
86
87 compute_depend:
88         $(OCAMLFIND) $(OCAMLDEP) -package "$(OCAMLPACKAGES)" $(SYNTAX)  $(MLSRCS) $(MLISRCS) >depend
89
90
91
92 include depend