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