Debian Codegraph @

Makefile

raw
1 include choose_mrbuild.mk
2 include $(MRBUILD_MK)/Makefile.common.header
3
4
5
6 PROJECT_NAME := mrgingham
7 ABI_VERSION := 2
8 TAIL_VERSION := 1
9
10
11 DIST_BIN := mrgingham mrgingham-observe-pixel-uncertainty mrgingham-rotate-corners
12 DIST_MAN := $(addsuffix .1,$(DIST_BIN))
13
14 # I want the tool I ship to be called "mrgingham", but I already have
15 # mrgingham.cc: it's a part of the LIBRARY
16 mrgingham: mrgingham-from-image
17 cp $< $@
18 EXTRA_CLEAN += mrgingham
19 all: mrgingham
20
21 BIN_SOURCES := mrgingham-from-image.cc
22 BIN_SOURCES += test-dump-chessboard-corners.cc test-dump-blobs.cc test-find-grid-from-points.cc
23
24 LIB_SOURCES := find_grid.cc find_blobs.cc find_chessboard_corners.cc mrgingham.cc ChESS.c
25
26 # The opencv people (or maybe the Debian people?) have renamed the opencv.pc
27 # file in opencv 4. So now I look for both version 4 and the default. What will
28 # happen with opencv5? We'll see!
29 CXXFLAGS_CV := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv 2>/dev/null)
30 LDLIBS_CV := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv 2>/dev/null)
31 CCXXFLAGS += $(CXXFLAGS_CV)
32 LDLIBS += $(LDLIBS_CV) -lpthread
33
34 CCXXFLAGS += -fvisibility=hidden
35
36 CFLAGS += -std=gnu99
37 CCXXFLAGS += -Wno-unused-function -Wno-missing-field-initializers -Wno-unused-parameter -Wno-strict-aliasing -Wno-int-to-pointer-cast -Wno-unused-variable
38
39 # On opencv4 I do this:
40 ifneq ($(wildcard /usr/include/opencv4),)
41 CCXXFLAGS += -D CV_LOAD_IMAGE_GRAYSCALE=cv::IMREAD_GRAYSCALE
42 endif
43
44
45 test:
46 test/test--mrgingham-rotate-corners
47 .PHONY: test
48
49
50 DIST_INCLUDE := mrgingham.hh point.hh
51
52 # I construct the README.org from the template. The only thing I do is to insert
53 # the manpages. Note that this is more complicated than it looks:
54 #
55 # 1. The documentation is extracted into a .pod by make-pod-from-help
56 # 2. This documentation is stripped out here wih pod2text, and included in the
57 # README. This README is an org-mode file, and the README.template.org
58 # container included the manpage text inside a #+BEGIN_EXAMPLE/#+END_EXAMPLE.
59 # So the manpages are treated as a verbatim, unformatted text blob
60 # 3. Further down, the same POD is converted to a manpage via pod2man
61 define MAKE_README =
62 BEGIN \
63 { \
64 for $$a (@ARGV) \
65 { \
66 $$base = $$a =~ s/\.pod$$//r; \
67 $$c{$$base} = `pod2text $$a | mawk "/REPOSITORY/{exit} {print}"`; \
68 } \
69 } \
70 \
71 while(<STDIN>) \
72 { \
73 print s/xxx-manpage-(.*?)-xxx/$$c{$$1}/gr; \
74 }
75 endef
76
77 README.org: README.template.org $(DIST_BIN:%=%.pod)
78 < $(filter README%,$^) perl -e '$(MAKE_README)' $(filter-out README%,$^) > $@
79 all: README.org
80
81 %.1: %.pod
82 pod2man --center="mrgingham: chessboard corner finder" --name=MRGINGHAM --release="mrgingham $(VERSION)" --section=1 $^ $@
83 %.pod: %
84 $(MRBUILD_BIN)/make-pod-from-help $< > [email protected]
85 cat footer.pod >> [email protected]
86 mv [email protected] $@
87 EXTRA_CLEAN += *.1 $(addsuffix .pod,$(DIST_BIN)) README.org
88
89 %.usage.h: %.usage
90 < $^ sed 's/\\/\\\\/g; s/"/\\"/g; s/^/"/; s/$$/\\n"/;' > $@
91 EXTRA_CLEAN += *.usage.h
92
93 mrgingham-from-image.o: mrgingham.usage.h
94
95 ########## chessboard-generating rules
96 ########## I can "make chessboard.10x14.pdf" and it'll do the right thing
97 chessboard.%.fig: generate-chessboard-fig.py
98 ./$< $(subst x, ,$*) > [email protected]
99 mv [email protected] $@
100 %.pdf: %.fig
101 fig2dev -L pdf $< > [email protected]
102 mv [email protected] $@
103
104
105 ########## python stuff
106
107 mrgingham_pywrap.o: CCXXFLAGS += $(PY_MRBUILD_CFLAGS)
108 mrgingham_pywrap_cplusplus_bridge.o: CCXXFLAGS += -fPIC
109 mrgingham_pywrap.o: $(addsuffix .h,$(wildcard *.docstring))
110
111 # The python library is called "mrgingham.$(SO)". This is confusing, but is the
112 # best I could do. Because I want to be able to "import mrgingham"; and the
113 # normal way of creating a "mrgingham" subdirectory for all the python stuff
114 # doesn't work here: I already have a directory entry called "mrgingham"; it's
115 # the main commandline tool.
116 mrgingham$(PY_EXT_SUFFIX): mrgingham_pywrap.o mrgingham_pywrap_cplusplus_bridge.o libmrgingham.$(SO)
117 $(PY_MRBUILD_LINKER) $(PY_MRBUILD_LDFLAGS) $^ -o $@
118
119 DIST_PY3_MODULES := mrgingham$(PY_EXT_SUFFIX)
120
121 all: mrgingham$(PY_EXT_SUFFIX)
122
123 include $(MRBUILD_MK)/Makefile.common.footer
124