|
| 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. |
| 4 | + |
| 5 | +all: obj/libre2.a |
| 6 | + |
| 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 |
| 11 | + |
| 12 | +CC=g++ |
| 13 | +CFLAGS=-c -Wall -Wno-sign-compare -O3 -g -I. $(CCPCRE) |
| 14 | +AR=ar |
| 15 | +ARFLAGS=rsc |
| 16 | +NM=nm |
| 17 | +NMFLAGS=-p |
| 18 | + |
| 19 | +HFILES=\ |
| 20 | + util/arena.h\ |
| 21 | + util/atomicops.h\ |
| 22 | + util/benchmark.h\ |
| 23 | + util/hash_map.h\ |
| 24 | + util/logging.h\ |
| 25 | + util/mutex.h\ |
| 26 | + util/pcre.h\ |
| 27 | + util/random.h\ |
| 28 | + util/sparse_array.h\ |
| 29 | + util/test.h\ |
| 30 | + util/utf.h\ |
| 31 | + util/util.h\ |
| 32 | + re2/filtered_re2.h\ |
| 33 | + re2/prefilter.h\ |
| 34 | + re2/prefilter_tree.h\ |
| 35 | + re2/prog.h\ |
| 36 | + re2/re2.h\ |
| 37 | + re2/regexp.h\ |
| 38 | + re2/stringpiece.h\ |
| 39 | + re2/testing/exhaustive_tester.h\ |
| 40 | + re2/testing/regexp_generator.h\ |
| 41 | + re2/testing/string_generator.h\ |
| 42 | + re2/testing/tester.h\ |
| 43 | + re2/unicode_casefold.h\ |
| 44 | + re2/unicode_groups.h\ |
| 45 | + re2/walker-inl.h\ |
| 46 | + |
| 47 | +OFILES=\ |
| 48 | + obj/util/arena.o\ |
| 49 | + obj/util/hash.o\ |
| 50 | + obj/util/rune.o\ |
| 51 | + obj/util/stringpiece.o\ |
| 52 | + obj/util/stringprintf.o\ |
| 53 | + obj/util/strutil.o\ |
| 54 | + obj/re2/bitstate.o\ |
| 55 | + obj/re2/compile.o\ |
| 56 | + obj/re2/dfa.o\ |
| 57 | + obj/re2/filtered_re2.o\ |
| 58 | + obj/re2/mimics_pcre.o\ |
| 59 | + obj/re2/nfa.o\ |
| 60 | + obj/re2/onepass.o\ |
| 61 | + obj/re2/parse.o\ |
| 62 | + obj/re2/perl_groups.o\ |
| 63 | + obj/re2/prefilter.o\ |
| 64 | + obj/re2/prefilter_tree.o\ |
| 65 | + obj/re2/prog.o\ |
| 66 | + obj/re2/re2.o\ |
| 67 | + obj/re2/regexp.o\ |
| 68 | + obj/re2/simplify.o\ |
| 69 | + obj/re2/tostring.o\ |
| 70 | + obj/re2/unicode_casefold.o\ |
| 71 | + obj/re2/unicode_groups.o\ |
| 72 | + |
| 73 | +TESTOFILES=\ |
| 74 | + obj/util/pcre.o\ |
| 75 | + obj/util/random.o\ |
| 76 | + obj/util/thread.o\ |
| 77 | + obj/re2/testing/backtrack.o\ |
| 78 | + obj/re2/testing/dump.o\ |
| 79 | + obj/re2/testing/exhaustive_tester.o\ |
| 80 | + obj/re2/testing/null_walker.o\ |
| 81 | + obj/re2/testing/regexp_generator.o\ |
| 82 | + obj/re2/testing/string_generator.o\ |
| 83 | + obj/re2/testing/tester.o\ |
| 84 | + |
| 85 | +TESTS=\ |
| 86 | + obj/test/charclass_test\ |
| 87 | + obj/test/compile_test\ |
| 88 | + obj/test/filtered_re2_test\ |
| 89 | + obj/test/mimics_pcre_test\ |
| 90 | + obj/test/parse_test\ |
| 91 | + obj/test/possible_match_test\ |
| 92 | + obj/test/re2_test\ |
| 93 | + obj/test/re2_arg_test\ |
| 94 | + obj/test/required_prefix_test\ |
| 95 | + obj/test/search_test\ |
| 96 | + obj/test/simplify_test\ |
| 97 | + obj/test/string_generator_test\ |
| 98 | + obj/test/dfa_test\ |
| 99 | + obj/test/exhaustive1_test\ |
| 100 | + obj/test/exhaustive2_test\ |
| 101 | + obj/test/exhaustive3_test\ |
| 102 | + obj/test/exhaustive_test\ |
| 103 | + obj/test/random_test\ |
| 104 | + |
| 105 | +obj/%.o: %.cc $(HFILES) |
| 106 | + @mkdir -p $$(dirname $@) |
| 107 | + $(CC) -o $@ $(CFLAGS) $*.cc 2>&1 | sed 5q |
| 108 | + |
| 109 | +obj/%.o: %.c $(HFILES) |
| 110 | + @mkdir -p $$(dirname $@) |
| 111 | + $(CC) -o $@ $(CFLAGS) $*.c 2>&1 | sed 5q |
| 112 | + |
| 113 | +obj/libre2.a: $(OFILES) |
| 114 | + @mkdir -p obj |
| 115 | + $(AR) $(ARFLAGS) obj/libre2.a $(OFILES) |
| 116 | + |
| 117 | +obj/test/%: obj/libre2.a obj/re2/testing/%.o $(TESTOFILES) obj/util/test.o |
| 118 | + @mkdir -p obj/test |
| 119 | + $(CC) -o $@ obj/re2/testing/$*.o $(TESTOFILES) obj/util/test.o obj/libre2.a -lpthread $(LDPCRE) |
| 120 | + |
| 121 | +obj/test/regexp_benchmark: obj/libre2.a obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/util/benchmark.o |
| 122 | + @mkdir -p obj/test |
| 123 | + $(CC) -o $@ obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/util/benchmark.o obj/libre2.a -lpthread $(LDPCRE) |
| 124 | + |
| 125 | +clean: |
| 126 | + rm -rf obj |
| 127 | + |
| 128 | +testofiles: $(TESTOFILES) |
| 129 | + |
| 130 | +test: $(TESTS) |
| 131 | + @./runtests $(TESTS) |
| 132 | + |
| 133 | +benchmark: obj/test/regexp_benchmark |
| 134 | + |
| 135 | +install: obj/libre2.a |
| 136 | + mkdir -p /usr/local/include/re2 |
| 137 | + install -m 444 re2/re2.h /usr/local/include/re2/re2.h |
| 138 | + install -m 444 re2/stringpiece.h /usr/local/include/re2/stringpiece.h |
| 139 | + install -m 555 obj/libre2.a /usr/local/lib/libre2.a |
| 140 | + |
| 141 | +testinstall: |
| 142 | + @mkdir -p obj |
| 143 | + cp testinstall.cc obj |
| 144 | + (cd obj && g++ -I/usr/local/include testinstall.cc -lre2 -o testinstall) |
| 145 | + obj/testinstall |
| 146 | + |
| 147 | +benchlog: obj/test/regexp_benchmark |
| 148 | + (echo '==BENCHMARK==' `hostname` `date`; \ |
| 149 | + (uname -a; g++ --version; hg identify; file obj/test/regexp_benchmark) | sed 's/^/# /'; \ |
| 150 | + echo; \ |
| 151 | + ./obj/test/regexp_benchmark 'PCRE|RE2') | tee -a benchlog.$$(hostname | sed 's/\..*//') |
0 commit comments