5 DEFINES
= -DDSFMT_MEXP
=19937
6 WARNINGS
= -Wall
-Wextra
-Wno-unused-parameter
9 ifeq "$(ARCH)" "x86_64"
10 ARCH_CFLAGS
= -fPIC
-DPIC
-m64
11 JPEG_LIBRARY_PATH
=/opt
/libjpeg-turbo
/lib64
13 ARCH_CFLAGS
= -m32
-msse2
14 JPEG_LIBRARY_PATH
=/opt
/libjpeg-turbo
/lib32
17 JPEG_CPATH
= /opt
/libjpeg-turbo
/include
19 LIBRARY_PATH
= $(JPEG_LIBRARY_PATH
)
21 ALL_CFLAGS
= -march
=native
-pthread
$(VECTOR_FLAGS
) -O3
$(WARNINGS
) -pipe
-D_GNU_SOURCE
-DDSFMT_MEXP
=19937 -std
=gnu99
$(INCLUDES
) $(ARCH_CFLAGS
) $(CFLAGS
)
22 ALL_LDFLAGS
= $(LDFLAGS
)
25 DSFMT_FLAGS
= -finline-functions
-fomit-frame-pointer
-DNDEBUG
-fno-strict-aliasing
--param max-inline-insns-single
=1800 -Wmissing-prototypes
-std
=c99
27 VECTOR_FLAGS
= -msse2
-DHAVE_SSE2
-D__SSE2__
-floop-strip-mine
-floop-block
29 # these *might* do something useful
31 #POSSIBLE_OPTIMISING_CFLAGS = -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las \
32 # -funsafe-loop-optimizations -Wunsafe-loop-optimizations -fsee -funsafe-math-optimizations and more
33 # "-combine -fwhole-program" with __attribute__((externally_visible))
34 # -fprofile-arcs and -fbranch-probabilities
35 #POSSIBLE_PESSIMISING_CFLAGS -fmudflap -fmudflapth -fmudflapir
37 SPARROW_SRC
= gstsparrow.c dSFMT
/dSFMT.c sparrow.c
43 export GST_DEBUG
= sparrow
:4
44 #export GST_PLUGIN_PATH = .
46 OPENCV_PREFIX
= $(shell test -d
/usr
/local
/include/opencv
&& echo
/usr
/local || echo
/usr
)
48 #OPENCV_INCLUDE = -I/usr/include/opencv/
49 OPENCV_INCLUDE
= -isystem
$(OPENCV_PREFIX
)/include/opencv
/
51 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
/
53 #GST_PLUGIN_LDFLAGS = -module -avoid-version -export-symbols-regex '_*\(gst_\|Gst\|GST_\).*'
54 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
55 INCLUDES
= -I.
$(GST_INCLUDES
) -I
/usr
/include/liboil-0.3
$(OPENCV_INCLUDE
) -I
$(JPEG_CPATH
)
57 JPEG_LINKS
= -L
$(JPEG_LIBRARY_PATH
) -Wl
,-Bstatic
-ljpeg
-Wl
,-Bdynamic
58 # -L$(JPEG_LIBRARY_PATH) -Wl,-Bstatic -ljpeg -Wl,-Bdynamic
59 #or, to use dynamic, allegedly, -R $(JPEG_LIBRARY_PATH)
60 # or just put in the list of linkees $(JPEG_LIBRARY_PATH)/libjpeg.a
61 JPEG_STATIC
=$(JPEG_LIBRARY_PATH
)/libjpeg.a
63 LINKS
= -L
/usr
/local
/lib
-lgstbase-0.10
-lgstreamer-0.10
-lgobject-2.0 \
64 -lglib-2.0
-lgstvideo-0.10
-lcxcore
-lcv
$(JPEG_LINKS
)
65 # -lgstcontroller-0.10 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lcv -lcvaux -lhighgui
67 SOURCES
= gstsparrow.c sparrow.c calibrate.c play.c floodfill.c edges.c dSFMT
/dSFMT.c jpeg_src.c
69 all:: libgstsparrow.so
71 libgstsparrow.so
: gstsparrow.o sparrow.o calibrate.o play.o floodfill.o edges.o dSFMT
/dSFMT.o jpeg_src.o
72 $(CC
) -shared
-Wl
,-O1
$+ $(GST_PLUGIN_LDFLAGS
) $(INCLUDES
) $(DEFINES
) $(LINKS
) -Wl
,-soname
-Wl
,$@ \
76 rm -f
*.so
*.o
*.a
*.d
*.s
77 cd dSFMT
&& rm -f
*.o
*.s
78 rm -f sparrow_false_colour_lut.h sparrow_gamma_lut.h
80 dSFMT
/dSFMT.o
: dSFMT
/dSFMT.c
81 $(CC
) $(DSFMT_FLAGS
) -MD
$(ALL_CFLAGS
) -fvisibility
=hidden
$(CPPFLAGS
) -c
-o
$@
$<
85 # @echo $(LIBRARY_PATH)
86 $(CC
) -c
-MD
$(ALL_CFLAGS
) $(CPPFLAGS
) -o
$@
$<
87 # $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) -MD $<
90 $(CC
) -S
$(ALL_CFLAGS
) $(CPPFLAGS
) -o
$@
$<
93 $(CC
) -E
$(ALL_CFLAGS
) $(CPPFLAGS
) -o
$@
$<
95 sparrow_gamma_lut.h
: gamma.py
98 sparrow_false_colour_lut.h
: false_colour.py
101 gstsparrow.c
: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
103 sparrow.c
: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
105 GST_LAUNCH
= gst-launch-0.10
107 TEST_GST_ARGS
= --gst-plugin-path
=.
--gst-debug
=sparrow
:$(DEBUG_LEVEL
)
108 TEST_INPUT_SIZE
= width
=320,height
=240
109 TEST_OUTPUT_SIZE
= width
=320,height
=240
110 TEST_V4L2_SHAPE
= 'video/x-raw-yuv,format=(fourcc)YUY2,$(TEST_INPUT_SIZE),framerate=25/1'
111 TEST_OUTPUT_SHAPE
= 'video/x-raw-rgb,$(TEST_OUTPUT_SIZE),framerate=25/1'
112 TEST_SINK
= ximagesink
113 #TEST_SINK = fbdevsink
114 TEST_PIPE_TAIL
= ffmpegcolorspace
! sparrow
$(TEST_OPTIONS
) ! $(TEST_OUTPUT_SHAPE
) ! $(TEST_SINK
)
115 TEST_V4L2_PIPE_TAIL
= $(TEST_V4L2_SHAPE
) ! $(TEST_PIPE_TAIL
)
118 $(GST_LAUNCH
) $(TEST_GST_ARGS
) v4l2src
! $(TEST_V4L2_PIPE_TAIL
)
121 GST_DEBUG
=sparrow
:$(DEBUG_LEVEL
) .
/gtk-app
2> /tmp
/gst.log || less
-R
/tmp
/gst.log
124 valgrind
--log-file
=valgrind.log
--trace-children
=yes
--suppressions
=valgrind-python.supp \
125 $(GST_LAUNCH
) $(TEST_GST_ARGS
) v4l2src
! $(TEST_V4L2_PIPE_TAIL
) 2> gst.log
128 echo
"set args $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)" > /tmp
/gdb-args.txt
129 gdb
-x
/tmp
/gdb-args.txt
$(GST_LAUNCH
)
132 timeout
-3 20 time
-v
$(GST_LAUNCH
) $(TEST_GST_ARGS
) v4l2src
! $(TEST_V4L2_PIPE_TAIL
)
135 $(GST_LAUNCH
) $(TEST_GST_ARGS
) v4l2src
! $(TEST_V4L2_PIPE_TAIL
)
138 GST_DEBUG
=sparrow
:5 \
139 $(GST_LAUNCH
) $(TEST_GST_ARGS
) videotestsrc
! $(TEST_V4L2_PIPE_TAIL
)
141 TEST_VIDEO_FILE
=/home
/douglas
/media
/video
/rochester-pal.avi
142 #TEST_VIDEO_FILE=/home/douglas/tv/newartland_2008_ep2_ps6313_part3.flv
145 $(GST_LAUNCH
) $(TEST_GST_ARGS
) \
146 filesrc location
=$(TEST_VIDEO_FILE
) ! decodebin2
! $(TEST_PIPE_TAIL
)
149 gst-inspect
$(TEST_GST_ARGS
) sparrow
$(TEST_OPTIONS
)
152 #show filtered and unfiltered video side by side
154 $(GST_LAUNCH
) $(TEST_GST_ARGS
) v4l2src
! ffmpegcolorspace
! tee name
=vid2 \
155 ! queue
! sparrow
$(TEST_OPTIONS
) ! $(TEST_OUTPUT_SHAPE
) ! $(TEST_SINK
) \
156 vid2.
! queue
! sparrow
$(TEST_OPTIONS
) ! $(TEST_OUTPUT_SHAPE
) ! $(TEST_SINK
)
161 # find -name "*.[ch]" | xargs etags -a
162 etags
-R
--exclude
=junk
--exclude
=.git
--exclude
=prof
166 cscope
-b
$(shell echo
"$(INCLUDES)" | sed s
/-isystem
/-I
/)
169 CPROTO_INCLUDES
= $(shell echo
"$(INCLUDES)" | sed s
/-isystem
/-I
/)
172 # cproto $(INCLUDES) -DUNUSED='' -S -i -X 0 *.c
173 cproto
$(CPROTO_INCLUDES
) -DUNUSED
='' $(DEFINES
) -S
-X
0 *.c
176 cproto
$(CPROTO_INCLUDES
) -DUNUSED
='' $(DEFINES
) -X
0 *.c
180 # sudo opcontrol --no-vmlinux $(OP_OPTS) && sudo opcontrol $(OP_OPTS) --start --verbose
181 # timeout -3 10 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_SHAPE) ! ffmpegcolorspace \
182 # ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
183 # opreport $(OP_OPTS)
186 lsmod | grep
-q
'sysprof_module' || sudo modprobe sysprof-module || \
187 echo
"try again after 'sudo m-a a-i sysprof-module-source'"
189 @echo
"click the start button!"
192 splint
$(INCLUDES
) sparrow.c
197 $(CC
) -MD
$(ALL_CFLAGS
) $(CPPFLAGS
) -o
test test.c
201 $(CC
) -MD
$(ALL_CFLAGS
) $(CPPFLAGS
) -o
test shift_test.c
204 CV_LINKS
= -lcv
-lcvaux
-lhighgui
207 $(CC
) -MD
$(ALL_CFLAGS
) $(CPPFLAGS
) $(CV_LINKS
) -o
test test-find-edge.c
211 $(CC
) -MD
$(ALL_CFLAGS
) $(CPPFLAGS
) $(CV_LINKS
) -o
test test-median.c
214 unittest-jpeg
: gstsparrow.o sparrow.o calibrate.o play.o floodfill.o edges.o dSFMT
/dSFMT.o jpeg_src.o
215 $(CC
) -MD
$(ALL_CFLAGS
) $(CPPFLAGS
) $(LINKS
) -o
test $^
$(JPEG_STATIC
) test-jpeg.c
220 make
-B CFLAGS
='-g -fno-inline -fno-inline-functions -fno-omit-frame-pointer'
224 make
-B CFLAGS
='-lccmalloc -g' CC
='ccmalloc --nowrapper gcc'
227 rsync
-t
$(shell git ls-tree
-r
--name-only HEAD
) 10.42.43.10:sparrow
230 .PHONY
: TAGS
all cproto cproto-nonstatic sysprof splint unittest unittest-shifts unittest-edges \
231 debug ccmalloc rsync app-clean
234 GTK_LINKS
= -lglib-2.0
$(LINKS
) -lgstinterfaces-0.10
235 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
/
236 CLUTTER_SRC
= clutter-app.c
237 CLUTTER_LINKS
= -lclutter-gst-0.10
-lglib-2.0
240 $(CC
) $(ALL_CFLAGS
) $(CPPFLAGS
) $(CV_LINKS
) $(INCLUDES
) $(GTK_INCLUDES
)\
241 $(GTK_LINKS
) -o
$@
$(GTK_APP
)
244 $(GST_LAUNCH
) -o sparrow.xml
$(TEST_GST_ARGS
) v4l2src
! $(TEST_V4L2_PIPE_TAIL
)
247 $(CC
) $(ALL_CFLAGS
) $(CPPFLAGS
) $(CLUTTER_LINKS
) $(CLUTTER_INCLUDES
)\
248 $(LINKS
) -o
$@
$(CLUTTER_SRC
)
251 $(RM
) gtk-app clutter-app
253 #ffmpeg -i sparrow-yadif-scale.avi -vcodec copy jpg/x%06d.jpg