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/getopt/libgetopt.a \
100 src/share/utf8/.libs/libutf8.a \
101 src/share/replaygain_analysis/.libs/libreplaygain_analysis.a \
102 src/share/replaygain_synthesis/.libs/libreplaygain_synthesis.a \
103 src/share/grabbag/.libs/libgrabbag.a \
104 src/test_libs_common/.libs/libtest_libs_common.a
109 inc_ilmbase="Iex Half Imath config IlmThread"
110 add_library ilmbase \
112 IexMath/.libs/libIexMath.a \
113 Half/.libs/libHalf.a \
114 Imath/.libs/libImath.a \
115 IlmThread/.libs/libIlmThread.a
120 libmp3lame/.libs/libmp3lame.a \
121 mpglib/.libs/libmpgdecoder.a
123 add_library libavc1394 \
124 libavc1394/.libs/libavc1394.a \
125 librom1394/.libs/librom1394.a \
126 common/.libs/libraw1394util.a
130 inc_libiec61883="src"
131 add_library libiec61883 \
132 src/.libs/libiec61883.a
134 add_library libjpeg \
136 .libs/libturbojpeg.a \
138 inc_openjpeg="src/lib/openmj2"
139 add_library openjpeg \
145 add_library libraw1394 \
146 src/.libs/libraw1394.a
148 add_library libsndfile \
149 src/.libs/libsndfile.a \
150 src/.libs/libcommon.a \
151 src/G72x/.libs/libg72x.a \
152 src/GSM610/.libs/libgsm.a
154 add_library libtheora \
155 lib/.libs/libtheora.a \
156 lib/.libs/libtheoradec.a \
157 lib/.libs/libtheoraenc.a
159 add_library libuuid \
161 inc_libvorbis="include ."
162 add_library libvorbis \
163 lib/.libs/libvorbis.a \
164 lib/.libs/libvorbisenc.a \
165 lib/.libs/libvorbisfile.a
166 inc_mjpegtools=". lavtools utils"
167 add_library mjpegtools \
168 utils/mmxsse/.libs/libmmxsse.a \
169 utils/.libs/libmjpegutils.a \
170 lavtools/.libs/liblavfile.a \
171 lavtools/.libs/liblavjpeg.a \
172 yuvfilters/.libs/libyuvfilters.a \
173 mpeg2enc/.libs/libmpeg2encpp.a \
174 mplex/.libs/libmplex2.a
175 inc_openexr="IlmImf config"
176 add_library openexr \
177 IlmImf/.libs/libIlmImf.a \
178 IlmImfUtil/.libs/libIlmImfUtil.a
180 add_library speech_tools \
186 libtiff/.libs/libtiff.a \
187 libtiff/.libs/libtiffxx.a \
189 inc_twolame="libtwolame"
190 add_library twolame \
191 libtwolame/.libs/libtwolame.a
205 if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
207 if [ $((n % 8)) != 0 ]; then echo ""; fi
210 # dynamic library paths
217 : ${TMPDIR:=$TEMPDIR}
221 local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
222 trap "rm -f -- ${exe}" EXIT
225 for hdr in $headers; do
226 test "${hdr%.h}" = "${hdr}" &&
227 echo "#include $hdr" ||
228 echo "#include <$hdr>"
230 for func in $func; do
231 echo "long check_$func(void) { return (long) $func; }"
233 echo "int main(void) { return 0; }"
234 } | cc -x c - -o $exe $@ >& /dev/null
237 if [ $ret = 0 ]; then
238 eval $name=\"shared $*\"
239 echo "exists shared $name"
242 local sta_libs=sta_$name
243 eval $name=\"static ${!sta_libs}\"
244 echo "build static $name"
248 # test for shared libs/header files
249 probe audiofile "audiofile.h" afOpenFile -laudiofile
250 probe faac "stdint.h faac.h" faacEncGetVersion -lfaac
251 probe faad2 "faad.h" NeAACDecInit -lfaad
252 # dont build festival in shared build
253 if [ "$STATIC_LIBRARIES" = "n" ]; then festival="shared"; fi
254 if [ "$STATIC_LIBRARIES" = "n" ]; then speech_tools="shared"; fi
255 probe fftw "fftw3.h" fftw_execute -lfftw3
256 probe flac "FLAC/stream_decoder.h" FLAC__stream_decoder_new -lFLAC
257 probe lame "lame/lame.h" hip_decode_init -lmp3lame
258 probe libavc1394 "libavc1394/avc1394.h librom1394/rom1394.h" avc1394_init_target -lavc1394
259 probe libdv "libdv/dv.h" dv_init -ldv
260 probe libiec61883 "libiec61883/iec61883.h" iec61883_mpeg2_recv_init -liec61883
261 probe libjpeg "stdio.h unistd.h jpeglib.h" jpeg_start_decompress -ljpeg
262 probe libogg "ogg/ogg.h" ogg_stream_init -logg
263 probe openjpeg "openjpeg.h" opj_version -lopenmj2 -DOPJ_STATIC || \
264 probe openjpeg "openjpeg-1.5/openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC || \
265 probe openjpeg "openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC
266 probe libraw1394 "libraw1394/raw1394.h" raw1394_iso_recv_init -lraw1394
267 probe libsndfile "sndfile.h" sf_open -lsndfile
268 probe ilmbase "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
269 probe openexr "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
270 probe libtheora "theora/theoraenc.h" th_info_init -ltheora -ltheoraenc -ltheoradec -logg
271 probe libvorbis "vorbis/vorbisenc.h" vorbis_info_init -lvorbisenc -lvorbis -lvorbisfile -logg
272 probe libvpx "vpx/vpx_decoder.h" vpx_codec_decode -lvpx
273 probe tiff "tiff.h tiffio.h" TIFFOpen -ltiff
274 probe twolame "twolame.h" twolame_encode_buffer_float32_interleaved -ltwolame
275 probe x264 "stdint.h x264.h" x264_encoder_encode -lx264
276 probe x265 "x265.h" x265_encoder_encode -lx265
279 # for ffmpeg link/broken disto libs
280 forced_libs="encore ffmpeg giflib libuuid"
281 for name in $LIBS; do
282 if is_in $name $forced_libs; then
286 if [ "$typ" = "shared" ]; then
287 echo "warn: $name forced static"
289 eval $name=\"static ${!sta_libs}\"
294 # add dependencies (order matters)
296 ffmpeg/faac ffmpeg/faad2 ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
297 ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/fdk \
298 libiec61883/libraw1394 libavc1394/librom1394 \
299 openexr/ilmbase ilmbase/libogg \
300 libtheora/libogg libtheora/libvorbis ; do
303 if is_in $lib $shared; then
304 if is_in $needs $shared; then continue; fi
305 if is_in $needs $static; then
306 echo warn: shared $lib using static $needs
311 if is_in $lib $static; then
312 if is_in $needs $static; then continue; fi
313 if is_in $needs $shared; then
314 echo warn: static $lib using shared $needs
322 # check for static libs which may conflicting header files
323 if [ "$STATIC_LIBRARIES" = "y" ]; then
324 for name in $LIBS; do
328 if [ "$typ" = "shared" ]; then
329 echo "warn: $name is shared and static"
332 eval $name=\"static ${!sta_libs}\"
336 # any unknowns are static
337 for name in $LIBS; do
338 if [ -z "${!name}" ]; then
340 eval $name=\"static ${!sta_libs}\"
344 # dont build festival
346 speech_tools="shared"
356 echo "thirdparty :=$LIBS" > config.mak
357 echo "shared_libs :=$shared" >> config.mak
358 echo "static_libs :=$static" >> config.mak
361 echo "$lib := ${!lib}"
363 echo "inc_$lib := ${!inc_lib}"
367 # translate config.mak into libs/incs
369 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
370 lib_static=$(call pkg_path,$(1))/$(2)
372 inc_static=-I$(1)/$(2)
374 lib_typ=$(firstword $(1))
375 lib_refs=$(wordlist 2,$(words $(1)),$(1))
377 $(foreach lib,$(thirdparty), \
378 $(eval pkg_$(lib) := $(call pkg_path,$(lib))) \
379 $(eval typ_$(lib) := $(call lib_typ,$($(lib)))) \
380 $(eval lib_$(lib) := \
381 $(foreach ref, $(call lib_refs,$($(lib))), \
382 $(call lib_$(typ_$(lib)),$(lib),$(ref)))) \
383 $(eval inc_$(lib) := \
384 $(foreach inc, $(inc_$(lib)), \
385 $(call inc_$(typ_$(lib)),$(pkg_$(lib)),$(inc)))))
388 ifeq ($(MAKECMDGOALS),list)
389 $(foreach lib,$(thirdparty),$(info $(lib) := $(typ_$(lib)) $(pkg_$(lib))) \
390 $(foreach ref,$(lib_$(lib)), $(info == $(ref))) \
391 $(foreach ref,$(inc_$(lib)), $(info -- $(ref))))
397 static_includes := $(foreach lib,$(static_libs), $(inc_$(lib)))
398 static_libraries := $(foreach lib,$(static_libs),$(lib_$(lib)))
399 shared_libraries := $(foreach lib,$(shared_libs),$(lib_$(lib)))
400 thirdparty_libraries := $(static_libraries) $(shared_libraries)