Merged from branch stable-succint-refactor
[SXSI/xpathcomp.git] / Makefile
1 DEBUG=false
2 PROFILE=true
3 VERBOSE=false
4
5 MLSRCS = memory.ml custom.ml ptset.ml finiteCofinite.ml tag.ml tagSet.ml options.ml tree.ml ata.ml ulexer.ml  xPath.ml main.ml
6 MLISRCS = memory.mli sigs.mli ptset.mli finiteCofinite.ml options.mli  tag.mli tagSet.mli tree.mli ata.mli ulexer.mli xPath.mli
7 MLOBJS = $(MLSRCS:.ml=.cmx)
8 MLCINT = $(MLISRCS:.mli=.cmi)
9
10
11 OCAMLPACKAGES = str,unix,ulex,camlp4
12
13 PPINCLUDES=$(OCAMLINCLUDES:%=-ppopt %)
14
15 CXXSOURCES =  XMLDocShredder.cpp SXSIStorageInterface.cpp StorageInterface.cpp OCamlDriver.cpp
16 CXXOBJECTS = $(CXXSOURCES:.cpp=.o)
17
18 CXXINCLUDES =   \
19         -I/usr/include/libxml++-2.6 \
20         -I/usr/include/libxml2 \
21         -I/usr/include/glibmm-2.4 \
22         -I/usr/include/glib-2.0 \
23         -I/usr/include/sigc++-2.0 \
24         -I/usr/lib/libxml++-2.6/include \
25         -I/usr/lib/glibmm-2.4/include \
26         -I/usr/lib/sigc++-2.0/include \
27         -I/usr/lib/glib-2.0/include\
28         -I`ocamlc -where`\
29         -IXMLTree \
30         -IXMLTree/libcds/includes \
31         -IXMLTree/TextCollection 
32
33 CXXFLAGS = -O3 -Wall $(INCLUDEDIRS) -fPIC
34 ifeq ($(VERBOSE),true)
35 HIDE=
36 else
37 HIDE=@
38 endif
39
40 ifeq ($(DEBUG), true)
41 CXX = g++ -DDEBUG
42 OCAMLOPT = ocamlopt -g -cc "$(CXX)" 
43 SYNT_DEBUG = -ppopt -DDEBUG
44 else
45 CXX = g++  
46 OCAMLOPT = ocamlopt -cc "$(CXX)" -ccopt -O3 -noassert -inline 100
47 endif
48 ifeq ($(PROFILE), true)
49 SYNT_PROF = $(SYNT_DEBUG) -ppopt -DPROFILE
50 endif
51
52 OCAMLFIND = ocamlfind
53 OCAMLMKLIB = ocamlmklib
54 OCAMLDEP = ocamldep
55 #Ugly but seems difficult with a makefile
56
57 LINK=$(OCAMLOPT) -linkpkg `ocamlc -version | grep -q "3.11.0" && echo dynlink.cmxa` camlp4lib.cmxa
58 SYNTAX= -syntax camlp4o $(PPINCLUDES) -ppopt pa_macro.cmo $(SYNT_PROF) 
59
60
61
62 LIBS=-lxml2 -lxml++-2.6 -lglibmm-2.4 -lgobject-2.0 -lglib-2.0 -lsigc-2.0 
63
64 all: main
65
66 main: libcamlshredder.a  $(MLOBJS)
67         @echo [LINK] $@
68         $(HIDE) $(OCAMLFIND) $(LINK) -o main -package "$(OCAMLPACKAGES)" $(SYNTAX) -cclib \
69         "$(LIBS) ./libcamlshredder.a"  $(MLOBJS)
70
71 .SUFFIXES: .ml .mli .cmx .cmi .cpp
72 .PHONY:compute_depend version
73
74 .cpp.o:
75         @echo [CPP] $@
76         $(HIDE) $(CXX) $(CXXINCLUDES) -c $(CXXFLAGS)  $<
77 .ml.cmx:
78         @echo [OCAMLOPT] $@
79         $(HIDE) $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
80 .mli.cmi:
81         @echo [OCAMLOPT] $@
82         $(HIDE) $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
83
84 libcamlshredder.a: $(CXXOBJECTS) XMLTree/XMLTree.a
85         @echo [LIB] $@
86         $(HIDE) mkdir -p .libs/
87         $(HIDE) cd .libs/ && ar x ../XMLTree/XMLTree.a
88         $(HIDE) $(OCAMLMKLIB) -o camlshredder -custom $(CXXOBJECTS) ./.libs/*.o $(LIBS)
89         $(HIDE) rm -rf .libs
90
91 clean:
92         @echo [CLEAN]
93         $(HIDE) rm -f *~ *.cm* *.[oa] *.so main .libs
94
95
96 testSuccint: $(CXXOBJECTS) XMLTree/XMLTree.a
97         mkdir -p .libs/
98         cd .libs/ && ar x ../XMLTree/XMLTree.a
99         $(CXX) -o testSuccint $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \
100 SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \
101 $(LIBS) testSuccint.cpp
102         rm -rf .libs
103
104 SXSIStorageInterface.o: SXSIStorageInterface.h SXSIStorageInterface.cpp StorageInterface.h
105 StorageInterface.o: StorageInterface.h
106 XMLDocShredder.o: XMLDocShredder.h XMLDocShredder.cpp SXSIStorageInterface.h StorageInterface.h
107 OCamlDriver.o: XMLDocShredder.h StorageInterface.h
108
109 compute_depend:
110         @echo [DEP]
111         $(HIDE) $(OCAMLFIND) $(OCAMLDEP) -package "$(OCAMLPACKAGES)" $(SYNTAX)  $(MLSRCS) $(MLISRCS) >depend
112
113 include depend