Remove trailing white spaces
[SXSI/xpathcomp.git] / Makefile
1 INLINE=100
2 DEBUG=false
3 PROFILE=false
4 VERBOSE=false
5
6 BASESRC=uid.ml custom.ml hcons.ml hlist.ml ptset.ml finiteCofinite.ml tag.ml tagSet.ml options.ml tree.ml ata.ml
7 BASEMLI=uid.mli sigs.mli hcons.mli hlist.mli ptset.mli finiteCofinite.mli tag.mli tagSet.mli options.mli tree.mli  ata.mli
8 MLSRCS = memory.ml $(BASESRC)   ulexer.ml  xPath.ml main.ml
9 MLISRCS = memory.mli $(BASEMLI)  ulexer.mli xPath.mli
10 BASEOBJS= $(BASESRC:.ml=.cmx)
11 BASEINT= $(BASEMLI:.ml=.cmi)
12 MLOBJS = $(MLSRCS:.ml=.cmx)
13 MLCINT = $(MLISRCS:.mli=.cmi)
14
15
16 OCAMLPACKAGES = str,unix,ulex,camlp4
17
18 PPINCLUDES=$(OCAMLINCLUDES:%=-ppopt %)
19
20 CXXSOURCES =  results.c XMLDocShredder.cpp  OCamlDriver.cpp
21 CXXOBJECTS1 = $(CXXSOURCES:.cpp=.o)
22 CXXOBJECTS = $(CXXOBJECTS1:.c=.o)
23
24 CAMLINCLUDES= -I`ocamlc -where`
25 LIBXMLINCLUDES=         \
26         -I/usr/include/libxml++-2.6 \
27         -I/usr/include/libxml2 \
28         -I/usr/include/glibmm-2.4 \
29         -I/usr/include/glib-2.0 \
30         -I/usr/include/sigc++-2.0 \
31         -I/usr/lib/libxml++-2.6/include \
32         -I/usr/lib/glibmm-2.4/include \
33         -I/usr/lib/sigc++-2.0/include \
34         -I/usr/lib/glib-2.0/include\
35
36 SXSIINCLUDES = \
37         -IXMLTree \
38         -IXMLTree/libcds/includes \
39         -IXMLTree/TextCollection 
40
41 CXXINCLUDES= $(CAMLINCLUDES) $(LIBXMLINCLUDES) $(SXSIINCLUDES)
42
43 CXXFLAGS = -O3 -Wall $(INCLUDEDIRS) -std=c++0x -static
44 CCFLAGS = -O3 -Wall  -static
45
46 ifeq ($(VERBOSE),true)
47 HIDE=
48 else
49 HIDE=@
50 endif
51
52 ifeq ($(DEBUG), true)
53 CXX = g++ -DDEBUG
54 CC = gcc -DDEBUG
55 DEBUG_FLAGS = -g
56 SYNT_DEBUG = -ppopt -DDEBUG
57 else
58 CXX = g++
59 CC = gcc -DDEBUG
60 endif
61
62 ifeq ($(PROFILE), true)
63 PROFILE_FLAGS = -p -S
64 SYNT_PROF = -ppopt -DPROFILE
65 endif
66 SYNT_FLAGS = $(SYNT_DEBUG) $(SYNT_PROF)
67 OPT_FLAGS = $(DEBUG_FLAGS) $(PROFILE_FLAGS) -nodynlink -fno-PIC
68
69 OCAMLOPT = ocamlopt -cc "$(CXX)" $(OPT_FLAGS) -ccopt -O3 -ccopt -std=c++0x -noassert -inline $(INLINE)
70
71
72 OCAMLFIND = ocamlfind
73 OCAMLMKLIB = ocamlmklib
74 OCAMLDEP = ocamldep
75 #Ugly but seems difficult with a makefile
76
77 LINK=$(OCAMLOPT) -linkpkg `ocamlc -version | grep -q "3.1[12].[012]" && echo dynlink.cmxa` camlp4lib.cmxa
78 SYNTAX= -syntax camlp4o $(PPINCLUDES) -ppopt pa_macro.cmo $(SYNT_FLAGS) 
79
80
81
82 LIBS=-lxml2 -lxml++-2.6 -lglibmm-2.4 -lgobject-2.0 -lglib-2.0 -lsigc-2.0 
83
84 all: main
85 #-ccopt -gp -p
86 main: libcamlshredder.a  $(MLOBJS)
87         @echo [LINK] $@
88         $(HIDE) $(OCAMLFIND) $(LINK) -o main -package "$(OCAMLPACKAGES)" $(SYNTAX) -cclib \
89         "$(LIBS) ./libcamlshredder.a"  $(MLOBJS)
90
91 sxsi_test: libcamlshredder.a uid.cmx custom.cmx hcons.cmx ptset.cmx finiteCofinite.cmx tag.cmx tagSet.cmx options.cmx tree.cmx
92         @echo [LINK] $@ 
93         $(HIDE) $(OCAMLFIND) $(LINK) -o sxsi_test -package "$(OCAMLPACKAGES)" $(SYNTAX) -cclib \
94         "$(LIBS) ./libcamlshredder.a"  uid.cmx custom.cmx hcons.cmx ptset.cmx finiteCofinite.cmx tag.cmx tagSet.cmx options.cmx tree.cmx sxsi_test.ml
95
96 unit_test: libcamlshredder.a  $(BASEOBJS) unit_test.cmx
97         @echo [LINK] $@ 
98         $(HIDE) $(OCAMLFIND) $(LINK) -o unit_test -package "$(OCAMLPACKAGES)" $(SYNTAX) -cclib \
99         "$(LIBS) ./libcamlshredder.a"  $(BASEOBJS) unit_test.cmx
100
101 .SUFFIXES: .ml .mli .cmx .cmi .cpp
102 .PHONY:compute_depend version
103
104 .c.o:
105         @echo [CC] $@
106         $(HIDE) $(CC) -c $(CCFLAGS) $<
107
108 .cpp.o:
109         @echo [CPP] $@
110         $(HIDE) $(CXX) $(CXXINCLUDES) -c $(CXXFLAGS)  $<
111
112 .ml.cmx:
113         @echo [OCAMLOPT] $@
114         $(HIDE) $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
115
116 # ata.cmx: ata.ml
117 #       @echo [OCAMLOPTPROF] $@
118 #       $(HIDE) $(OCAMLFIND) $(OCAMLOPT) -S -ccopt -gp -p -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
119
120
121 .mli.cmi:
122         @echo [OCAMLOPT] $@
123         $(HIDE) $(OCAMLFIND) $(OCAMLOPT) -package "$(OCAMLPACKAGES)"  $(SYNTAX) -c $<
124
125 libcamlshredder.a: $(CXXOBJECTS) XMLTree/XMLTree.a
126         @echo [LIB] $@
127         $(HIDE) mkdir -p .libs/
128         $(HIDE) cd .libs/ && ar x ../XMLTree/XMLTree.a
129         $(HIDE) $(OCAMLMKLIB) -o camlshredder -custom $(CXXOBJECTS) .libs/*.o $(LIBS)
130         $(HIDE) rm -rf .libs
131
132 clean:
133         @echo [CLEAN]
134         $(HIDE) rm -f *~ *.cm* *.[oa] *.so main *.s sxsi_test
135         $(HIDE) rm -rf .libs
136
137
138 timeXMLTree: $(CXXOBJECTS) XMLTree/XMLTree.a  timeXMLTree.cpp myTimeXMLTree.cpp
139         mkdir -p .libs/
140         cd .libs/ && ar x ../XMLTree/XMLTree.a
141         $(CXX) -o timeXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \
142         SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \
143         $(LIBS) timeXMLTree.cpp
144         $(CXX) -o myTimeXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \
145         SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \
146         $(LIBS) myTimeXMLTree.cpp
147 #       $(CXX) -o testXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \
148 #       SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \
149 #       $(LIBS) testXMLTree.cpp
150         rm -rf .libs
151
152 timeSXSI: $(CXXOBJECTS) XMLTree/XMLTree.a  timeSXSI.cpp
153         mkdir -p .libs/
154         cd .libs/ && ar x ../XMLTree/XMLTree.a
155         $(CXX) -o timeSXSI $(CXXFLAGS) $(SXSIINCLUDES) -I/usr/include/libxml2 -lxml2 ./.libs/*.o timeSXSI.cpp
156 #       $(CXX) -o testXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \
157 #       SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \
158 #       $(LIBS) testXMLTree.cpp
159         rm -rf .libs
160
161 XMLDocShredder.o: XMLDocShredder.h XMLDocShredder.cpp 
162 OCamlDriver.o: XMLDocShredder.h
163 results.o: results.h
164
165 compute_depend:
166         @echo [DEP]
167         $(HIDE) $(OCAMLFIND) $(OCAMLDEP) -package "$(OCAMLPACKAGES)" $(SYNTAX)  $(MLSRCS) $(MLISRCS) >depend
168
169 include depend