Advertisement
Guest User

Re2MingwMakefile

a guest
May 26th, 2010
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 6.80 KB | None | 0 0
  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 obj/so/libre2.so
  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. CXXFLAGS=-Wall -O3 -g -DMINGW -DNO_THREADS # can override
  14. RE2_CXXFLAGS=-Wno-sign-compare -c -I. $(CCPCRE)  # required
  15. #If you can get pthreads to link! Feel free to use this these instead!
  16. #CXXFLAGS=-Wall -O3 -g -DMINGW -lpthread
  17. #LDFLAGS=-lpthread
  18. LDFLAGS=
  19. AR=ar
  20. ARFLAGS=rsc
  21. NM=nm
  22. NMFLAGS=-p
  23.  
  24. # To rebuild the Tables generated by Perl and Python scripts (requires Internet
  25. # access for Unicode data), uncomment the following line:
  26. # REBUILD_TABLES=1
  27.  
  28. ifeq ($(shell uname),Darwin)
  29. MAKE_SHARED_LIBRARY=g++ -dynamiclib $(LDFLAGS) -exported_symbols_list libre2.symbols.darwin
  30. else
  31. MAKE_SHARED_LIBRARY=g++ -shared -Wl,-soname,libre2.so.0,--version-script=libre2.symbols $(LDFLAGS)
  32. endif
  33.  
  34. HFILES=\
  35.     util/arena.h\
  36.     util/atomicops.h\
  37.     util/benchmark.h\
  38.     util/flags.h\
  39.     util/hash_map.h\
  40.     util/logging.h\
  41.     util/mutex.h\
  42.     util/pcre.h\
  43.     util/random.h\
  44.     util/sparse_array.h\
  45.     util/sparse_set.h\
  46.     util/test.h\
  47.     util/utf.h\
  48.     util/util.h\
  49.     re2/filtered_re2.h\
  50.     re2/prefilter.h\
  51.     re2/prefilter_tree.h\
  52.     re2/prog.h\
  53.     re2/re2.h\
  54.     re2/regexp.h\
  55.     re2/stringpiece.h\
  56.     re2/testing/exhaustive_tester.h\
  57.     re2/testing/regexp_generator.h\
  58.     re2/testing/string_generator.h\
  59.     re2/testing/tester.h\
  60.     re2/unicode_casefold.h\
  61.     re2/unicode_groups.h\
  62.     re2/variadic_function.h\
  63.     re2/walker-inl.h\
  64.  
  65. OFILES=\
  66.     obj/util/arena.o\
  67.     obj/util/hash.o\
  68.     obj/util/rune.o\
  69.     obj/util/stringpiece.o\
  70.     obj/util/stringprintf.o\
  71.     obj/util/strutil.o\
  72.     obj/re2/bitstate.o\
  73.     obj/re2/compile.o\
  74.     obj/re2/dfa.o\
  75.     obj/re2/filtered_re2.o\
  76.     obj/re2/mimics_pcre.o\
  77.     obj/re2/nfa.o\
  78.     obj/re2/onepass.o\
  79.     obj/re2/parse.o\
  80.     obj/re2/perl_groups.o\
  81.     obj/re2/prefilter.o\
  82.     obj/re2/prefilter_tree.o\
  83.     obj/re2/prog.o\
  84.     obj/re2/re2.o\
  85.     obj/re2/regexp.o\
  86.     obj/re2/simplify.o\
  87.     obj/re2/tostring.o\
  88.     obj/re2/unicode_casefold.o\
  89.     obj/re2/unicode_groups.o\
  90.  
  91. TESTOFILES=\
  92.     obj/util/pcre.o\
  93.     obj/util/random.o\
  94.     obj/util/thread.o\
  95.     obj/re2/testing/backtrack.o\
  96.     obj/re2/testing/dump.o\
  97.     obj/re2/testing/exhaustive_tester.o\
  98.     obj/re2/testing/null_walker.o\
  99.     obj/re2/testing/regexp_generator.o\
  100.     obj/re2/testing/string_generator.o\
  101.     obj/re2/testing/tester.o\
  102.  
  103. TESTS=\
  104.     obj/test/charclass_test\
  105.     obj/test/compile_test\
  106.     obj/test/filtered_re2_test\
  107.     obj/test/mimics_pcre_test\
  108.     obj/test/parse_test\
  109.     obj/test/possible_match_test\
  110.     obj/test/re2_test\
  111.     obj/test/re2_arg_test\
  112.     obj/test/regexp_test\
  113.     obj/test/required_prefix_test\
  114.     obj/test/search_test\
  115.     obj/test/simplify_test\
  116.     obj/test/string_generator_test\
  117.     obj/test/dfa_test\
  118.     obj/test/exhaustive1_test\
  119.     obj/test/exhaustive2_test\
  120.     obj/test/exhaustive3_test\
  121.     obj/test/exhaustive_test\
  122.     obj/test/random_test\
  123.  
  124. SOFILES=$(patsubst obj/%,obj/so/%,$(OFILES))
  125. STESTOFILES=$(patsubst obj/%,obj/so/%,$(TESTOFILES))
  126. STESTS=$(patsubst obj/%,obj/so/%,$(TESTS))
  127.  
  128. DOFILES=$(patsubst obj/%,obj/dbg/%,$(OFILES))
  129. DTESTOFILES=$(patsubst obj/%,obj/dbg/%,$(TESTOFILES))
  130. DTESTS=$(patsubst obj/%,obj/dbg/%,$(TESTS))
  131.  
  132. obj/%.o: %.cc $(HFILES)
  133.     @mkdir -p $$(dirname $@)
  134.     $(CC) -o $@ $(CXXFLAGS) $(RE2_CXXFLAGS) -DNDEBUG $*.cc
  135.  
  136. obj/dbg/%.o: %.cc $(HFILES)
  137.     @mkdir -p $$(dirname $@)
  138.     $(CC) -o $@ $(CXXFLAGS) $(RE2_CXXFLAGS) $*.cc
  139.  
  140. obj/so/%.o: %.cc $(HFILES)
  141.     @mkdir -p $$(dirname $@)
  142.     $(CC) -o $@ $(CXXFLAGS) $(RE2_CXXFLAGS) -DNDEBUG $*.cc
  143.  
  144. obj/%.o: %.c $(HFILES)
  145.     @mkdir -p $$(dirname $@)
  146.     $(CC) -o $@ $(CXXFLAGS) $(RE2_CXXFLAGS) -DNDEBUG $*.c
  147.  
  148. obj/dbg/%.o: %.c $(HFILES)
  149.     @mkdir -p $$(dirname $@)
  150.     $(CC) -o $@ $(CXXFLAGS) $(RE2_CXXFLAGS) $*.c
  151.  
  152. obj/so/%.o: %.c $(HFILES)
  153.     @mkdir -p $$(dirname $@)
  154.     $(CC) -o $@ -fPIC $(CXXFLAGS) $(RE2_CXXFLAGS) -DNDEBUG $*.c
  155.  
  156. obj/libre2.a: $(OFILES)
  157.     @mkdir -p obj
  158.     $(AR) $(ARFLAGS) obj/libre2.a $(OFILES)
  159.  
  160. obj/dbg/libre2.a: $(DOFILES)
  161.     @mkdir -p obj/dbg
  162.     $(AR) $(ARFLAGS) obj/dbg/libre2.a $(DOFILES)
  163.  
  164. obj/so/libre2.so: $(SOFILES)
  165.     @mkdir -p obj/so
  166.     $(MAKE_SHARED_LIBRARY) -o $@.0 $(SOFILES)
  167.     ln -sf obj/so/libre2.so.0 $@
  168.  
  169. obj/test/%: obj/libre2.a obj/re2/testing/%.o $(TESTOFILES) obj/util/test.o
  170.     @mkdir -p obj/test
  171.     $(CC) -o $@ obj/re2/testing/$*.o $(TESTOFILES) obj/util/test.o obj/libre2.a $(LDFLAGS) $(LDPCRE)
  172.  
  173. obj/dbg/test/%: obj/dbg/libre2.a obj/dbg/re2/testing/%.o $(DTESTOFILES) obj/dbg/util/test.o
  174.     @mkdir -p obj/dbg/test
  175.     $(CC) -o $@ obj/dbg/re2/testing/$*.o $(DTESTOFILES) obj/dbg/util/test.o obj/dbg/libre2.a $(LDFLAGS) $(LDPCRE)
  176.  
  177. obj/so/test/%: obj/so/libre2.so obj/libre2.a obj/so/re2/testing/%.o $(STESTOFILES) obj/so/util/test.o
  178.     @mkdir -p obj/so/test
  179.     $(CC) -o $@ obj/so/re2/testing/$*.o $(STESTOFILES) obj/so/util/test.o -Lobj/so -lre2 obj/libre2.a $(LDFLAGS) $(LDPCRE)
  180.  
  181. obj/test/regexp_benchmark: obj/libre2.a obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/util/benchmark.o
  182.     @mkdir -p obj/test
  183.     $(CC) -o $@ obj/re2/testing/regexp_benchmark.o $(TESTOFILES) obj/util/benchmark.o obj/libre2.a $(LDFLAGS) $(LDPCRE)
  184.  
  185. ifdef REBUILD_TABLES
  186. re2/perl_groups.cc: re2/make_perl_groups.pl
  187.     perl $< > $@
  188.  
  189. re2/unicode_%.cc: re2/make_unicode_%.py
  190.     python $< > $@
  191. endif
  192.  
  193. distclean: clean
  194.     rm -f re2/perl_groups.cc re2/unicode_casefold.cc re2/unicode_groups.cc
  195.  
  196. clean:
  197.     rm -rf obj
  198.     rm -f re2/*.pyc
  199.  
  200. testofiles: $(TESTOFILES)
  201.  
  202. test: debug-test static-test shared-test
  203.  
  204. debug-test: $(DTESTS)
  205.     @./runtests $(DTESTS)
  206.  
  207. static-test: $(TESTS)
  208.     @./runtests $(TESTS)
  209.  
  210. shared-test: $(STESTS)
  211.     @LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS)
  212.  
  213. benchmark: obj/test/regexp_benchmark
  214.  
  215. install: obj/libre2.a obj/so/libre2.so.0
  216.     rm -fr output
  217.     mkdir output
  218.     mkdir output/include
  219.     mkdir output/include/re2
  220.     mkdir output/lib
  221.     cp re2/re2.h output/include/re2/re2.h
  222.     cp re2/stringpiece.h output/include/re2/stringpiece.h
  223.     cp re2/variadic_function.h output/include/re2/variadic_function.h
  224.     cp obj/libre2.a output/lib/libre2.a
  225.     cp obj/so/libre2.so output/lib/libre2.so
  226.  
  227. testinstall:
  228.     @mkdir -p obj
  229.     cp testinstall.cc obj
  230.     (cd obj && g++ -I/usr/local/include -L/usr/local/lib testinstall.cc -lre2 -pthread -o testinstall)
  231.     obj/testinstall
  232.  
  233. benchlog: obj/test/regexp_benchmark
  234.     (echo '==BENCHMARK==' `hostname` `date`; \
  235.       (uname -a; g++ --version; hg identify; file obj/test/regexp_benchmark) | sed 's/^/# /'; \
  236.       echo; \
  237.       ./obj/test/regexp_benchmark 'PCRE|RE2') | tee -a benchlog.$$(hostname | sed 's/\..*//')
  238.  
  239. # Keep gmake from deleting intermediate files it creates.
  240. # This makes repeated builds faster and preserves debug info on OS X.
  241.  
  242. .PRECIOUS: obj/%.o obj/dbg/%.o obj/so/%.o obj/libre2.a \
  243.     obj/dbg/libre2.a obj/so/libre2.a \
  244.     obj/test/% obj/so/test/% obj/dbg/test/%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement