found a helper function for dataless ipl images; use it
[sparrow.git] / Makefile
blobc182625a8c0bef839bba23ddf6a9b2a1cda2e68f
1 all::
3 #CFLAGS =
4 #LDFLAGS =
5 DEFINES = -DDSFMT_MEXP=19937
6 WARNINGS = -Wall -Wextra -Wno-unused-parameter
8 ARCH = $(shell arch)
9 ifeq "$(ARCH)" "x86_64"
10 ARCH_CFLAGS = -fPIC -DPIC -m64
11 else
12 ARCH_CFLAGS = -m32 -msse2
13 endif
15 ALL_CFLAGS = -march=native -pthread $(VECTOR_FLAGS) -O3 $(WARNINGS) -pipe -D_GNU_SOURCE -DDSFMT_MEXP=19937 -std=gnu99 $(INCLUDES) $(ARCH_CFLAGS) $(CFLAGS)
16 ALL_LDFLAGS = $(LDFLAGS)
19 DSFMT_FLAGS = -finline-functions -fomit-frame-pointer -DNDEBUG -fno-strict-aliasing --param max-inline-insns-single=1800 -Wmissing-prototypes -std=c99
21 VECTOR_FLAGS = -msse2 -DHAVE_SSE2 -D__SSE2__ -floop-strip-mine -floop-block
23 # these *might* do something useful
24 # -fvisibility=hidden
25 #POSSIBLE_OPTIMISING_CFLAGS = -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las \
26 # -funsafe-loop-optimizations -Wunsafe-loop-optimizations -fsee -funsafe-math-optimizations and more
27 # "-combine -fwhole-program" with __attribute__((externally_visible))
28 # -fprofile-arcs and -fbranch-probabilities
29 #POSSIBLE_PESSIMISING_CFLAGS -fmudflap -fmudflapth -fmudflapir
31 SPARROW_SRC = gstsparrow.c dSFMT/dSFMT.c sparrow.c
33 CC = gcc
34 AR = ar
35 INSTALL = install
37 export GST_DEBUG = sparrow:4
38 #export GST_PLUGIN_PATH = .
40 OPENCV_PREFIX = $(shell test -d /usr/local/include/opencv && echo /usr/local || echo /usr )
42 #OPENCV_INCLUDE = -I/usr/include/opencv/
43 OPENCV_INCLUDE = -isystem $(OPENCV_PREFIX)/include/opencv/
45 #GST_PLUGIN_LDFLAGS = -module -avoid-version -export-symbols-regex '_*\(gst_\|Gst\|GST_\).*'
46 GST_INCLUDES = -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2
47 INCLUDES = -I. $(GST_INCLUDES) -I/usr/include/liboil-0.3 $(OPENCV_INCLUDE)
49 LINKS = -L/usr/local/lib -lgstbase-0.10 -lgstreamer-0.10 -lgobject-2.0 \
50 -lglib-2.0 -lgstvideo-0.10 -lcxcore -lcv
51 # -lgstcontroller-0.10 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lcv -lcvaux -lhighgui
53 all:: libgstsparrow.so
55 libgstsparrow.so: gstsparrow.o sparrow.o calibrate.o play.o floodfill.o edges.o dSFMT/dSFMT.o
56 $(CC) -shared -Wl,-O1 $+ $(GST_PLUGIN_LDFLAGS) $(INCLUDES) $(DEFINES) $(LINKS) -Wl,-soname -Wl,$@ \
57 -o $@
59 clean:
60 rm -f *.so *.o *.a *.d *.s
61 cd dSFMT && rm -f *.o *.s
62 rm -f sparrow_false_colour_lut.h sparrow_gamma_lut.h
64 dSFMT/dSFMT.o: dSFMT/dSFMT.c
65 $(CC) $(DSFMT_FLAGS) -MD $(ALL_CFLAGS) -fvisibility=hidden $(CPPFLAGS) -c -o $@ $<
67 .c.o:
68 $(CC) -c -MD $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
69 # $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) -MD $<
71 %.s: %.c
72 $(CC) -S $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
74 %.i: %.c
75 $(CC) -E $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
77 sparrow_gamma_lut.h: gamma.py
78 python $< > $@
80 sparrow_false_colour_lut.h: false_colour.py
81 python $< > $@
83 gstsparrow.c: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
85 sparrow.c: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
87 GST_LAUNCH = gst-launch-0.10
88 DEBUG_LEVEL = 5
89 TEST_GST_ARGS = --gst-plugin-path=. --gst-debug=sparrow:$(DEBUG_LEVEL)
90 TEST_INPUT_SIZE = width=320,height=240
91 TEST_OUTPUT_SIZE = width=320,height=240
92 TEST_V4L2_SHAPE = 'video/x-raw-yuv,format=(fourcc)YUY2,$(TEST_INPUT_SIZE),framerate=25/1'
93 TEST_OUTPUT_SHAPE = 'video/x-raw-rgb,$(TEST_OUTPUT_SIZE),framerate=25/1'
94 TEST_SINK = ximagesink
95 #TEST_SINK = fbdevsink
96 TEST_PIPE_TAIL = ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
97 TEST_V4L2_PIPE_TAIL = $(TEST_V4L2_SHAPE) ! $(TEST_PIPE_TAIL)
99 test: all
100 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
102 test-valgrind: debug
103 valgrind --log-file=valgrind.log --trace-children=yes --suppressions=valgrind-python.supp \
104 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL) 2> gst.log
106 test-gdb: debug
107 echo "set args $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)" > /tmp/gdb-args.txt
108 gdb -x /tmp/gdb-args.txt $(GST_LAUNCH)
110 test-times: all
111 timeout -3 20 time -v $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
113 test-cam:
114 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
116 test-pattern: all
117 GST_DEBUG=sparrow:5 \
118 $(GST_LAUNCH) $(TEST_GST_ARGS) videotestsrc ! $(TEST_V4L2_PIPE_TAIL)
120 TEST_VIDEO_FILE=/home/douglas/media/video/rochester-pal.avi
121 #TEST_VIDEO_FILE=/home/douglas/tv/newartland_2008_ep2_ps6313_part3.flv
123 test-file: all
124 $(GST_LAUNCH) $(TEST_GST_ARGS) \
125 filesrc location=$(TEST_VIDEO_FILE) ! decodebin2 ! $(TEST_PIPE_TAIL)
127 inspect: all
128 gst-inspect $(TEST_GST_ARGS) sparrow $(TEST_OPTIONS)
131 #show filtered and unfiltered video side by side
132 test-tee: all
133 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! tee name=vid2 \
134 ! queue ! ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
135 vid2. ! queue ! ffmpegcolorspace ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
137 test-tee2: all
138 $(GST_LAUNCH) $(TEST_GST_ARGS) -v v4l2src ! ffmpegcolorspace ! tee name=vid2 \
139 ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
140 vid2. ! queue ! fdsink | \
141 $(GST_LAUNCH) fdsrc ! queue ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
144 TAGS:
145 $(RM) TAGS
146 # find -name "*.[ch]" | xargs etags -a
147 etags -R --exclude=junk --exclude=.git --exclude=prof
149 cscope:
150 $(RM) cscope.out
151 cscope -b $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
154 CPROTO_INCLUDES = $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
156 cproto:
157 # cproto $(INCLUDES) -DUNUSED='' -S -i -X 0 *.c
158 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -S -X 0 *.c
160 cproto-nonstatic:
161 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -X 0 *.c
164 #oprofile: all
165 # sudo opcontrol --no-vmlinux $(OP_OPTS) && sudo opcontrol $(OP_OPTS) --start --verbose
166 # timeout -3 10 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_SHAPE) ! ffmpegcolorspace \
167 # ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
168 # opreport $(OP_OPTS)
170 sysprof: debug
171 lsmod | grep -q 'sysprof_module' || sudo modprobe sysprof-module || \
172 echo "try again after 'sudo m-a a-i sysprof-module-source'"
173 sysprof &
174 @echo "click the start button!"
176 splint:
177 splint $(INCLUDES) sparrow.c
178 flawfinder $(PWD)
181 unittest:
182 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test test.c
183 ./test
185 unittest-shifts:
186 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test shift_test.c
187 ./test
189 CV_LINKS = -lcv -lcvaux -lhighgui
191 unittest-edges:
192 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-find-edge.c
193 ./test
195 unittest-median:
196 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-median.c
197 ./test
200 debug:
201 make -B CFLAGS='-g -fno-inline -fno-inline-functions -fno-omit-frame-pointer'
203 #ccmalloc
204 ccmalloc:
205 make -B CFLAGS='-lccmalloc -g' CC='ccmalloc --nowrapper gcc'
207 rsync:
208 rsync -t $(shell git ls-tree -r --name-only HEAD) 10.42.43.10:sparrow
211 .PHONY: TAGS all cproto cproto-nonstatic sysprof splint unittest unittest-shifts unittest-edges \
212 debug ccmalloc rsync