3 if [ -x "`which gmake`" ]; then
9 for v in OBJDIR CPATH EXTRA_LIBS HAVE_LADSPA \
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
136 if [ "$HAVE_LADSPA" = "y" ]; then
142 libmp3lame/.libs/libmp3lame.a \
143 mpglib/.libs/libmpgdecoder.a
144 if [ "$HAVE_FIREWIRE" = "y" ]; then
146 add_library libavc1394 \
147 libavc1394/.libs/libavc1394.a \
148 librom1394/.libs/librom1394.a \
149 common/.libs/libraw1394util.a
151 add_library libraw1394 \
152 src/.libs/libraw1394.a
153 inc_libiec61883="src"
154 add_library libiec61883 \
155 src/.libs/libiec61883.a
157 if [ "$HAVE_DV" = "y" ]; then
163 add_library libjpeg \
165 .libs/libturbojpeg.a \
167 inc_openjpeg="src/lib/openjp2"
168 add_library openjpeg \
174 add_library libsndfile \
175 src/.libs/libsndfile.a \
176 src/.libs/libcommon.a \
177 src/G72x/.libs/libg72x.a \
178 src/GSM610/.libs/libgsm.a
180 add_library libtheora \
181 lib/.libs/libtheora.a \
182 lib/.libs/libtheoradec.a \
183 lib/.libs/libtheoraenc.a
185 add_library libuuid \
187 inc_libvorbis="include ."
188 add_library libvorbis \
189 lib/.libs/libvorbis.a \
190 lib/.libs/libvorbisenc.a \
191 lib/.libs/libvorbisfile.a
192 inc_mjpegtools=". lavtools utils"
193 add_library mjpegtools \
194 utils/mmxsse/.libs/libmmxsse.a \
195 utils/.libs/libmjpegutils.a \
196 lavtools/.libs/liblavfile.a \
197 lavtools/.libs/liblavjpeg.a \
198 yuvfilters/.libs/libyuvfilters.a \
199 mpeg2enc/.libs/libmpeg2encpp.a \
200 mplex/.libs/libmplex2.a
201 inc_openexr="IlmImf config"
202 add_library openexr \
203 IlmImf/.libs/libIlmImf.a \
204 IlmImfUtil/.libs/libIlmImfUtil.a
206 add_library speech_tools \
212 libtiff/.libs/libtiff.a \
213 libtiff/.libs/libtiffxx.a \
215 inc_twolame="libtwolame"
216 add_library twolame \
217 libtwolame/.libs/libtwolame.a
229 if [ -n "$libs" ]; then
236 if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
238 if [ $((n % 8)) != 0 ]; then echo ""; fi
241 # dynamic library paths
243 if ! `echo $LIBS | grep -qw $1`; then return 0; fi
245 if [ -n "${!name}" ]; then return 0; fi
250 : ${TMPDIR:=$TEMPDIR}
254 local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
255 trap "rm -f -- ${exe}" EXIT
258 for hdr in $headers; do
259 test "${hdr%.h}" = "${hdr}" &&
260 echo "#include $hdr" ||
261 echo "#include <$hdr>"
263 for func in $func; do
264 echo "long check_$func(void) { return (long) $func; }"
266 echo "int main(void) { return 0; }"
267 } | cc -x c - -o $exe $@ $EXTRA_LIBS >& /dev/null
270 if [ $ret = 0 ]; then
271 eval $name=\"shared $*\"
272 echo "exists shared $name"
275 local sta_libs=sta_$name
276 eval $name=\"static ${!sta_libs}\"
277 echo "build static $name"
281 # test for shared libs/header files
282 probe a52dec "a52.h" a52_init -la52
283 probe audiofile "audiofile.h" afOpenFile -laudiofile
284 probe faac "stdint.h faac.h" faacEncGetVersion -lfaac
285 probe faad2 "faad.h" NeAACDecInit -lfaad
286 # dont build festival in shared build
287 if [ "$STATIC_LIBRARIES" = "n" ]; then festival="shared"; fi
288 if [ "$STATIC_LIBRARIES" = "n" ]; then speech_tools="shared"; fi
289 probe fftw "fftw3.h" fftw_execute -lfftw3
290 probe flac "FLAC/stream_decoder.h" FLAC__stream_decoder_new -lFLAC
291 probe lame "lame/lame.h" hip_decode_init -lmp3lame
292 probe libavc1394 "libavc1394/avc1394.h librom1394/rom1394.h" avc1394_init_target -lavc1394
293 probe libdv "libdv/dv.h" dv_init -ldv
294 probe libiec61883 "libiec61883/iec61883.h" iec61883_mpeg2_recv_init -liec61883
295 probe libjpeg "stdio.h unistd.h jpeglib.h" jpeg_start_decompress -ljpeg
296 probe libogg "ogg/ogg.h" ogg_stream_init -logg
297 probe openjpeg "openjpeg.h" opj_version -lopenjp2 -DOPJ_STATIC || \
298 probe openjpeg "openjpeg-1.5/openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC || \
299 probe openjpeg "openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC
300 probe libraw1394 "libraw1394/raw1394.h" raw1394_iso_recv_init -lraw1394
301 probe libsndfile "sndfile.h" sf_open -lsndfile
302 probe ilmbase "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
303 probe openexr "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
304 probe libtheora "theora/theoraenc.h" th_info_init -ltheora -ltheoraenc -ltheoradec -logg
305 probe libvorbis "vorbis/vorbisenc.h" vorbis_info_init -lvorbisenc -lvorbis -lvorbisfile -logg
306 probe libvpx "vpx/vpx_decoder.h" vpx_codec_decode -lvpx
307 probe tiff "tiff.h tiffio.h" TIFFOpen -ltiff
308 probe twolame "twolame.h" twolame_encode_buffer_float32_interleaved -ltwolame
309 probe x264 "stdint.h x264.h" x264_encoder_encode -lx264
310 probe x265 "x265.h" x265_encoder_encode -lx265
312 forced_libs="$forced_libs a52dec encore ffmpeg giflib libuuid openjpeg"
314 # for ffmpeg link/broken disto libs
315 for name in $LIBS; do
316 if is_in $name $forced_libs; then
320 if [ "$typ" = "shared" ]; then
321 echo "warn: $name forced static"
323 eval $name=\"static ${!sta_libs}\"
328 # add dependencies (order matters)
330 ffmpeg/faac ffmpeg/faad2 ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
331 ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/fdk \
332 libiec61883/libraw1394 libavc1394/librom1394 \
333 openexr/ilmbase ilmbase/libogg \
334 libtheora/libogg libtheora/libvorbis ; do
337 if is_in $lib $shared; then
338 if is_in $needs $shared; then continue; fi
339 if is_in $needs $static; then
340 echo warn: shared $lib using static $needs
345 if is_in $lib $static; then
346 if is_in $needs $static; then continue; fi
347 if is_in $needs $shared; then
348 echo warn: static $lib using shared $needs
356 # check for static libs which may conflicting header files
357 if [ "$STATIC_LIBRARIES" = "y" ]; then
358 for name in $LIBS; do
362 if [ "$typ" = "shared" ]; then
363 echo "warn: $name is shared and static"
366 eval $name=\"static ${!sta_libs}\"
370 # any unknowns are static
371 for name in $LIBS; do
372 if [ -z "${!name}" ]; then
374 eval $name=\"static ${!sta_libs}\"
378 # dont build festival
380 speech_tools="shared"
390 echo "thirdparty :=$LIBS" > config.mak
391 echo "shared_libs :=$shared" >> config.mak
392 echo "static_libs :=$static" >> config.mak
395 echo "$lib := ${!lib}"
397 echo "inc_$lib := ${!inc_lib}"
401 # translate config.mak into libs/incs
403 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
404 lib_static=$(call pkg_path,$(1))/$(2)
406 inc_static=-I$(1)/$(2)
408 lib_typ=$(firstword $(1))
409 lib_refs=$(wordlist 2,$(words $(1)),$(1))
411 $(foreach lib,$(thirdparty), \
412 $(eval pkg_$(lib) := $(call pkg_path,$(lib))) \
413 $(eval typ_$(lib) := $(call lib_typ,$($(lib)))) \
414 $(eval lib_$(lib) := \
415 $(foreach ref, $(call lib_refs,$($(lib))), \
416 $(call lib_$(typ_$(lib)),$(lib),$(ref)))) \
417 $(eval inc_$(lib) := \
418 $(foreach inc, $(inc_$(lib)), \
419 $(call inc_$(typ_$(lib)),$(pkg_$(lib)),$(inc)))))
422 ifeq ($(MAKECMDGOALS),list)
423 $(foreach lib,$(thirdparty),$(info $(lib) := $(typ_$(lib)) $(pkg_$(lib))) \
424 $(foreach ref,$(lib_$(lib)), $(info == $(ref))) \
425 $(foreach ref,$(inc_$(lib)), $(info -- $(ref))))
431 static_includes := $(foreach lib,$(static_libs), $(inc_$(lib)))
432 static_libraries := $(foreach lib,$(static_libs),$(lib_$(lib)))
433 shared_libraries := $(foreach lib,$(shared_libs),$(lib_$(lib)))
434 thirdparty_libraries := $(static_libraries) $(shared_libraries)