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
13 CXXFLAGS
=-Wall
-O3
-g
-pthread
# can override
14 RE2_CXXFLAGS
=-Wno-sign-compare
-c
-I.
$(CCPCRE
) # required
21 # Variables mandated by GNU, the arbiter of all good taste on the internet.
22 # http://www.gnu.org/prep/standards/standards.html
25 bindir=$(exec_prefix)/bin
26 includedir=$(prefix)/include
27 libdir=$(exec_prefix)/lib
29 INSTALL_PROGRAM
=$(INSTALL
)
30 INSTALL_DATA
=$(INSTALL
) -m
644
33 # http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
36 # To rebuild the Tables generated by Perl and Python scripts (requires Internet
37 # access for Unicode data), uncomment the following line:
40 ifeq ($(shell uname
),Darwin
)
41 MAKE_SHARED_LIBRARY
=$(CXX
) -dynamiclib
$(LDFLAGS
) -exported_symbols_list libre2.symbols.darwin
43 MAKE_SHARED_LIBRARY
=$(CXX
) -shared
-Wl
,-soname
,libre2.so.
$(SONAME
),--version-script
=libre2.symbols
$(LDFLAGS
)
51 re2
/variadic_function.h\
76 re2
/testing
/exhaustive_tester.h\
77 re2
/testing
/regexp_generator.h\
78 re2
/testing
/string_generator.h\
80 re2
/unicode_casefold.h\
82 re2
/variadic_function.h\
89 obj
/util
/stringpiece.o\
90 obj
/util
/stringprintf.o\
96 obj
/re2
/filtered_re2.o\
97 obj
/re2
/mimics_pcre.o\
101 obj
/re2
/perl_groups.o\
103 obj
/re2
/prefilter_tree.o\
110 obj
/re2
/unicode_casefold.o\
111 obj
/re2
/unicode_groups.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\
126 obj
/test/charclass_test\
127 obj
/test/compile_test\
128 obj
/test/filtered_re2_test\
129 obj
/test/mimics_pcre_test\
131 obj
/test/possible_match_test\
133 obj
/test/re2_arg_test\
134 obj
/test/regexp_test\
135 obj
/test/required_prefix_test\
136 obj
/test/search_test\
138 obj
/test/simplify_test\
139 obj
/test/string_generator_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
)
173 $(AR
) $(ARFLAGS
) obj
/libre2.a
$(OFILES
)
175 obj
/dbg
/libre2.a
: $(DOFILES
)
177 $(AR
) $(ARFLAGS
) obj
/dbg
/libre2.a
$(DOFILES
)
179 obj
/so
/libre2.so
: $(SOFILES
)
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
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
198 $(CXX
) -o
$@ obj
/re2
/testing
/regexp_benchmark.o
$(TESTOFILES
) obj
/util
/benchmark.o obj
/libre2.a
$(LDFLAGS
) $(LDPCRE
)
201 re2
/perl_groups.
cc: re2
/make_perl_groups.pl
204 re2
/unicode_
%.
cc: re2
/make_unicode_
%.py
209 rm -f re2
/perl_groups.
cc re2
/unicode_casefold.
cc re2
/unicode_groups.
cc
215 testofiles
: $(TESTOFILES
)
217 test: $(DTESTS
) $(TESTS
) $(STESTS
) debug-test static-test shared-test
219 debug-test
: $(DTESTS
)
221 @echo Running debug binary tests.
223 @.
/runtests
$(DTESTS
)
225 static-test
: $(TESTS
)
227 @echo Running static binary tests.
231 shared-test
: $(STESTS
)
233 @echo Running dynamic binary tests.
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
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/^/# /'; \
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/%
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