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