3 if [ -x "`which gmake`" ]; then
9 for v in OBJDIR CPATH EXTRA_LIBS \
10 HAVE_ALSA HAVE_DVB HAVE_ESOUND HAVE_FIREWIRE HAVE_DV \
11 HAVE_OSS HAVE_XFT HAVE_VIDEO4LINUX HAVE_VIDEO4LINUX2 ; do
12 eval export "$v=\"`$MAKE -s val-$v`\""
15 if [ "$1" = "static" ]; then
17 elif [ "$1" = "shared" ]; then
19 elif [ "$1" = "cv" ]; then
21 libs="libogg libtheora libvorbis openexr libdv libjpeg tiff x264 mjpegtools a52dec lame libsndfile faac faad2"
22 forced_libs="mjpegtools x264"
24 echo "usage: $0 <static | shared | cv>"
30 echo "configuring thirdparty library build"
32 echo "required libraries:"
44 [ $var = $value ] && return 0
60 inc_audiofile="libaudiofile"
61 add_library audiofile \
62 libaudiofile/.libs/libaudiofile.a \
63 libaudiofile/modules/.libs/libmodules.a \
64 libaudiofile/alac/.libs/libalac.a
68 if [ "$HAVE_ESOUND" = "y" ]; then
76 libfaac/.libs/libfaac.a \
77 common/mp4v2/libmp4v2.a
80 libfaad/.libs/libfaad.a \
81 common/mp4ff/libmp4ff.a
82 # fdk replaces faac/faad2, but is experimental...
83 inc_fdk="libAACdec/include libAACenc/include libSYS/include"
87 add_library festival \
91 libavutil/libavutil.a \
92 libavcodec/libavcodec.a \
93 libpostproc/libpostproc.a \
94 libavdevice/libavdevice.a \
95 libavformat/libavformat.a \
96 libswscale/libswscale.a \
97 libavfilter/libavfilter.a \
98 libswresample/libswresample.a
102 libbench2/libbench2.a \
103 rdft/scalar/r2cb/.libs/librdft_scalar_r2cb.a \
104 rdft/scalar/r2r/.libs/librdft_scalar_r2r.a \
105 rdft/scalar/.libs/librdft_scalar.a \
106 rdft/scalar/r2cf/.libs/librdft_scalar_r2cf.a \
107 rdft/.libs/librdft.a \
109 reodft/.libs/libreodft.a \
110 dft/scalar/codelets/.libs/libdft_scalar_codelets.a \
111 dft/scalar/.libs/libdft_scalar.a \
113 kernel/.libs/libkernel.a \
114 simd-support/.libs/libsimd_support.a \
115 simd-support/.libs/libsimd_sse2_nonportable.a
118 src/libFLAC/.libs/libFLAC.a \
119 src/libFLAC++/.libs/libFLAC++.a \
120 src/share/utf8/.libs/libutf8.a \
121 src/share/replaygain_analysis/.libs/libreplaygain_analysis.a \
122 src/share/replaygain_synthesis/.libs/libreplaygain_synthesis.a \
123 src/share/grabbag/.libs/libgrabbag.a \
124 src/test_libs_common/.libs/libtest_libs_common.a
129 inc_ilmbase="Iex Half Imath config IlmThread"
130 add_library ilmbase \
132 IexMath/.libs/libIexMath.a \
133 Half/.libs/libHalf.a \
134 Imath/.libs/libImath.a \
135 IlmThread/.libs/libIlmThread.a
140 libmp3lame/.libs/libmp3lame.a \
141 mpglib/.libs/libmpgdecoder.a
142 if [ "$HAVE_FIREWIRE" = "y" ]; then
144 add_library libavc1394 \
145 libavc1394/.libs/libavc1394.a \
146 librom1394/.libs/librom1394.a \
147 common/.libs/libraw1394util.a
149 add_library libraw1394 \
150 src/.libs/libraw1394.a
151 inc_libiec61883="src"
152 add_library libiec61883 \
153 src/.libs/libiec61883.a
155 if [ "$HAVE_DV" = "y" ]; then
161 add_library libjpeg \
163 .libs/libturbojpeg.a \
165 inc_openjpeg="src/lib/openjp2"
166 add_library openjpeg \
172 add_library libsndfile \
173 src/.libs/libsndfile.a \
174 src/.libs/libcommon.a \
175 src/G72x/.libs/libg72x.a \
176 src/GSM610/.libs/libgsm.a
178 add_library libtheora \
179 lib/.libs/libtheora.a \
180 lib/.libs/libtheoradec.a \
181 lib/.libs/libtheoraenc.a
183 add_library libuuid \
185 inc_libvorbis="include ."
186 add_library libvorbis \
187 lib/.libs/libvorbis.a \
188 lib/.libs/libvorbisenc.a \
189 lib/.libs/libvorbisfile.a
190 inc_mjpegtools=". lavtools utils"
191 add_library mjpegtools \
192 utils/mmxsse/.libs/libmmxsse.a \
193 utils/.libs/libmjpegutils.a \
194 lavtools/.libs/liblavfile.a \
195 lavtools/.libs/liblavjpeg.a \
196 yuvfilters/.libs/libyuvfilters.a \
197 mpeg2enc/.libs/libmpeg2encpp.a \
198 mplex/.libs/libmplex2.a
199 inc_openexr="IlmImf config"
200 add_library openexr \
201 IlmImf/.libs/libIlmImf.a \
202 IlmImfUtil/.libs/libIlmImfUtil.a
204 add_library speech_tools \
210 libtiff/.libs/libtiff.a \
211 libtiff/.libs/libtiffxx.a \
213 inc_twolame="libtwolame"
214 add_library twolame \
215 libtwolame/.libs/libtwolame.a
227 if [ -n "$libs" ]; then
234 if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
236 if [ $((n % 8)) != 0 ]; then echo ""; fi
239 # dynamic library paths
241 if ! `echo $LIBS | grep -qw $1`; then return 0; fi
243 if [ -n "${!name}" ]; then return 0; fi
248 : ${TMPDIR:=$TEMPDIR}
252 local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
253 trap "rm -f -- ${exe}" EXIT
256 for hdr in $headers; do
257 test "${hdr%.h}" = "${hdr}" &&
258 echo "#include $hdr" ||
259 echo "#include <$hdr>"
261 for func in $func; do
262 echo "long check_$func(void) { return (long) $func; }"
264 echo "int main(void) { return 0; }"
265 } | cc -x c - -o $exe $@ $EXTRA_LIBS >& /dev/null
268 if [ $ret = 0 ]; then
269 eval $name=\"shared $*\"
270 echo "exists shared $name"
273 local sta_libs=sta_$name
274 eval $name=\"static ${!sta_libs}\"
275 echo "build static $name"
279 # test for shared libs/header files
280 probe a52dec "a52.h" a52_init -la52
281 probe audiofile "audiofile.h" afOpenFile -laudiofile
282 probe faac "stdint.h faac.h" faacEncGetVersion -lfaac
283 probe faad2 "faad.h" NeAACDecInit -lfaad
284 # dont build festival in shared build
285 if [ "$STATIC_LIBRARIES" = "n" ]; then festival="shared"; fi
286 if [ "$STATIC_LIBRARIES" = "n" ]; then speech_tools="shared"; fi
287 probe fftw "fftw3.h" fftw_execute -lfftw3
288 probe flac "FLAC/stream_decoder.h" FLAC__stream_decoder_new -lFLAC
289 probe lame "lame/lame.h" hip_decode_init -lmp3lame
290 probe libavc1394 "libavc1394/avc1394.h librom1394/rom1394.h" avc1394_init_target -lavc1394
291 probe libdv "libdv/dv.h" dv_init -ldv
292 probe libiec61883 "libiec61883/iec61883.h" iec61883_mpeg2_recv_init -liec61883
293 probe libjpeg "stdio.h unistd.h jpeglib.h" jpeg_start_decompress -ljpeg
294 probe libogg "ogg/ogg.h" ogg_stream_init -logg
295 probe openjpeg "openjpeg.h" opj_version -lopenjp2 -DOPJ_STATIC || \
296 probe openjpeg "openjpeg-1.5/openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC || \
297 probe openjpeg "openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC
298 probe libraw1394 "libraw1394/raw1394.h" raw1394_iso_recv_init -lraw1394
299 probe libsndfile "sndfile.h" sf_open -lsndfile
300 probe ilmbase "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
301 probe openexr "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
302 probe libtheora "theora/theoraenc.h" th_info_init -ltheora -ltheoraenc -ltheoradec -logg
303 probe libvorbis "vorbis/vorbisenc.h" vorbis_info_init -lvorbisenc -lvorbis -lvorbisfile -logg
304 probe libvpx "vpx/vpx_decoder.h" vpx_codec_decode -lvpx
305 probe tiff "tiff.h tiffio.h" TIFFOpen -ltiff
306 probe twolame "twolame.h" twolame_encode_buffer_float32_interleaved -ltwolame
307 probe x264 "stdint.h x264.h" x264_encoder_encode -lx264
308 probe x265 "x265.h" x265_encoder_encode -lx265
310 forced_libs="$forced_libs a52dec encore ffmpeg giflib libuuid openjpeg"
312 # for ffmpeg link/broken disto libs
313 for name in $LIBS; do
314 if is_in $name $forced_libs; then
318 if [ "$typ" = "shared" ]; then
319 echo "warn: $name forced static"
321 eval $name=\"static ${!sta_libs}\"
326 # add dependencies (order matters)
328 ffmpeg/faac ffmpeg/faad2 ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
329 ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/fdk \
330 libiec61883/libraw1394 libavc1394/librom1394 \
331 openexr/ilmbase ilmbase/libogg \
332 libtheora/libogg libtheora/libvorbis ; do
335 if is_in $lib $shared; then
336 if is_in $needs $shared; then continue; fi
337 if is_in $needs $static; then
338 echo warn: shared $lib using static $needs
343 if is_in $lib $static; then
344 if is_in $needs $static; then continue; fi
345 if is_in $needs $shared; then
346 echo warn: static $lib using shared $needs
354 # check for static libs which may conflicting header files
355 if [ "$STATIC_LIBRARIES" = "y" ]; then
356 for name in $LIBS; do
360 if [ "$typ" = "shared" ]; then
361 echo "warn: $name is shared and static"
364 eval $name=\"static ${!sta_libs}\"
368 # any unknowns are static
369 for name in $LIBS; do
370 if [ -z "${!name}" ]; then
372 eval $name=\"static ${!sta_libs}\"
376 # dont build festival
378 speech_tools="shared"
388 echo "thirdparty :=$LIBS" > config.mak
389 echo "shared_libs :=$shared" >> config.mak
390 echo "static_libs :=$static" >> config.mak
393 echo "$lib := ${!lib}"
395 echo "inc_$lib := ${!inc_lib}"
399 # translate config.mak into libs/incs
401 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
402 lib_static=$(call pkg_path,$(1))/$(2)
404 inc_static=-I$(1)/$(2)
406 lib_typ=$(firstword $(1))
407 lib_refs=$(wordlist 2,$(words $(1)),$(1))
409 $(foreach lib,$(thirdparty), \
410 $(eval pkg_$(lib) := $(call pkg_path,$(lib))) \
411 $(eval typ_$(lib) := $(call lib_typ,$($(lib)))) \
412 $(eval lib_$(lib) := \
413 $(foreach ref, $(call lib_refs,$($(lib))), \
414 $(call lib_$(typ_$(lib)),$(lib),$(ref)))) \
415 $(eval inc_$(lib) := \
416 $(foreach inc, $(inc_$(lib)), \
417 $(call inc_$(typ_$(lib)),$(pkg_$(lib)),$(inc)))))
420 ifeq ($(MAKECMDGOALS),list)
421 $(foreach lib,$(thirdparty),$(info $(lib) := $(typ_$(lib)) $(pkg_$(lib))) \
422 $(foreach ref,$(lib_$(lib)), $(info == $(ref))) \
423 $(foreach ref,$(inc_$(lib)), $(info -- $(ref))))
429 static_includes := $(foreach lib,$(static_libs), $(inc_$(lib)))
430 static_libraries := $(foreach lib,$(static_libs),$(lib_$(lib)))
431 shared_libraries := $(foreach lib,$(shared_libs),$(lib_$(lib)))
432 thirdparty_libraries := $(static_libraries) $(shared_libraries)