File: Makefile

package info (click to toggle)
mrgingham 1.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: cpp: 2,285; ansic: 479; sh: 364; python: 280; makefile: 92
file content (124 lines) | stat: -rw-r--r-- 4,225 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
include choose_mrbuild.mk
include $(MRBUILD_MK)/Makefile.common.header



PROJECT_NAME := mrgingham
ABI_VERSION  := 2
TAIL_VERSION := 1


DIST_BIN := mrgingham mrgingham-observe-pixel-uncertainty mrgingham-rotate-corners
DIST_MAN := $(addsuffix .1,$(DIST_BIN))

# I want the tool I ship to be called "mrgingham", but I already have
# mrgingham.cc: it's a part of the LIBRARY
mrgingham: mrgingham-from-image
	cp $< $@
EXTRA_CLEAN += mrgingham
all: mrgingham

BIN_SOURCES := mrgingham-from-image.cc
BIN_SOURCES += test-dump-chessboard-corners.cc test-dump-blobs.cc test-find-grid-from-points.cc

LIB_SOURCES := find_grid.cc find_blobs.cc find_chessboard_corners.cc mrgingham.cc ChESS.c

# The opencv people (or maybe the Debian people?) have renamed the opencv.pc
# file in opencv 4. So now I look for both version 4 and the default. What will
# happen with opencv5? We'll see!
CXXFLAGS_CV := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv 2>/dev/null)
LDLIBS_CV   := $(shell pkg-config --libs   opencv4 2>/dev/null || pkg-config --libs   opencv 2>/dev/null)
CCXXFLAGS += $(CXXFLAGS_CV)
LDLIBS    += $(LDLIBS_CV) -lpthread

CCXXFLAGS += -fvisibility=hidden

CFLAGS    += -std=gnu99
CCXXFLAGS += -Wno-unused-function -Wno-missing-field-initializers -Wno-unused-parameter -Wno-strict-aliasing -Wno-int-to-pointer-cast -Wno-unused-variable

# On opencv4 I do this:
ifneq ($(wildcard /usr/include/opencv4),)
CCXXFLAGS += -D CV_LOAD_IMAGE_GRAYSCALE=cv::IMREAD_GRAYSCALE
endif


test:
	test/test--mrgingham-rotate-corners
.PHONY: test


DIST_INCLUDE := mrgingham.hh point.hh

# I construct the README.org from the template. The only thing I do is to insert
# the manpages. Note that this is more complicated than it looks:
#
# 1. The documentation is extracted into a .pod by make-pod-from-help
# 2. This documentation is stripped out here wih pod2text, and included in the
#    README. This README is an org-mode file, and the README.template.org
#    container included the manpage text inside a #+BEGIN_EXAMPLE/#+END_EXAMPLE.
#    So the manpages are treated as a verbatim, unformatted text blob
# 3. Further down, the same POD is converted to a manpage via pod2man
define MAKE_README =
BEGIN									\
{									\
  for $$a (@ARGV)							\
  {									\
    $$base = $$a =~ s/\.pod$$//r;                                       \
    $$c{$$base} = `pod2text $$a | mawk "/REPOSITORY/{exit} {print}"`;	\
  }									\
}									\
									\
while(<STDIN>)								\
{									\
  print s/xxx-manpage-(.*?)-xxx/$$c{$$1}/gr;				\
}
endef

README.org: README.template.org $(DIST_BIN:%=%.pod)
	< $(filter README%,$^) perl -e '$(MAKE_README)' $(filter-out README%,$^) > $@
all: README.org

%.1: %.pod
	pod2man --center="mrgingham: chessboard corner finder" --name=MRGINGHAM --release="mrgingham $(VERSION)" --section=1 $^ $@
%.pod: %
	$(MRBUILD_BIN)/make-pod-from-help $< > $@.tmp
	cat footer.pod >> $@.tmp
	mv $@.tmp $@
EXTRA_CLEAN += *.1 $(addsuffix .pod,$(DIST_BIN)) README.org

%.usage.h: %.usage
	< $^ sed 's/\\/\\\\/g; s/"/\\"/g; s/^/"/; s/$$/\\n"/;' > $@
EXTRA_CLEAN += *.usage.h

mrgingham-from-image.o: mrgingham.usage.h

########## chessboard-generating rules
########## I can "make chessboard.10x14.pdf" and it'll do the right thing
chessboard.%.fig: generate-chessboard-fig.py
	./$< $(subst x, ,$*) > $@.tmp
	mv $@.tmp $@
%.pdf: %.fig
	fig2dev -L pdf $< > $@.tmp
	mv $@.tmp $@


########## python stuff

mrgingham_pywrap.o: CCXXFLAGS += $(PY_MRBUILD_CFLAGS)
mrgingham_pywrap_cplusplus_bridge.o: CCXXFLAGS += -fPIC
mrgingham_pywrap.o: $(addsuffix .h,$(wildcard *.docstring))

# The python library is called "mrgingham.$(SO)". This is confusing, but is the
# best I could do. Because I want to be able to "import mrgingham"; and the
# normal way of creating a "mrgingham" subdirectory for all the python stuff
# doesn't work here: I already have a directory entry called "mrgingham"; it's
# the main commandline tool.
mrgingham$(PY_EXT_SUFFIX): mrgingham_pywrap.o mrgingham_pywrap_cplusplus_bridge.o libmrgingham.$(SO)
	$(PY_MRBUILD_LINKER) $(PY_MRBUILD_LDFLAGS) $^ -o $@

DIST_PY3_MODULES := mrgingham$(PY_EXT_SUFFIX)

all: mrgingham$(PY_EXT_SUFFIX)

include $(MRBUILD_MK)/Makefile.common.footer