various debugging pieces in edges.[ch]
[sparrow.git] / Makefile
blob882a3b65b7465a34fde117b37a6d9442dba7e9b8
1 all::
3 #CFLAGS =
4 #LDFLAGS =
5 DEFINES = -DDSFMT_MEXP=19937
6 WARNINGS = -Wall -Wextra -Wno-unused-parameter
7 ALL_CFLAGS = $(VECTOR_FLAGS) -O3 $(WARNINGS) -pipe -D_GNU_SOURCE -DDSFMT_MEXP=19937 -std=gnu99 $(INCLUDES) $(CFLAGS)
8 ALL_LDFLAGS = $(LDFLAGS)
11 DSFMT_FLAGS = -finline-functions -fomit-frame-pointer -DNDEBUG -fno-strict-aliasing --param max-inline-insns-single=1800 -Wmissing-prototypes -std=c99
13 VECTOR_FLAGS = -msse2 -DHAVE_SSE2 -D__SSE2__ -floop-strip-mine -floop-block
15 # these *might* do something useful
16 # -fvisibility=hidden
17 #POSSIBLE_OPTIMISING_CFLAGS = -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las \
18 # -funsafe-loop-optimizations -Wunsafe-loop-optimizations -fsee -funsafe-math-optimizations and more
19 # "-combine -fwhole-program" with __attribute__((externally_visible))
20 # -fprofile-arcs and -fbranch-probabilities
21 #POSSIBLE_PESSIMISING_CFLAGS -fmudflap -fmudflapth -fmudflapir
23 SPARROW_SRC = gstsparrow.c dSFMT/dSFMT.c sparrow.c
25 CC = gcc
26 AR = ar
27 INSTALL = install
29 export GST_DEBUG = sparrow:4
30 #export GST_PLUGIN_PATH = .
32 #OPENCV_INCLUDE = -I/usr/include/opencv/
33 OPENCV_INCLUDE = -isystem /usr/local/include/opencv/
35 #GST_PLUGIN_LDFLAGS = -module -avoid-version -export-symbols-regex '_*\(gst_\|Gst\|GST_\).*'
36 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
37 INCLUDES = -I. $(GST_INCLUDES) -I/usr/include/liboil-0.3 $(OPENCV_INCLUDE)
39 LINKS = -L/usr/local/lib -lgstbase-0.10 -lgstreamer-0.10 -lgobject-2.0 \
40 -lglib-2.0 -lgstvideo-0.10 -lcxcore -lcv
41 # -lgstcontroller-0.10 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lcv -lcvaux -lhighgui
43 all:: libgstsparrow.so
45 libgstsparrow.so: gstsparrow.o sparrow.o calibrate.o itworks.o floodfill.o edges.o dSFMT/dSFMT.o
46 $(CC) -shared -Wl,-O1 $+ $(GST_PLUGIN_LDFLAGS) $(INCLUDES) $(DEFINES) $(LINKS) -Wl,-soname -Wl,$@ \
47 -o $@
49 clean:
50 rm -f *.so *.o *.a *.d *.s
51 cd dSFMT && rm -f *.o *.s
52 rm -f sparrow_false_colour_lut.h sparrow_gamma_lut.h
54 dSFMT/dSFMT.o: dSFMT/dSFMT.c
55 $(CC) $(DSFMT_FLAGS) -MD $(ALL_CFLAGS) -fvisibility=hidden $(CPPFLAGS) -c -o $@ $<
57 .c.o:
58 $(CC) -c -MD $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
59 # $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) -MD $<
61 %.s: %.c
62 $(CC) -S $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
64 %.i: %.c
65 $(CC) -E $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
67 sparrow_gamma_lut.h: gamma.py
68 python $< > $@
70 sparrow_false_colour_lut.h: false_colour.py
71 python $< > $@
73 gstsparrow.c: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
75 sparrow.c: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
77 DEBUG_LEVEL = 5
78 TEST_GST_ARGS = --gst-plugin-path=. --gst-debug=sparrow:$(DEBUG_LEVEL)
79 TEST_INPUT_SIZE = width=320,height=240
80 TEST_OUTPUT_SIZE = width=320,height=240
81 TEST_V4L2_SHAPE = 'video/x-raw-yuv,format=(fourcc)YUY2,$(TEST_INPUT_SIZE),framerate=25/1'
82 TEST_OUTPUT_SHAPE = 'video/x-raw-rgb,$(TEST_OUTPUT_SIZE),framerate=25/1'
83 TEST_SINK = ximagesink
84 #TEST_SINK = fbdevsink
85 TEST_PIPE_TAIL = ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
86 TEST_V4L2_PIPE_TAIL = $(TEST_V4L2_SHAPE) ! $(TEST_PIPE_TAIL)
88 test: all
89 gst-launch $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
91 test-valgrind: debug
92 valgrind --log-file=valgrind.log --trace-children=yes --suppressions=valgrind-python.supp \
93 gst-launch $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL) 2> gst.log
95 test-gdb: debug
96 echo "set args $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)" > /tmp/gdb-args.txt
97 gdb -x /tmp/gdb-args.txt gst-launch
99 test-nemiver: debug
100 nemiver "gst-launch $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)"
103 test-times: all
104 timeout -3 20 time -v gst-launch $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
106 test-cam:
107 gst-launch $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
109 test-pattern: all
110 GST_DEBUG=sparrow:5 \
111 gst-launch $(TEST_GST_ARGS) videotestsrc ! $(TEST_V4L2_PIPE_TAIL)
113 TEST_VIDEO_FILE=/home/douglas/media/video/rochester-pal.avi
114 #TEST_VIDEO_FILE=/home/douglas/tv/newartland_2008_ep2_ps6313_part3.flv
116 test-file: all
117 gst-launch $(TEST_GST_ARGS) \
118 filesrc location=$(TEST_VIDEO_FILE) ! decodebin2 ! $(TEST_PIPE_TAIL)
120 inspect: all
121 gst-inspect $(TEST_GST_ARGS) sparrow $(TEST_OPTIONS)
124 #show filtered and unfiltered video side by side
125 test-tee: all
126 gst-launch $(TEST_GST_ARGS) v4l2src ! tee name=vid2 \
127 ! queue ! ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
128 vid2. ! queue ! ffmpegcolorspace ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
130 test-tee2: all
131 gst-launch $(TEST_GST_ARGS) -v v4l2src ! ffmpegcolorspace ! tee name=vid2 \
132 ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
133 vid2. ! queue ! fdsink | \
134 gst-launch fdsrc ! queue ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
137 TAGS:
138 $(RM) TAGS
139 # find -name "*.[ch]" | xargs etags -a
140 etags -R --exclude=junk --exclude=.git --exclude=prof
142 cscope:
143 $(RM) cscope.out
144 cscope -b $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
147 CPROTO_INCLUDES = $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
149 cproto:
150 # cproto $(INCLUDES) -DUNUSED='' -S -i -X 0 *.c
151 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -S -X 0 *.c
153 cproto-nonstatic:
154 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -X 0 *.c
157 #oprofile: all
158 # sudo opcontrol --no-vmlinux $(OP_OPTS) && sudo opcontrol $(OP_OPTS) --start --verbose
159 # timeout -3 10 gst-launch $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_SHAPE) ! ffmpegcolorspace \
160 # ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
161 # opreport $(OP_OPTS)
163 sysprof: debug
164 lsmod | grep -q 'sysprof_module' || sudo modprobe sysprof-module
165 sysprof &
166 @echo "click the start button!"
168 splint:
169 splint $(INCLUDES) sparrow.c
170 flawfinder $(PWD)
173 unittest:
174 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test test.c
175 ./test
177 unittest-shifts:
178 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test shift_test.c
179 ./test
181 CV_LINKS = -lcv -lcvaux -lhighgui
183 unittest-edges:
184 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-find-edge.c
185 ./test
188 debug:
189 make -B CFLAGS='-g -fno-inline -fno-inline-functions -fno-omit-frame-pointer'
191 #ccmalloc
192 ccmalloc:
193 make -B CFLAGS='-lccmalloc -g' CC='ccmalloc --nowrapper gcc'
196 .PHONY: TAGS all cproto cproto-nonstatic sysprof splint unittest unittest-shifts unittest-edges \
197 debug ccmalloc