.
[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 = str,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 OCAMLFIND = ocamlfind
48 OCAMLMKLIB = ocamlmklib
49 OCAMLDEP = ocamldep
50 #Ugly but seems difficult with a makefile
51
52 LINK=$(OCAMLOPT) -linkpkg `ocamlc -version | grep -q "3.11.0" && echo dynlink.cmxa` camlp4lib.cmxa
53 SYNTAX= -syntax camlp4o $(PPINCLUDES) -ppopt pa_macro.cmo $(SYNT_PROF) 
54
55
56
57 LIBS=-lxml2 -lxml++-2.6 -lglibmm-2.4 -lgobject-2.0 -lglib-2.0 -lsigc-2.0 
58
59 all: version libcamlshredder.a  $(MLOBJS)
60
61         $(OCAMLFIND) $(LINK) -o main -package "$(OCAMLPACKAGES)" $(SYNTAX) -cclib \
62         "$(LIBS) ./libcamlshredder.a"  $(MLOBJS)
63
64 .SUFFIXES: .ml .mli .cmx .cmi .cpp
65 .PHONY:compute_depend version
66 .cpp.o:
67         $(CXX) $(CXXINCLUDES) -c $(CXXFLAGS)  $<
68 .ml.cmx:
69         $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
70 .mli.cmi:
71         $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
72
73 libcamlshredder.a: $(CXXOBJECTS) XMLTree/XMLTree.a
74         mkdir -p .libs/
75         cd .libs/ && ar x ../XMLTree/XMLTree.a
76         $(OCAMLMKLIB) -o camlshredder -custom $(CXXOBJECTS) ./.libs/*.o $(LIBS)
77         rm -rf .libs
78
79 clean:
80         rm -f *~ *.cm* *.[oa] *.so main .libs
81
82
83 testSuccint: $(CXXOBJECTS) XMLTree/XMLTree.a
84         mkdir -p .libs/
85         cd .libs/ && ar x ../XMLTree/XMLTree.a
86         $(CXX) -o testSuccint $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \
87 SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \
88 $(LIBS) testSuccint.cpp
89         rm -rf .libs
90
91 SXSIStorageInterface.o: SXSIStorageInterface.h SXSIStorageInterface.cpp StorageInterface.h
92 StorageInterface.o: StorageInterface.h
93 XMLDocShredder.o: XMLDocShredder.h XMLDocShredder.cpp OCamlStorageInterface.h StorageInterface.h
94 OCamlDriver.o: XMLDocShredder.h StorageInterface.h
95
96 compute_depend:
97         $(OCAMLFIND) $(OCAMLDEP) -package "$(OCAMLPACKAGES)" $(SYNTAX)  $(MLSRCS) $(MLISRCS) >depend
98
99
100
101 include depend