option to use video test source for testing with camera
[sparrow.git] / Makefile
blob0016aeb9173b16b6189e329de795c8aca1d5237b
1 all::
3 GDB_ALWAYS_FLAGS = -g
4 #CFLAGS =
5 #LDFLAGS =
6 DEFINES = -DDSFMT_MEXP=19937
7 WARNINGS = -Wall -Wextra -Wno-unused-parameter
9 ARCH = $(shell arch)
10 ifeq "$(ARCH)" "x86_64"
11 ARCH_CFLAGS = -fPIC -DPIC -m64
12 JPEG_LIBRARY_PATH=/opt/libjpeg-turbo/lib
13 JPEG_STATIC=
14 JPEG_LINKS = -ljpeg
15 else
16 ARCH_CFLAGS = -m32 -msse2
17 JPEG_LIBRARY_PATH=/opt/libjpeg-turbo/lib32
18 JPEG_STATIC=$(JPEG_LIBRARY_PATH)/libjpeg.a
19 JPEG_LINKS = -L$(JPEG_LIBRARY_PATH) -Wl,-Bstatic -ljpeg -Wl,-Bdynamic
20 endif
21 JPEG_CPATH = /opt/libjpeg-turbo/include
22 CPATH = $(JPEG_CPATH)
23 LD_LIBRARY_PATH = $(JPEG_LIBRARY_PATH):$(LD_LIBRARY_PATH)
26 ALL_CFLAGS = -march=native -pthread $(VECTOR_FLAGS) -O3 $(WARNINGS) -pipe -D_GNU_SOURCE -DDSFMT_MEXP=19937 -std=gnu99 $(INCLUDES) $(ARCH_CFLAGS) $(CFLAGS) $(GDB_ALWAYS_FLAGS)
27 ALL_LDFLAGS = $(LDFLAGS)
30 DSFMT_FLAGS = -finline-functions -fomit-frame-pointer -DNDEBUG -fno-strict-aliasing --param max-inline-insns-single=1800 -Wmissing-prototypes -std=c99
32 VECTOR_FLAGS = -msse2 -DHAVE_SSE2 -D__SSE2__ -floop-strip-mine -floop-block
34 # these *might* do something useful
35 # -fvisibility=hidden
36 #POSSIBLE_OPTIMISING_CFLAGS = -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las \
37 # -funsafe-loop-optimizations -Wunsafe-loop-optimizations -fsee -funsafe-math-optimizations and more
38 # "-combine -fwhole-program" with __attribute__((externally_visible))
39 # -fprofile-arcs and -fbranch-probabilities
40 #POSSIBLE_PESSIMISING_CFLAGS -fmudflap -fmudflapth -fmudflapir
42 SPARROW_SRC = gstsparrow.c dSFMT/dSFMT.c sparrow.c
44 CC = gcc
45 AR = ar
46 INSTALL = install
48 export GST_DEBUG = sparrow:4
49 #export GST_PLUGIN_PATH = .
51 OPENCV_PREFIX = $(shell test -d /usr/local/include/opencv && echo /usr/local || echo /usr )
53 #OPENCV_INCLUDE = -I/usr/include/opencv/
54 OPENCV_INCLUDE = -isystem $(OPENCV_PREFIX)/include/opencv/
56 GTK_INCLUDES = -I/usr/include/gtk-2.0/ -I/usr/include/cairo/ -I/usr/include/pango-1.0/ -I/usr/lib/gtk-2.0/include/ -I/usr/include/atk-1.0/
58 #GST_PLUGIN_LDFLAGS = -module -avoid-version -export-symbols-regex '_*\(gst_\|Gst\|GST_\).*'
59 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
60 INCLUDES = -I. $(GST_INCLUDES) -I/usr/include/liboil-0.3 $(OPENCV_INCLUDE) -I$(JPEG_CPATH)
63 # -L$(JPEG_LIBRARY_PATH) -Wl,-Bstatic -ljpeg -Wl,-Bdynamic
64 #or, to use dynamic linking, allegedly, -R $(JPEG_LIBRARY_PATH)
65 # or just put in the list of linkees $(JPEG_LIBRARY_PATH)/libjpeg.a
66 # or symlink /usr/lib/libjpeg* to /opt/..
69 LINKS = -L/usr/local/lib -lgstbase-0.10 -lgstreamer-0.10 -lgobject-2.0 \
70 -lglib-2.0 -lgstvideo-0.10 -lcxcore -lcv $(JPEG_LINKS)
71 # -lgstcontroller-0.10 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lcv -lcvaux -lhighgui
73 SOURCES = gstsparrow.c sparrow.c calibrate.c play.c floodfill.c edges.c dSFMT/dSFMT.c jpeg_src.c load_images.c
74 OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
76 all:: libgstsparrow.so
78 libgstsparrow.so: $(OBJECTS) $(JPEG_STATIC)
79 $(CC) -shared -Wl,-O1 $+ $(GST_PLUGIN_LDFLAGS) $(INCLUDES) $(DEFINES) $(LINKS) -Wl,-soname -Wl,$@ \
80 -o $@
82 clean:
83 rm -f *.so *.o *.a *.d *.s
84 cd dSFMT && rm -f *.o *.s
85 rm -f sparrow_false_colour_lut.h
87 dSFMT/dSFMT.o: dSFMT/dSFMT.c
88 $(CC) $(DSFMT_FLAGS) -MD $(ALL_CFLAGS) -fvisibility=hidden $(CPPFLAGS) -c -o $@ $<
90 .c.o:
91 # @echo $(CPATH)
92 # @echo $(LIBRARY_PATH)
93 $(CC) -c -MD $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
94 # $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) -MD $<
96 %.s: %.c
97 $(CC) -S $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
99 %.i: %.c
100 $(CC) -E $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
102 sparrow_false_colour_lut.h: false_colour.py
103 python $< > $@
105 gstsparrow.c: gstsparrow.h sparrow_false_colour_lut.h sparrow.h
107 sparrow.c: gstsparrow.h sparrow_false_colour_lut.h sparrow.h
109 GST_LAUNCH = gst-launch-0.10
110 DEBUG_LEVEL = 5
111 TEST_GST_ARGS = --gst-plugin-path=. --gst-debug=sparrow:$(DEBUG_LEVEL)
112 #TEST_INPUT_SIZE = width=320,height=240
113 #TEST_OUTPUT_SIZE = width=320,height=240
114 TEST_FPS=20
115 TEST_INPUT_SIZE = width=800,height=600
116 TEST_OUTPUT_SIZE = width=800,height=600
118 TEST_V4L2_SHAPE = 'video/x-raw-yuv,format=(fourcc)YUY2,$(TEST_INPUT_SIZE),framerate=$(TEST_FPS)/1'
119 TEST_OUTPUT_SHAPE = 'video/x-raw-rgb,$(TEST_OUTPUT_SIZE),framerate=$(TEST_FPS)/1'
120 TEST_SINK = ximagesink
121 #TEST_SINK = fbdevsink
122 TEST_PIPE_TAIL = ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
123 TEST_V4L2_PIPE_TAIL = $(TEST_V4L2_SHAPE) ! $(TEST_PIPE_TAIL)
125 test: all
126 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
128 test-capture: all
129 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! ffmpegcolorspace ! tee name=vid2 \
130 ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
131 vid2. ! queue ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location='/tmp/sparrow.ogv'
132 # ! jpegenc ! avimux ! filesink location=mjpeg.avi
133 #jpegenc quality=85
135 test-gtk: debug gtk-app
136 GST_DEBUG=sparrow:$(DEBUG_LEVEL) gdb ./gtk-app
138 test-valgrind: debug
139 valgrind --log-file=valgrind.log --trace-children=yes --suppressions=valgrind-python.supp \
140 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL) 2> gst.log
142 test-gdb: debug
143 echo "set args $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)" > /tmp/gdb-args.txt
144 gdb -x /tmp/gdb-args.txt $(GST_LAUNCH)
146 test-times: all
147 timeout -3 20 time -v $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
149 test-cam:
150 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
152 test-pattern: all
153 GST_DEBUG=sparrow:5 \
154 $(GST_LAUNCH) $(TEST_GST_ARGS) videotestsrc ! $(TEST_V4L2_PIPE_TAIL)
156 TEST_VIDEO_FILE=/home/douglas/media/video/rochester-pal.avi
157 #TEST_VIDEO_FILE=/home/douglas/tv/newartland_2008_ep2_ps6313_part3.flv
159 test-file: all
160 $(GST_LAUNCH) $(TEST_GST_ARGS) \
161 filesrc location=$(TEST_VIDEO_FILE) ! decodebin2 ! $(TEST_PIPE_TAIL)
163 inspect: all
164 gst-inspect $(TEST_GST_ARGS) sparrow $(TEST_OPTIONS)
167 #show filtered and unfiltered video side by side
168 test-tee: all
169 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! ffmpegcolorspace ! tee name=vid2 \
170 ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
171 vid2. ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
174 TAGS:
175 $(RM) TAGS
176 # find -name "*.[ch]" | xargs etags -a
177 etags -R --exclude=junk --exclude=.git --exclude=prof
179 cscope:
180 $(RM) cscope.out
181 cscope -b $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
184 CPROTO_INCLUDES = $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
186 cproto:
187 # cproto $(INCLUDES) -DUNUSED='' -S -i -X 0 *.c
188 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -S -X 0 *.c
190 cproto-nonstatic:
191 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -X 0 *.c
194 #oprofile: all
195 # sudo opcontrol --no-vmlinux $(OP_OPTS) && sudo opcontrol $(OP_OPTS) --start --verbose
196 # timeout -3 10 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_SHAPE) ! ffmpegcolorspace \
197 # ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
198 # opreport $(OP_OPTS)
200 sysprof: debug
201 lsmod | grep -q 'sysprof_module' || sudo modprobe sysprof-module || \
202 echo "try again after 'sudo m-a a-i sysprof-module-source'"
203 sysprof &
204 @echo "click the start button!"
206 splint:
207 splint $(INCLUDES) sparrow.c
208 flawfinder $(PWD)
211 unittest:
212 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test test.c
213 ./test
215 unittest-shifts:
216 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test shift_test.c
217 ./test
219 CV_LINKS = -lcv -lcvaux -lhighgui
221 unittest-edges:
222 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-find-edge.c
223 ./test
225 unittest-median:
226 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-median.c
227 ./test
229 unittest-jpeg: gstsparrow.o sparrow.o calibrate.o play.o floodfill.o edges.o dSFMT/dSFMT.o jpeg_src.o
230 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(LINKS) -o test $^ $(JPEG_STATIC) test-jpeg.c
232 # ./test
234 debug:
235 make -B CFLAGS='-g -fno-inline -fno-inline-functions -fno-omit-frame-pointer'
237 #ccmalloc
238 ccmalloc:
239 make -B CFLAGS='-lccmalloc -g' CC='ccmalloc --nowrapper gcc'
241 rsync:
242 rsync -t $(shell git ls-tree -r --name-only HEAD) 10.42.43.10:sparrow
245 .PHONY: TAGS all cproto cproto-nonstatic sysprof splint unittest unittest-shifts unittest-edges \
246 debug ccmalloc rsync app-clean
248 GTK_APP = gtk-app.c
249 GTK_LINKS = -lglib-2.0 $(LINKS) -lgstinterfaces-0.10
250 CLUTTER_INCLUDES = -I/usr/include/clutter-1.0/ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ -I/usr/include/pango-1.0/ -I/usr/include/cairo/ -I/usr/include/gstreamer-0.10/ -I/usr/include/libxml2/
251 CLUTTER_SRC = clutter-app.c
252 CLUTTER_LINKS = -lclutter-gst-0.10 -lglib-2.0
253 GTK_CLUTTER_LINKS = $(LINKS) -lgstinterfaces-0.10 -lclutter-gst-0.10 -lglib-2.0 -lclutter-gtk-0.10
254 GTK_CLUTTER_INCLUDES = $(GTK_INCLUDES) $(CLUTTER_INCLUDES)
256 gtk-app::
257 $(CC) -g $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) $(INCLUDES) $(GTK_INCLUDES)\
258 $(GTK_LINKS) -o $@ $(GTK_APP)
260 gtk-clutter-app::
261 $(CC) $(ALL_CFLAGS) $(CPPFLAGS) $(GTK_CLUTTER_LINKS) $(INCLUDES) $(GTK_CLUTTER_INCLUDES) \
262 -o $@ gtk-clutter-app.c
264 sparrow.xml::
265 $(GST_LAUNCH) -o sparrow.xml $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
267 clutter-app:
268 $(CC) $(ALL_CFLAGS) $(CPPFLAGS) $(CLUTTER_LINKS) $(CLUTTER_INCLUDES)\
269 $(LINKS) -o $@ $(CLUTTER_SRC)
271 app-clean:
272 $(RM) gtk-app clutter-app