3 if [ "$1" = "static" ]; then
5 elif [ "$1" = "shared" ]; then
8 echo "usage: $0 <static | shared>"
14 echo "configuring thirdparty library build"
16 echo "required libraries:"
28 [ $var = $value ] && return 0
42 add_library audiofile \
43 libaudiofile/.libs/libaudiofile.a \
44 libaudiofile/modules/.libs/libmodules.a \
45 libaudiofile/alac/.libs/libalac.a
48 `uname -m`/libencore.a
55 libfaac/.libs/libfaac.a \
56 common/mp4v2/libmp4v2.a
59 libfaad/.libs/libfaad.a \
60 common/mp4ff/libmp4ff.a
61 # fdk replaces faac/faad2, but is experimental...
62 inc_fdk="libAACdec/include libAACenc/include libSYS/include"
66 add_library festival \
70 libavutil/libavutil.a \
71 libavcodec/libavcodec.a \
72 libpostproc/libpostproc.a \
73 libavdevice/libavdevice.a \
74 libavformat/libavformat.a \
75 libswscale/libswscale.a \
76 libavfilter/libavfilter.a \
77 libswresample/libswresample.a
81 libbench2/libbench2.a \
82 rdft/scalar/r2cb/.libs/librdft_scalar_r2cb.a \
83 rdft/scalar/r2r/.libs/librdft_scalar_r2r.a \
84 rdft/scalar/.libs/librdft_scalar.a \
85 rdft/scalar/r2cf/.libs/librdft_scalar_r2cf.a \
86 rdft/.libs/librdft.a \
88 reodft/.libs/libreodft.a \
89 dft/scalar/codelets/.libs/libdft_scalar_codelets.a \
90 dft/scalar/.libs/libdft_scalar.a \
92 kernel/.libs/libkernel.a \
93 simd-support/.libs/libsimd_support.a \
94 simd-support/.libs/libsimd_sse2_nonportable.a
97 src/libFLAC/.libs/libFLAC.a \
98 src/libFLAC++/.libs/libFLAC++.a \
99 src/share/utf8/.libs/libutf8.a \
100 src/share/replaygain_analysis/.libs/libreplaygain_analysis.a \
101 src/share/replaygain_synthesis/.libs/libreplaygain_synthesis.a \
102 src/share/grabbag/.libs/libgrabbag.a \
103 src/test_libs_common/.libs/libtest_libs_common.a
108 inc_ilmbase="Iex Half Imath config IlmThread"
109 add_library ilmbase \
111 IexMath/.libs/libIexMath.a \
112 Half/.libs/libHalf.a \
113 Imath/.libs/libImath.a \
114 IlmThread/.libs/libIlmThread.a
119 libmp3lame/.libs/libmp3lame.a \
120 mpglib/.libs/libmpgdecoder.a
122 add_library libavc1394 \
123 libavc1394/.libs/libavc1394.a \
124 librom1394/.libs/librom1394.a \
125 common/.libs/libraw1394util.a
129 inc_libiec61883="src"
130 add_library libiec61883 \
131 src/.libs/libiec61883.a
133 add_library libjpeg \
135 .libs/libturbojpeg.a \
137 inc_openjpeg="src/lib/openmj2"
138 add_library openjpeg \
144 add_library libraw1394 \
145 src/.libs/libraw1394.a
147 add_library libsndfile \
148 src/.libs/libsndfile.a \
149 src/.libs/libcommon.a \
150 src/G72x/.libs/libg72x.a \
151 src/GSM610/.libs/libgsm.a
153 add_library libtheora \
154 lib/.libs/libtheora.a \
155 lib/.libs/libtheoradec.a \
156 lib/.libs/libtheoraenc.a
158 add_library libuuid \
160 inc_libvorbis="include ."
161 add_library libvorbis \
162 lib/.libs/libvorbis.a \
163 lib/.libs/libvorbisenc.a \
164 lib/.libs/libvorbisfile.a
165 inc_mjpegtools=". lavtools utils"
166 add_library mjpegtools \
167 utils/mmxsse/.libs/libmmxsse.a \
168 utils/.libs/libmjpegutils.a \
169 lavtools/.libs/liblavfile.a \
170 lavtools/.libs/liblavjpeg.a \
171 yuvfilters/.libs/libyuvfilters.a \
172 mpeg2enc/.libs/libmpeg2encpp.a \
173 mplex/.libs/libmplex2.a
174 inc_openexr="IlmImf config"
175 add_library openexr \
176 IlmImf/.libs/libIlmImf.a \
177 IlmImfUtil/.libs/libIlmImfUtil.a
179 add_library speech_tools \
185 libtiff/.libs/libtiff.a \
186 libtiff/.libs/libtiffxx.a \
188 inc_twolame="libtwolame"
189 add_library twolame \
190 libtwolame/.libs/libtwolame.a
204 if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
206 if [ $((n % 8)) != 0 ]; then echo ""; fi
209 # dynamic library paths
216 : ${TMPDIR:=$TEMPDIR}
220 local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
221 trap "rm -f -- ${exe}" EXIT
224 for hdr in $headers; do
225 test "${hdr%.h}" = "${hdr}" &&
226 echo "#include $hdr" ||
227 echo "#include <$hdr>"
229 for func in $func; do
230 echo "long check_$func(void) { return (long) $func; }"
232 echo "int main(void) { return 0; }"
233 } | cc -x c - -o $exe $@ >& /dev/null
236 if [ $ret = 0 ]; then
237 eval $name=\"shared $*\"
238 echo "exists shared $name"
241 local sta_libs=sta_$name
242 eval $name=\"static ${!sta_libs}\"
243 echo "build static $name"
247 # test for shared libs/header files
248 probe audiofile "audiofile.h" afOpenFile -laudiofile
249 probe faac "stdint.h faac.h" faacEncGetVersion -lfaac
250 probe faad2 "faad.h" NeAACDecInit -lfaad
251 # dont build festival in shared build
252 if [ "$STATIC_LIBRARIES" = "n" ]; then festival="shared"; fi
253 if [ "$STATIC_LIBRARIES" = "n" ]; then speech_tools="shared"; fi
254 probe fftw "fftw3.h" fftw_execute -lfftw3
255 probe flac "FLAC/stream_decoder.h" FLAC__stream_decoder_new -lFLAC
256 probe lame "lame/lame.h" hip_decode_init -lmp3lame
257 probe libavc1394 "libavc1394/avc1394.h librom1394/rom1394.h" avc1394_init_target -lavc1394
258 probe libdv "libdv/dv.h" dv_init -ldv
259 probe libiec61883 "libiec61883/iec61883.h" iec61883_mpeg2_recv_init -liec61883
260 probe libjpeg "stdio.h unistd.h jpeglib.h" jpeg_start_decompress -ljpeg
261 probe libogg "ogg/ogg.h" ogg_stream_init -logg
262 probe openjpeg "openjpeg.h" opj_version -lopenmj2 -DOPJ_STATIC || \
263 probe openjpeg "openjpeg-1.5/openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC || \
264 probe openjpeg "openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC
265 probe libraw1394 "libraw1394/raw1394.h" raw1394_iso_recv_init -lraw1394
266 probe libsndfile "sndfile.h" sf_open -lsndfile
267 probe ilmbase "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
268 probe openexr "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
269 probe libtheora "theora/theoraenc.h" th_info_init -ltheora -ltheoraenc -ltheoradec -logg
270 probe libvorbis "vorbis/vorbisenc.h" vorbis_info_init -lvorbisenc -lvorbis -lvorbisfile -logg
271 probe libvpx "vpx/vpx_decoder.h" vpx_codec_decode -lvpx
272 probe tiff "tiff.h tiffio.h" TIFFOpen -ltiff
273 probe twolame "twolame.h" twolame_encode_buffer_float32_interleaved -ltwolame
274 probe x264 "stdint.h x264.h" x264_encoder_encode -lx264
275 probe x265 "x265.h" x265_encoder_encode -lx265
278 # for ffmpeg link/broken disto libs
279 forced_libs="encore ffmpeg giflib libuuid"
280 for name in $LIBS; do
281 if is_in $name $forced_libs; then
285 if [ "$typ" = "shared" ]; then
286 echo "warn: $name forced static"
288 eval $name=\"static ${!sta_libs}\"
293 # add dependencies (order matters)
295 ffmpeg/faac ffmpeg/faad2 ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
296 ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/fdk \
297 libiec61883/libraw1394 libavc1394/librom1394 \
298 openexr/ilmbase ilmbase/libogg \
299 libtheora/libogg libtheora/libvorbis ; do
302 if is_in $lib $shared; then
303 if is_in $needs $shared; then continue; fi
304 if is_in $needs $static; then
305 echo warn: shared $lib using static $needs
310 if is_in $lib $static; then
311 if is_in $needs $static; then continue; fi
312 if is_in $needs $shared; then
313 echo warn: static $lib using shared $needs
321 # check for static libs which may conflicting header files
322 if [ "$STATIC_LIBRARIES" = "y" ]; then
323 for name in $LIBS; do
327 if [ "$typ" = "shared" ]; then
328 echo "warn: $name is shared and static"
331 eval $name=\"static ${!sta_libs}\"
335 # any unknowns are static
336 for name in $LIBS; do
337 if [ -z "${!name}" ]; then
339 eval $name=\"static ${!sta_libs}\"
343 # dont build festival
345 speech_tools="shared"
355 echo "thirdparty :=$LIBS" > config.mak
356 echo "shared_libs :=$shared" >> config.mak
357 echo "static_libs :=$static" >> config.mak
360 echo "$lib := ${!lib}"
362 echo "inc_$lib := ${!inc_lib}"
366 # translate config.mak into libs/incs
368 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
369 lib_static=$(call pkg_path,$(1))/$(2)
371 inc_static=-I$(1)/$(2)
373 lib_typ=$(firstword $(1))
374 lib_refs=$(wordlist 2,$(words $(1)),$(1))
376 $(foreach lib,$(thirdparty), \
377 $(eval pkg_$(lib) := $(call pkg_path,$(lib))) \
378 $(eval typ_$(lib) := $(call lib_typ,$($(lib)))) \
379 $(eval lib_$(lib) := \
380 $(foreach ref, $(call lib_refs,$($(lib))), \
381 $(call lib_$(typ_$(lib)),$(lib),$(ref)))) \
382 $(eval inc_$(lib) := \
383 $(foreach inc, $(inc_$(lib)), \
384 $(call inc_$(typ_$(lib)),$(pkg_$(lib)),$(inc)))))
387 ifeq ($(MAKECMDGOALS),list)
388 $(foreach lib,$(thirdparty),$(info $(lib) := $(typ_$(lib)) $(pkg_$(lib))) \
389 $(foreach ref,$(lib_$(lib)), $(info == $(ref))) \
390 $(foreach ref,$(inc_$(lib)), $(info -- $(ref))))
396 static_includes := $(foreach lib,$(static_libs), $(inc_$(lib)))
397 static_libraries := $(foreach lib,$(static_libs),$(lib_$(lib)))
398 shared_libraries := $(foreach lib,$(shared_libs),$(lib_$(lib)))
399 thirdparty_libraries := $(static_libraries) $(shared_libraries)