shuffle: add basic Markov shuffle, other minor cleanups
[greylag.git] / Makefile
blobad35484d2148d99a5af795d5a909b1c2353bbce5
1 # Makefile for cgreylag module
3 # The SWIG Python/STL interface is pretty new, so SWIG 1.3.31 or later is
4 # required.
5 # Python 2.5 or later is required.
6 # A reasonably recent g++/libstdc++ may also be required.
8 # Developed with swig 1.3.31, g++ 3.4.6/4.1.2, libstdc++.so.6
11 .PHONY: all modsyms install install_scripts clean tags check release
12 .DELETE_ON_ERROR:
15 DEST = /usr/local/lib/greylag/
17 PYTHONFLAGS = $(shell python-config --include)
19 CXXBASEFLAGS = -Wall -Werror -g3 -fPIC -pipe
21 # use to add flags from the make command-line
22 CXXFASTFLAGS =
24 # This makes it easy to compile different versions without editing this file.
25 # 0=debug, 2=fast, 3=maybe faster (and less debuggable)
26 SPEED := 2
28 ifeq ($(SPEED),0)
29 # for debugging (extra checking, slow)
30 CXXFLAGS = $(CXXBASEFLAGS) -O0 -D_GLIBCXX_DEBUG
31 else
32 ifeq ($(SPEED),2)
33 # reasonably fast
34 CXXFLAGS = $(CXXBASEFLAGS) -O2 -ffast-math
35 else
36 ifeq ($(SPEED),3)
37 # for speed (fastest?, fewest checks)
38 CXXFLAGS = $(CXXBASEFLAGS) -O3 -ffast-math -DNDEBUG
39 else
40 CXXFLAGS = ---INVALID-SPEED
41 endif
42 endif
43 endif
45 SWIGCXXFLAGS = $(CXXFLAGS) $(PYTHONFLAGS) -fno-strict-aliasing -Wno-error
47 MODULE = cgreylag
49 all :: _$(MODULE).so
51 $(MODULE)_wrap.cpp : $(MODULE).i $(MODULE).hpp
52 swig -c++ -python -o $@ $<
54 $(MODULE)_wrap.o : $(MODULE)_wrap.cpp $(MODULE).hpp
55 @echo "# some warnings possible here (compiling swig output)"
56 $(CXX) $(SWIGCXXFLAGS) -c $<
58 $(MODULE).o : $(MODULE).cpp $(MODULE).hpp
59 $(CXX) $(CXXFLAGS) $(CXXFASTFLAGS) -c $<
61 _$(MODULE).so : $(MODULE).o $(MODULE)_wrap.o
62 $(CXX) $(CXXFLAGS) $(CXXFASTFLAGS) -shared $^ -o $@
65 # summary of C++ modules symbols used by main script
66 modsyms ::
67 @sed -n -e 's/^.*\(cgreylag\.[a-zA-Z0-9_.]*\).*$$/\1/p' \
68 greylag_chase.py \
69 | sort | uniq -c
71 tags :: TAGS
72 TAGS : $(MODULE).cpp $(MODULE).hpp
73 etags $^
75 install :: all install_scripts
76 install -p _$(MODULE).so $(DEST)
77 install -p --mode=444 $(MODULE).py $(DEST)
79 # FIX: we could compile the .py files here
80 install_scripts ::
81 [ -d $(DEST) ] || install -d $(DEST)
82 install -p --mode=444 greylag.py $(DEST)
83 install -p greylag_shuffle_database.py $(DEST)/greylag-shuffle-database
84 install -p greylag_chase.py $(DEST)/greylag-chase
85 install -p greylag_rally.py $(DEST)/greylag-rally
86 install -p greylag_merge.py $(DEST)/greylag-merge
87 install -p greylag_sqt.py $(DEST)/greylag-sqt
88 install -p greylag_validate.py $(DEST)/greylag-validate
90 clean ::
91 -rm -f $(MODULE).py $(MODULE)_wrap.cpp $(MODULE).o $(MODULE)_wrap.o \
92 _$(MODULE).so *.py[co] TAGS *~ .??*~ \
93 test/*.py[co] test/*.glw test/*-bad.sqt test/tmp* test/*~
95 check :: all
96 nosetests --exe --with-doctest $(NOSEFLAGS)
99 release :: all
100 @echo "# did you update VERSION in greylag.py?"
101 git-tag -l "v$(VERSION)" || false # no such tag
102 git-archive --format=tar --prefix=greylag-$(VERSION)/ v$(VERSION) \
103 | gzip -9 > ../greylag-$(VERSION).tgz