3 if [ "$1" = "static" ]; then
5 elif [ "$1" = "shared" ]; then
7 elif [ "$1" = "cv" ]; then
9 libs="libogg libtheora libvorbis openexr libdv libjpeg tiff x264 mjpegtools a52dec lame libsndfile faac faad2"
10 forced_libs="mjpegtools x264"
12 echo "usage: $0 <static | shared | cv>"
18 echo "configuring thirdparty library build"
20 echo "required libraries:"
32 [ $var = $value ] && return 0
49 add_library audiofile \
50 libaudiofile/.libs/libaudiofile.a \
51 libaudiofile/modules/.libs/libmodules.a \
52 libaudiofile/alac/.libs/libalac.a
55 `uname -m`/libencore.a
62 libfaac/.libs/libfaac.a \
63 common/mp4v2/libmp4v2.a
66 libfaad/.libs/libfaad.a \
67 common/mp4ff/libmp4ff.a
68 # fdk replaces faac/faad2, but is experimental...
69 inc_fdk="libAACdec/include libAACenc/include libSYS/include"
73 add_library festival \
77 libavutil/libavutil.a \
78 libavcodec/libavcodec.a \
79 libpostproc/libpostproc.a \
80 libavdevice/libavdevice.a \
81 libavformat/libavformat.a \
82 libswscale/libswscale.a \
83 libavfilter/libavfilter.a \
84 libswresample/libswresample.a
88 libbench2/libbench2.a \
89 rdft/scalar/r2cb/.libs/librdft_scalar_r2cb.a \
90 rdft/scalar/r2r/.libs/librdft_scalar_r2r.a \
91 rdft/scalar/.libs/librdft_scalar.a \
92 rdft/scalar/r2cf/.libs/librdft_scalar_r2cf.a \
93 rdft/.libs/librdft.a \
95 reodft/.libs/libreodft.a \
96 dft/scalar/codelets/.libs/libdft_scalar_codelets.a \
97 dft/scalar/.libs/libdft_scalar.a \
99 kernel/.libs/libkernel.a \
100 simd-support/.libs/libsimd_support.a \
101 simd-support/.libs/libsimd_sse2_nonportable.a
104 src/libFLAC/.libs/libFLAC.a \
105 src/libFLAC++/.libs/libFLAC++.a \
106 src/share/utf8/.libs/libutf8.a \
107 src/share/replaygain_analysis/.libs/libreplaygain_analysis.a \
108 src/share/replaygain_synthesis/.libs/libreplaygain_synthesis.a \
109 src/share/grabbag/.libs/libgrabbag.a \
110 src/test_libs_common/.libs/libtest_libs_common.a
115 inc_ilmbase="Iex Half Imath config IlmThread"
116 add_library ilmbase \
118 IexMath/.libs/libIexMath.a \
119 Half/.libs/libHalf.a \
120 Imath/.libs/libImath.a \
121 IlmThread/.libs/libIlmThread.a
126 libmp3lame/.libs/libmp3lame.a \
127 mpglib/.libs/libmpgdecoder.a
129 add_library libavc1394 \
130 libavc1394/.libs/libavc1394.a \
131 librom1394/.libs/librom1394.a \
132 common/.libs/libraw1394util.a
136 inc_libiec61883="src"
137 add_library libiec61883 \
138 src/.libs/libiec61883.a
140 add_library libjpeg \
142 .libs/libturbojpeg.a \
144 inc_openjpeg="src/lib/openjp2"
145 add_library openjpeg \
151 add_library libraw1394 \
152 src/.libs/libraw1394.a
154 add_library libsndfile \
155 src/.libs/libsndfile.a \
156 src/.libs/libcommon.a \
157 src/G72x/.libs/libg72x.a \
158 src/GSM610/.libs/libgsm.a
160 add_library libtheora \
161 lib/.libs/libtheora.a \
162 lib/.libs/libtheoradec.a \
163 lib/.libs/libtheoraenc.a
165 add_library libuuid \
167 inc_libvorbis="include ."
168 add_library libvorbis \
169 lib/.libs/libvorbis.a \
170 lib/.libs/libvorbisenc.a \
171 lib/.libs/libvorbisfile.a
172 inc_mjpegtools=". lavtools utils"
173 add_library mjpegtools \
174 utils/mmxsse/.libs/libmmxsse.a \
175 utils/.libs/libmjpegutils.a \
176 lavtools/.libs/liblavfile.a \
177 lavtools/.libs/liblavjpeg.a \
178 yuvfilters/.libs/libyuvfilters.a \
179 mpeg2enc/.libs/libmpeg2encpp.a \
180 mplex/.libs/libmplex2.a
181 inc_openexr="IlmImf config"
182 add_library openexr \
183 IlmImf/.libs/libIlmImf.a \
184 IlmImfUtil/.libs/libIlmImfUtil.a
186 add_library speech_tools \
192 libtiff/.libs/libtiff.a \
193 libtiff/.libs/libtiffxx.a \
195 inc_twolame="libtwolame"
196 add_library twolame \
197 libtwolame/.libs/libtwolame.a
209 if [ -n "$libs" ]; then
216 if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
218 if [ $((n % 8)) != 0 ]; then echo ""; fi
221 # dynamic library paths
223 if ! `echo $LIBS | grep -qw $1`; then return 0; fi
229 : ${TMPDIR:=$TEMPDIR}
233 local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
234 trap "rm -f -- ${exe}" EXIT
237 for hdr in $headers; do
238 test "${hdr%.h}" = "${hdr}" &&
239 echo "#include $hdr" ||
240 echo "#include <$hdr>"
242 for func in $func; do
243 echo "long check_$func(void) { return (long) $func; }"
245 echo "int main(void) { return 0; }"
246 } | cc -x c - -o $exe $@ >& /dev/null
249 if [ $ret = 0 ]; then
250 eval $name=\"shared $*\"
251 echo "exists shared $name"
254 local sta_libs=sta_$name
255 eval $name=\"static ${!sta_libs}\"
256 echo "build static $name"
260 # test for shared libs/header files
261 probe a52dec "a52.h" a52_init -la52
262 probe audiofile "audiofile.h" afOpenFile -laudiofile
263 probe faac "stdint.h faac.h" faacEncGetVersion -lfaac
264 probe faad2 "faad.h" NeAACDecInit -lfaad
265 # dont build festival in shared build
266 if [ "$STATIC_LIBRARIES" = "n" ]; then festival="shared"; fi
267 if [ "$STATIC_LIBRARIES" = "n" ]; then speech_tools="shared"; fi
268 probe fftw "fftw3.h" fftw_execute -lfftw3
269 probe flac "FLAC/stream_decoder.h" FLAC__stream_decoder_new -lFLAC
270 probe lame "lame/lame.h" hip_decode_init -lmp3lame
271 probe libavc1394 "libavc1394/avc1394.h librom1394/rom1394.h" avc1394_init_target -lavc1394
272 probe libdv "libdv/dv.h" dv_init -ldv
273 probe libiec61883 "libiec61883/iec61883.h" iec61883_mpeg2_recv_init -liec61883
274 probe libjpeg "stdio.h unistd.h jpeglib.h" jpeg_start_decompress -ljpeg
275 probe libogg "ogg/ogg.h" ogg_stream_init -logg
276 probe openjpeg "openjpeg.h" opj_version -lopenjp2 -DOPJ_STATIC || \
277 probe openjpeg "openjpeg-1.5/openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC || \
278 probe openjpeg "openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC
279 probe libraw1394 "libraw1394/raw1394.h" raw1394_iso_recv_init -lraw1394
280 probe libsndfile "sndfile.h" sf_open -lsndfile
281 probe ilmbase "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
282 probe openexr "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
283 probe libtheora "theora/theoraenc.h" th_info_init -ltheora -ltheoraenc -ltheoradec -logg
284 probe libvorbis "vorbis/vorbisenc.h" vorbis_info_init -lvorbisenc -lvorbis -lvorbisfile -logg
285 probe libvpx "vpx/vpx_decoder.h" vpx_codec_decode -lvpx
286 probe tiff "tiff.h tiffio.h" TIFFOpen -ltiff
287 probe twolame "twolame.h" twolame_encode_buffer_float32_interleaved -ltwolame
288 probe x264 "stdint.h x264.h" x264_encoder_encode -lx264
289 probe x265 "x265.h" x265_encoder_encode -lx265
291 if [ -n "$forced_libs" ]; then
292 forced_libs="encore ffmpeg giflib libuuid"
295 # for ffmpeg link/broken disto libs
296 for name in $LIBS; do
297 if is_in $name $forced_libs; then
301 if [ "$typ" = "shared" ]; then
302 echo "warn: $name forced static"
304 eval $name=\"static ${!sta_libs}\"
309 # add dependencies (order matters)
311 ffmpeg/faac ffmpeg/faad2 ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
312 ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/fdk \
313 libiec61883/libraw1394 libavc1394/librom1394 \
314 openexr/ilmbase ilmbase/libogg \
315 libtheora/libogg libtheora/libvorbis ; do
318 if is_in $lib $shared; then
319 if is_in $needs $shared; then continue; fi
320 if is_in $needs $static; then
321 echo warn: shared $lib using static $needs
326 if is_in $lib $static; then
327 if is_in $needs $static; then continue; fi
328 if is_in $needs $shared; then
329 echo warn: static $lib using shared $needs
337 # check for static libs which may conflicting header files
338 if [ "$STATIC_LIBRARIES" = "y" ]; then
339 for name in $LIBS; do
343 if [ "$typ" = "shared" ]; then
344 echo "warn: $name is shared and static"
347 eval $name=\"static ${!sta_libs}\"
351 # any unknowns are static
352 for name in $LIBS; do
353 if [ -z "${!name}" ]; then
355 eval $name=\"static ${!sta_libs}\"
359 # dont build festival
361 speech_tools="shared"
371 echo "thirdparty :=$LIBS" > config.mak
372 echo "shared_libs :=$shared" >> config.mak
373 echo "static_libs :=$static" >> config.mak
376 echo "$lib := ${!lib}"
378 echo "inc_$lib := ${!inc_lib}"
382 # translate config.mak into libs/incs
384 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
385 lib_static=$(call pkg_path,$(1))/$(2)
387 inc_static=-I$(1)/$(2)
389 lib_typ=$(firstword $(1))
390 lib_refs=$(wordlist 2,$(words $(1)),$(1))
392 $(foreach lib,$(thirdparty), \
393 $(eval pkg_$(lib) := $(call pkg_path,$(lib))) \
394 $(eval typ_$(lib) := $(call lib_typ,$($(lib)))) \
395 $(eval lib_$(lib) := \
396 $(foreach ref, $(call lib_refs,$($(lib))), \
397 $(call lib_$(typ_$(lib)),$(lib),$(ref)))) \
398 $(eval inc_$(lib) := \
399 $(foreach inc, $(inc_$(lib)), \
400 $(call inc_$(typ_$(lib)),$(pkg_$(lib)),$(inc)))))
403 ifeq ($(MAKECMDGOALS),list)
404 $(foreach lib,$(thirdparty),$(info $(lib) := $(typ_$(lib)) $(pkg_$(lib))) \
405 $(foreach ref,$(lib_$(lib)), $(info == $(ref))) \
406 $(foreach ref,$(inc_$(lib)), $(info -- $(ref))))
412 static_includes := $(foreach lib,$(static_libs), $(inc_$(lib)))
413 static_libraries := $(foreach lib,$(static_libs),$(lib_$(lib)))
414 shared_libraries := $(foreach lib,$(shared_libs),$(lib_$(lib)))
415 thirdparty_libraries := $(static_libraries) $(shared_libraries)