get jpeg loading (but not reading) working
[sparrow.git] / Makefile
blobdfead89c9bbed9b7f0f9108458da86e42508de0c
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 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
30 # -fvisibility=hidden
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
39 CC = gcc
40 AR = ar
41 INSTALL = install
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
68 OBJECTS = gstsparrow.o sparrow.o calibrate.o play.o floodfill.o edges.o dSFMT/dSFMT.o jpeg_src.o load_images.o
70 all:: libgstsparrow.so
72 libgstsparrow.so: $(OBJECTS)
73 $(CC) -shared -Wl,-O1 $+ $(GST_PLUGIN_LDFLAGS) $(INCLUDES) $(DEFINES) $(LINKS) -Wl,-soname -Wl,$@ \
74 -o $@
76 clean:
77 rm -f *.so *.o *.a *.d *.s
78 cd dSFMT && rm -f *.o *.s
79 rm -f sparrow_false_colour_lut.h sparrow_gamma_lut.h
81 dSFMT/dSFMT.o: dSFMT/dSFMT.c
82 $(CC) $(DSFMT_FLAGS) -MD $(ALL_CFLAGS) -fvisibility=hidden $(CPPFLAGS) -c -o $@ $<
84 .c.o:
85 # @echo $(CPATH)
86 # @echo $(LIBRARY_PATH)
87 $(CC) -c -MD $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
88 # $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) -MD $<
90 %.s: %.c
91 $(CC) -S $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
93 %.i: %.c
94 $(CC) -E $(ALL_CFLAGS) $(CPPFLAGS) -o $@ $<
96 sparrow_gamma_lut.h: gamma.py
97 python $< > $@
99 sparrow_false_colour_lut.h: false_colour.py
100 python $< > $@
102 gstsparrow.c: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
104 sparrow.c: sparrow_gamma_lut.h gstsparrow.h sparrow_false_colour_lut.h sparrow.h
106 GST_LAUNCH = gst-launch-0.10
107 DEBUG_LEVEL = 5
108 TEST_GST_ARGS = --gst-plugin-path=. --gst-debug=sparrow:$(DEBUG_LEVEL)
109 TEST_INPUT_SIZE = width=320,height=240
110 TEST_OUTPUT_SIZE = width=320,height=240
111 TEST_V4L2_SHAPE = 'video/x-raw-yuv,format=(fourcc)YUY2,$(TEST_INPUT_SIZE),framerate=25/1'
112 TEST_OUTPUT_SHAPE = 'video/x-raw-rgb,$(TEST_OUTPUT_SIZE),framerate=25/1'
113 TEST_SINK = ximagesink
114 #TEST_SINK = fbdevsink
115 TEST_PIPE_TAIL = ffmpegcolorspace ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
116 TEST_V4L2_PIPE_TAIL = $(TEST_V4L2_SHAPE) ! $(TEST_PIPE_TAIL)
118 test: all
119 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
121 test-gtk: all
122 GST_DEBUG=sparrow:$(DEBUG_LEVEL) ./gtk-app 2> /tmp/gst.log || less -R /tmp/gst.log
124 test-valgrind: debug
125 valgrind --log-file=valgrind.log --trace-children=yes --suppressions=valgrind-python.supp \
126 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL) 2> gst.log
128 test-gdb: debug
129 echo "set args $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)" > /tmp/gdb-args.txt
130 gdb -x /tmp/gdb-args.txt $(GST_LAUNCH)
132 test-times: all
133 timeout -3 20 time -v $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
135 test-cam:
136 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
138 test-pattern: all
139 GST_DEBUG=sparrow:5 \
140 $(GST_LAUNCH) $(TEST_GST_ARGS) videotestsrc ! $(TEST_V4L2_PIPE_TAIL)
142 TEST_VIDEO_FILE=/home/douglas/media/video/rochester-pal.avi
143 #TEST_VIDEO_FILE=/home/douglas/tv/newartland_2008_ep2_ps6313_part3.flv
145 test-file: all
146 $(GST_LAUNCH) $(TEST_GST_ARGS) \
147 filesrc location=$(TEST_VIDEO_FILE) ! decodebin2 ! $(TEST_PIPE_TAIL)
149 inspect: all
150 gst-inspect $(TEST_GST_ARGS) sparrow $(TEST_OPTIONS)
153 #show filtered and unfiltered video side by side
154 test-tee: all
155 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! ffmpegcolorspace ! tee name=vid2 \
156 ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK) \
157 vid2. ! queue ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
160 TAGS:
161 $(RM) TAGS
162 # find -name "*.[ch]" | xargs etags -a
163 etags -R --exclude=junk --exclude=.git --exclude=prof
165 cscope:
166 $(RM) cscope.out
167 cscope -b $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
170 CPROTO_INCLUDES = $(shell echo "$(INCLUDES)" | sed s/-isystem/-I/)
172 cproto:
173 # cproto $(INCLUDES) -DUNUSED='' -S -i -X 0 *.c
174 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -S -X 0 *.c
176 cproto-nonstatic:
177 cproto $(CPROTO_INCLUDES) -DUNUSED='' $(DEFINES) -X 0 *.c
180 #oprofile: all
181 # sudo opcontrol --no-vmlinux $(OP_OPTS) && sudo opcontrol $(OP_OPTS) --start --verbose
182 # timeout -3 10 $(GST_LAUNCH) $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_SHAPE) ! ffmpegcolorspace \
183 # ! sparrow $(TEST_OPTIONS) ! $(TEST_OUTPUT_SHAPE) ! $(TEST_SINK)
184 # opreport $(OP_OPTS)
186 sysprof: debug
187 lsmod | grep -q 'sysprof_module' || sudo modprobe sysprof-module || \
188 echo "try again after 'sudo m-a a-i sysprof-module-source'"
189 sysprof &
190 @echo "click the start button!"
192 splint:
193 splint $(INCLUDES) sparrow.c
194 flawfinder $(PWD)
197 unittest:
198 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test test.c
199 ./test
201 unittest-shifts:
202 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) -o test shift_test.c
203 ./test
205 CV_LINKS = -lcv -lcvaux -lhighgui
207 unittest-edges:
208 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-find-edge.c
209 ./test
211 unittest-median:
212 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) -o test test-median.c
213 ./test
215 unittest-jpeg: gstsparrow.o sparrow.o calibrate.o play.o floodfill.o edges.o dSFMT/dSFMT.o jpeg_src.o
216 $(CC) -MD $(ALL_CFLAGS) $(CPPFLAGS) $(LINKS) -o test $^ $(JPEG_STATIC) test-jpeg.c
218 #./test
220 debug:
221 make -B CFLAGS='-g -fno-inline -fno-inline-functions -fno-omit-frame-pointer'
223 #ccmalloc
224 ccmalloc:
225 make -B CFLAGS='-lccmalloc -g' CC='ccmalloc --nowrapper gcc'
227 rsync:
228 rsync -t $(shell git ls-tree -r --name-only HEAD) 10.42.43.10:sparrow
231 .PHONY: TAGS all cproto cproto-nonstatic sysprof splint unittest unittest-shifts unittest-edges \
232 debug ccmalloc rsync app-clean
234 GTK_APP = gtk-app.c
235 GTK_LINKS = -lglib-2.0 $(LINKS) -lgstinterfaces-0.10
236 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/
237 CLUTTER_SRC = clutter-app.c
238 CLUTTER_LINKS = -lclutter-gst-0.10 -lglib-2.0
239 GTK_CLUTTER_LINKS = $(LINKS) -lgstinterfaces-0.10 -lclutter-gst-0.10 -lglib-2.0 -lclutter-gtk-0.10
240 GTK_CLUTTER_INCLUDES = $(GTK_INCLUDES) $(CLUTTER_INCLUDES)
242 gtk-app::
243 $(CC) $(ALL_CFLAGS) $(CPPFLAGS) $(CV_LINKS) $(INCLUDES) $(GTK_INCLUDES)\
244 $(GTK_LINKS) -o $@ $(GTK_APP)
246 gtk-clutter-app::
247 $(CC) $(ALL_CFLAGS) $(CPPFLAGS) $(GTK_CLUTTER_LINKS) $(INCLUDES) $(GTK_CLUTTER_INCLUDES) \
248 -o $@ gtk-clutter-app.c
250 sparrow.xml::
251 $(GST_LAUNCH) -o sparrow.xml $(TEST_GST_ARGS) v4l2src ! $(TEST_V4L2_PIPE_TAIL)
253 clutter-app:
254 $(CC) $(ALL_CFLAGS) $(CPPFLAGS) $(CLUTTER_LINKS) $(CLUTTER_INCLUDES)\
255 $(LINKS) -o $@ $(CLUTTER_SRC)
257 app-clean:
258 $(RM) gtk-app clutter-app
260 #ffmpeg -i sparrow-yadif-scale.avi -vcodec copy jpg/x%06d.jpg