Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / re2 / Makefile
blob4ded8ec00d7f033e0fa93845c532978fc41fe0fc
1 # Copyright 2009 The RE2 Authors. All Rights Reserved.
2 # Use of this source code is governed by a BSD-style
3 # license that can be found in the LICENSE file.
5 all: obj/libre2.a obj/so/libre2.so
7 # to build against PCRE for testing or benchmarking,
8 # uncomment the next two lines
9 # CCPCRE=-I/usr/local/include -DUSEPCRE
10 # LDPCRE=-L/usr/local/lib -lpcre
12 CXX=g++
13 CXXFLAGS=-Wall -O3 -g -pthread # can override
14 RE2_CXXFLAGS=-Wno-sign-compare -c -I. $(CCPCRE) # required
15 LDFLAGS=-pthread
16 AR=ar
17 ARFLAGS=rsc
18 NM=nm
19 NMFLAGS=-p
21 # Variables mandated by GNU, the arbiter of all good taste on the internet.
22 # http://www.gnu.org/prep/standards/standards.html
23 prefix=/usr/local
24 exec_prefix=$(prefix)
25 bindir=$(exec_prefix)/bin
26 includedir=$(prefix)/include
27 libdir=$(exec_prefix)/lib
28 INSTALL=install
29 INSTALL_PROGRAM=$(INSTALL)
30 INSTALL_DATA=$(INSTALL) -m 644
32 # ABI version
33 # http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
34 SONAME=0
36 # To rebuild the Tables generated by Perl and Python scripts (requires Internet
37 # access for Unicode data), uncomment the following line:
38 # REBUILD_TABLES=1
40 ifeq ($(shell uname),Darwin)
41 MAKE_SHARED_LIBRARY=$(CXX) -dynamiclib $(LDFLAGS) -exported_symbols_list libre2.symbols.darwin
42 else
43 MAKE_SHARED_LIBRARY=$(CXX) -shared -Wl,-soname,libre2.so.$(SONAME),--version-script=libre2.symbols $(LDFLAGS)
44 endif
46 INSTALL_HFILES=\
47 re2/filtered_re2.h\
48 re2/re2.h\
49 re2/set.h\
50 re2/stringpiece.h\
51 re2/variadic_function.h\
53 HFILES=\
54 util/arena.h\
55 util/atomicops.h\
56 util/benchmark.h\
57 util/flags.h\
58 util/logging.h\
59 util/mutex.h\
60 util/pcre.h\
61 util/random.h\
62 util/sparse_array.h\
63 util/sparse_set.h\
64 util/test.h\
65 util/utf.h\
66 util/util.h\
67 util/valgrind.h\
68 re2/filtered_re2.h\
69 re2/prefilter.h\
70 re2/prefilter_tree.h\
71 re2/prog.h\
72 re2/re2.h\
73 re2/regexp.h\
74 re2/set.h\
75 re2/stringpiece.h\
76 re2/testing/exhaustive_tester.h\
77 re2/testing/regexp_generator.h\
78 re2/testing/string_generator.h\
79 re2/testing/tester.h\
80 re2/unicode_casefold.h\
81 re2/unicode_groups.h\
82 re2/variadic_function.h\
83 re2/walker-inl.h\
85 OFILES=\
86 obj/util/arena.o\
87 obj/util/hash.o\
88 obj/util/rune.o\
89 obj/util/stringpiece.o\
90 obj/util/stringprintf.o\
91 obj/util/strutil.o\
92 obj/util/valgrind.o\
93 obj/re2/bitstate.o\
94 obj/re2/compile.o\
95 obj/re2/dfa.o\
96 obj/re2/filtered_re2.o\
97 obj/re2/mimics_pcre.o\
98 obj/re2/nfa.o\
99 obj/re2/onepass.o\
100 obj/re2/parse.o\
101 obj/re2/perl_groups.o\
102 obj/re2/prefilter.o\
103 obj/re2/prefilter_tree.o\
104 obj/re2/prog.o\
105 obj/re2/re2.o\
106 obj/re2/regexp.o\
107 obj/re2/set.o\
108 obj/re2/simplify.o\
109 obj/re2/tostring.o\
110 obj/re2/unicode_casefold.o\
111 obj/re2/unicode_groups.o\
113 TESTOFILES=\
114 obj/util/pcre.o\
115 obj/util/random.o\
116 obj/util/thread.o\
117 obj/re2/testing/backtrack.o\
118 obj/re2/testing/dump.o\
119 obj/re2/testing/exhaustive_tester.o\
120 obj/re2/testing/null_walker.o\
121 obj/re2/testing/regexp_generator.o\
122 obj/re2/testing/string_generator.o\
123 obj/re2/testing/tester.o\
125 TESTS=\
126 obj/test/charclass_test\
127 obj/test/compile_test\
128 obj/test/filtered_re2_test\
129 obj/test/mimics_pcre_test\
130 obj/test/parse_test\
131 obj/test/possible_match_test\
132 obj/test/re2_test\
133 obj/test/re2_arg_test\
134 obj/test/regexp_test\
135 obj/test/required_prefix_test\
136 obj/test/search_test\
137 obj/test/set_test\
138 obj/test/simplify_test\
139 obj/test/string_generator_test\
141 BIGTESTS=\
142 obj/test/dfa_test\
143 obj/test/exhaustive1_test\
144 obj/test/exhaustive2_test\
145 obj/test/exhaustive3_test\
146 obj/test/exhaustive_test\
147 obj/test/random_test\
149 SOFILES=$(patsubst obj/%,obj/so/%,$(OFILES))
150 STESTOFILES=$(patsubst obj/%,obj/so/%,$(TESTOFILES))
151 STESTS=$(patsubst obj/%,obj/so/%,$(TESTS))
152 SBIGTESTS=$(patsubst obj/%,obj/so/%,$(BIGTESTS))
154 DOFILES=$(patsubst obj/%,obj/dbg/%,$(OFILES))
155 DTESTOFILES=$(patsubst obj/%,obj/dbg/%,$(TESTOFILES))
156 DTESTS=$(patsubst obj/%,obj/dbg/%,$(TESTS))
157 DBIGTESTS=$(patsubst obj/%,obj/dbg/%,$(BIGTESTS))
159 obj/%.o: %.cc $(HFILES)
160 @mkdir -p $$(dirname $@)
161 $(CXX) -o $@ $(CPPFLAGS) $(CXXFLAGS) $(RE2_CXXFLAGS) -DNDEBUG $*.cc
163 obj/dbg/%.o: %.cc $(HFILES)
164 @mkdir -p $$(dirname $@)
165 $(CXX) -o $@ -fPIC $(CPPFLAGS) $(CXXFLAGS) $(RE2_CXXFLAGS) $*.cc
167 obj/so/%.o: %.cc $(HFILES)
168 @mkdir -p $$(dirname $@)
169 $(CXX) -o $@ -fPIC $(CPPFLAGS) $(CXXFLAGS) $(RE2_CXXFLAGS) -DNDEBUG $*.cc
171 obj/libre2.a: $(OFILES)
172 @mkdir -p obj
173 $(AR) $(ARFLAGS) obj/libre2.a $(OFILES)
175 obj/dbg/libre2.a: $(DOFILES)
176 @mkdir -p obj/dbg
177 $(AR) $(ARFLAGS) obj/dbg/libre2.a $(DOFILES)
179 obj/so/libre2.so: $(SOFILES)
180 @mkdir -p obj/so
181 $(MAKE_SHARED_LIBRARY) -o $@.$(SONAME) $(SOFILES)
182 ln -sf libre2.so.$(SONAME) $@
184 obj/test/%: obj/libre2.a obj/re2/testing/%.o $(TESTOFILES) obj/util/test.o
185 @mkdir -p obj/test
186 $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) obj/util/test.o obj/libre2.a $(LDFLAGS) $(LDPCRE)
188 obj/dbg/test/%: obj/dbg/libre2.a obj/dbg/re2/testing/%.o $(DTESTOFILES) obj/dbg/util/test.o
189 @mkdir -p obj/dbg/test
190 $(CXX) -o $@ obj/dbg/re2/testing/$*.o $(DTESTOFILES) obj/dbg/util/test.o obj/dbg/libre2.a $(LDFLAGS) $(LDPCRE)
192 obj/so/test/%: obj/so/libre2.so obj/libre2.a obj/so/re2/testing/%.o $(STESTOFILES) obj/so/util/test.o
193 @mkdir -p obj/so/test
194 $(CXX) -o $@ obj/so/re2/testing/$*.o $(STESTOFILES) obj/so/util/test.o -Lobj/so -lre2 obj/libre2.a $(LDFLAGS) $(LDPCRE)
196 obj/test/regexp_benchmark: obj/libre2.a obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/util/benchmark.o
197 @mkdir -p obj/test
198 $(CXX) -o $@ obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/util/benchmark.o obj/libre2.a $(LDFLAGS) $(LDPCRE)
200 ifdef REBUILD_TABLES
201 re2/perl_groups.cc: re2/make_perl_groups.pl
202 perl $< > $@
204 re2/unicode_%.cc: re2/make_unicode_%.py
205 python $< > $@
206 endif
208 distclean: clean
209 rm -f re2/perl_groups.cc re2/unicode_casefold.cc re2/unicode_groups.cc
211 clean:
212 rm -rf obj
213 rm -f re2/*.pyc
215 testofiles: $(TESTOFILES)
217 test: $(DTESTS) $(TESTS) $(STESTS) debug-test static-test shared-test
219 debug-test: $(DTESTS)
220 @echo
221 @echo Running debug binary tests.
222 @echo
223 @./runtests $(DTESTS)
225 static-test: $(TESTS)
226 @echo
227 @echo Running static binary tests.
228 @echo
229 @./runtests $(TESTS)
231 shared-test: $(STESTS)
232 @echo
233 @echo Running dynamic binary tests.
234 @echo
235 @LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS)
237 debug-bigtest: $(DTESTS) $(DBIGTESTS)
238 @./runtests $(DTESTS) $(DBIGTESTS)
240 static-bigtest: $(TESTS) $(BIGTESTS)
241 @./runtests $(TESTS) $(BIGTESTS)
243 shared-bigtest: $(STESTS) $(SBIGTESTS)
244 @LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS) $(SBIGTESTS)
246 benchmark: obj/test/regexp_benchmark
248 install: obj/libre2.a obj/so/libre2.so
249 mkdir -p $(DESTDIR)$(includedir)/re2 $(DESTDIR)$(libdir)
250 $(INSTALL_DATA) $(INSTALL_HFILES) $(DESTDIR)$(includedir)/re2
251 $(INSTALL) obj/libre2.a $(DESTDIR)$(libdir)/libre2.a
252 $(INSTALL) obj/so/libre2.so $(DESTDIR)$(libdir)/libre2.so.$(SONAME).0.0
253 ln -sf libre2.so.$(SONAME).0.0 $(DESTDIR)$(libdir)/libre2.so.$(SONAME)
254 ln -sf libre2.so.$(SONAME).0.0 $(DESTDIR)$(libdir)/libre2.so
256 testinstall:
257 @mkdir -p obj
258 cp testinstall.cc obj
259 (cd obj && $(CXX) -I$(DESTDIR)$(includedir) -L$(DESTDIR)$(libdir) testinstall.cc -lre2 -pthread -o testinstall)
260 LD_LIBRARY_PATH=$(DESTDIR)$(libdir) obj/testinstall
262 benchlog: obj/test/regexp_benchmark
263 (echo '==BENCHMARK==' `hostname` `date`; \
264 (uname -a; $(CXX) --version; hg identify; file obj/test/regexp_benchmark) | sed 's/^/# /'; \
265 echo; \
266 ./obj/test/regexp_benchmark 'PCRE|RE2') | tee -a benchlog.$$(hostname | sed 's/\..*//')
268 # Keep gmake from deleting intermediate files it creates.
269 # This makes repeated builds faster and preserves debug info on OS X.
271 .PRECIOUS: obj/%.o obj/dbg/%.o obj/so/%.o obj/libre2.a \
272 obj/dbg/libre2.a obj/so/libre2.a \
273 obj/test/% obj/so/test/% obj/dbg/test/%
275 log:
276 make clean
277 make CXXFLAGS="$(CXXFLAGS) -DLOGGING=1" obj/test/exhaustive{,1,2,3}_test
278 echo '#' RE2 exhaustive tests built by make log >re2-exhaustive.txt
279 echo '#' $$(date) >>re2-exhaustive.txt
280 obj/test/exhaustive_test |grep -v '^PASS$$' >>re2-exhaustive.txt
281 obj/test/exhaustive1_test |grep -v '^PASS$$' >>re2-exhaustive.txt
282 obj/test/exhaustive2_test |grep -v '^PASS$$' >>re2-exhaustive.txt
283 obj/test/exhaustive3_test |grep -v '^PASS$$' >>re2-exhaustive.txt
285 make CXXFLAGS="$(CXXFLAGS) -DLOGGING=1" obj/test/search_test
286 echo '#' RE2 basic search tests built by make $@ >re2-search.txt
287 echo '#' $$(date) >>re2-search.txt
288 obj/test/search_test |grep -v '^PASS$$' >>re2-search.txt