change some comments, debug messages, and whitespace
[sparrow.git] / Makefile
blobe433b68d45cc2dc947b8d8c6950cedf15fd62cc9
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-nemiver: debug
111 nemiver "$(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)"
114 test-times: all
115 timeout -3 20 time -v $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
117 test-cam:
118 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
120 test-pattern: all
121 GST_DEBUG=sparrow:5 \
122 $(GST_LAUNCH) $(TEST_GST_ARGS) videotestsrc ! $(TEST_V4L2_PIPE_TAIL)
124 TEST_VIDEO_FILE=/home/douglas/media/video/rochester-pal.avi
125 #TEST_VIDEO_FILE=/home/douglas/tv/newartland_2008_ep2_ps6313_part3.flv
127 test-file: all
128 $(GST_LAUNCH) $(TEST_GST_ARGS) \
129 filesrc location=$(TEST_VIDEO_FILE) ! decodebin2 ! $(TEST_PIPE_TAIL)
131 inspect: all
132 gst-inspect $(TEST_GST_ARGS) sparrow $(TEST_OPTIONS)
135 #show filtered and unfiltered video side by side
136 test-tee: all
137 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! tee name=vid2 \
138 ! queue ! ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
139 vid2. ! queue ! ffmpegcolorspace ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
141 test-tee2: all
142 $(GST_LAUNCH) $(TEST_GST_ARGS) -v v4l2src ! ffmpegcolorspace ! tee name=vid2 \
143 ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
144 vid2. ! queue ! fdsink | \
145 $(GST_LAUNCH) fdsrc ! queue ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
148 TAGS:
149 $(RM) TAGS
150 # find -name "*.[ch]" | xargs etags -a
151 etags -R --exclude=junk --exclude=.git --exclude=prof
153 cscope:
154 $(RM) cscope.out
155 cscope -b $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
158 CPROTO_INCLUDES = $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
160 cproto:
161 # cproto $(INCLUDES) -DUNUSED='' -S -i -X 0 *.c
162 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -S -X 0 *.c
164 cproto-nonstatic:
165 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -X 0 *.c
168 #oprofile: all
169 # sudo opcontrol --no-vmlinux $(OP_OPTS) && sudo opcontrol $(OP_OPTS) --start --verbose
170 # timeout -3 10 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_SHAPE) ! ffmpegcolorspace \
171 # ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
172 # opreport $(OP_OPTS)
174 sysprof: debug
175 lsmod | grep -q 'sysprof_module' || sudo modprobe sysprof-module || \
176 echo "try again after 'sudo m-a a-i sysprof-module-source'"
177 sysprof &
178 @echo "click the start button!"
180 splint:
181 splint $(INCLUDES) sparrow.c
182 flawfinder $(PWD)
185 unittest:
186 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test test.c
187 ./test
189 unittest-shifts:
190 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test shift_test.c
191 ./test
193 CV_LINKS = -lcv -lcvaux -lhighgui
195 unittest-edges:
196 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-find-edge.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'
208 .PHONY: TAGS all cproto cproto-nonstatic sysprof splint unittest unittest-shifts unittest-edges \
209 debug ccmalloc