dvd/bd scaling fixes, es/de .po file updates
[goodguy/history.git] / cinelerra-5.1 / thirdparty / configure
1 #!/bin/bash
2
3 if [ -x "`which gmake`" ]; then
4   MAKE=gmake
5 else
6   MAKE=make
7 fi
8
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`\""
13 done
14
15 if [ "$1" = "static" ]; then
16   STATIC_LIBRARIES="y"
17 elif [ "$1" = "shared" ]; then
18   STATIC_LIBRARIES="n"
19 elif [ "$1" = "cv" ]; then
20   STATIC_LIBRARIES="n"
21   libs="libogg libtheora libvorbis openexr libdv libjpeg tiff x264 mjpegtools a52dec lame libsndfile faac faad2"
22   forced_libs="mjpegtools x264"
23 else
24   echo "usage: $0 <static | shared | cv>"
25   exit 1
26 fi
27
28 #thirdparty libraries
29
30 echo "configuring thirdparty library build"
31 echo ""
32 echo "required libraries:"
33
34 append() {
35   var=$1
36   shift
37   eval "$var+=\" $*\""
38 }
39
40 is_in() {
41   value=$1
42   shift
43   for var in $*; do
44     [ $var = $value ] && return 0
45   done
46   return 1
47 }
48
49 add_library() {
50   local lib=$1
51   shift 1
52   append LIBS $lib
53   sta_lib=sta_$lib
54   append $sta_lib $@
55 }
56
57 inc_a52dec="include"
58 add_library a52dec \
59         liba52/.libs/liba52.a
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
65 inc_encore="."
66 add_library encore \
67         $OBJDIR/libencore.a
68 if [ "$HAVE_ESOUND" = "y" ]; then
69 inc_esound="."
70 add_library esound \
71         .libs/libesd.a \
72         .libs/libesddsp.a
73 fi
74 inc_faac="include"
75 add_library faac \
76         libfaac/.libs/libfaac.a \
77         common/mp4v2/libmp4v2.a
78 inc_faad2="include"
79 add_library faad2 \
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"
84 add_library fdk \
85         .libs/libfdk-aac.a
86 inc_festival="src"
87 add_library festival \
88         src/lib/libFestival.a
89 inc_ffmpeg="."
90 add_library ffmpeg \
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
99 inc_fftw="api"
100 add_library fftw \
101         .libs/libfftw3.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 \
108         api/.libs/libapi.a \
109         reodft/.libs/libreodft.a \
110         dft/scalar/codelets/.libs/libdft_scalar_codelets.a \
111         dft/scalar/.libs/libdft_scalar.a \
112         dft/.libs/libdft.a \
113         kernel/.libs/libkernel.a \
114         simd-support/.libs/libsimd_support.a \
115         simd-support/.libs/libsimd_sse2_nonportable.a
116 inc_flac="include"
117 add_library flac \
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
125 inc_giflib="lib"
126 add_library giflib \
127         lib/.libs/libgif.a \
128         util/libgetarg.a
129 inc_ilmbase="Iex Half Imath config IlmThread"
130 add_library ilmbase \
131         Iex/.libs/libIex.a \
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
137 inc_ladspa=""
138 add_library ladspa
139 fi
140 inc_lame="include"
141 add_library lame \
142         libmp3lame/.libs/libmp3lame.a \
143         mpglib/.libs/libmpgdecoder.a
144 if [ "$HAVE_FIREWIRE" = "y" ]; then
145 inc_libavc1394="."
146 add_library libavc1394 \
147         libavc1394/.libs/libavc1394.a \
148         librom1394/.libs/librom1394.a \
149         common/.libs/libraw1394util.a
150 inc_libraw1394="."
151 add_library libraw1394 \
152         src/.libs/libraw1394.a
153 inc_libiec61883="src"
154 add_library libiec61883 \
155         src/.libs/libiec61883.a
156 fi
157 if [ "$HAVE_DV" = "y" ]; then
158 inc_libdv="."
159 add_library libdv \
160         libdv/.libs/libdv.a
161 fi
162 inc_libjpeg="."
163 add_library libjpeg \
164         .libs/libjpeg.a \
165         .libs/libturbojpeg.a \
166         simd/.libs/libsimd.a
167 inc_openjpeg="src/lib/openjp2"
168 add_library openjpeg \
169         bin/libopenjp2.a
170 inc_libogg="include"
171 add_library libogg \
172         src/.libs/libogg.a
173 inc_libsndfile="."
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
179 inc_libtheora="."
180 add_library libtheora \
181         lib/.libs/libtheora.a \
182         lib/.libs/libtheoradec.a \
183         lib/.libs/libtheoraenc.a
184 inc_libuuid="."
185 add_library libuuid \
186         .libs/libuuid.a
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
205 inc_speech_tools="."
206 add_library speech_tools \
207         lib/libestools.a \
208         lib/libeststring.a \
209         lib/libestbase.a
210 inc_tiff="."
211 add_library tiff \
212         libtiff/.libs/libtiff.a \
213         libtiff/.libs/libtiffxx.a \
214         port/.libs/libport.a
215 inc_twolame="libtwolame"
216 add_library twolame \
217         libtwolame/.libs/libtwolame.a
218 inc_x264="."
219 add_library x264 \
220         libx264.a
221 inc_x265=". source"
222 add_library x265 \
223         libx265.a
224 inc_libvpx="."
225 add_library libvpx \
226         libvpx.a \
227
228 echo ""
229 if [ -n "$libs" ]; then
230   LIBS="$libs"
231 fi
232
233 n=0
234 for lib in $LIBS; do
235   echo -n " $lib"
236   if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
237 done
238 if [ $((n % 8)) != 0 ]; then echo ""; fi
239 echo ""
240
241 # dynamic library paths
242 probe() {
243   if ! `echo $LIBS | grep -qw $1`; then return 0; fi
244   local name="$1"
245   if [ -n "${!name}" ]; then return 0; fi
246   local headers="$2"
247   local func="$3"
248   shift 3
249
250   : ${TMPDIR:=$TEMPDIR}
251   : ${TMPDIR:=$TMP}
252   : ${TMPDIR:=/tmp}
253
254   local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
255   trap "rm -f -- ${exe}" EXIT
256
257   {
258     for hdr in $headers; do
259       test "${hdr%.h}" = "${hdr}" &&
260         echo "#include $hdr"    ||
261         echo "#include <$hdr>"
262     done
263     for func in $func; do
264       echo "long check_$func(void) { return (long) $func; }"
265     done
266     echo "int main(void) { return 0; }"
267   } | cc -x c - -o $exe $@ $EXTRA_LIBS >& /dev/null
268   ret=$?
269   rm -f "${exe}"
270   if [ $ret = 0 ]; then
271     eval $name=\"shared $*\"
272     echo "exists shared $name"
273     return 0
274   fi
275   local sta_libs=sta_$name
276   eval $name=\"static ${!sta_libs}\"
277   echo "build  static $name"
278   return 1
279 }
280
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
311
312 forced_libs="$forced_libs a52dec encore ffmpeg giflib libuuid openjpeg"
313
314 # for ffmpeg link/broken disto libs
315 for name in $LIBS; do
316   if is_in $name $forced_libs; then
317     set - ${!name}
318     typ="$1"
319     shift 1
320     if [ "$typ" = "shared" ]; then
321       echo "warn: $name forced static"
322       sta_libs=sta_$name
323       eval $name=\"static ${!sta_libs}\"
324     fi
325   fi
326 done
327
328 # add dependencies (order matters)
329 for dep in \
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
335   lib="${dep%%/*}"
336   needs="${dep##*/}"
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
341       continue
342     fi
343     append shared $needs
344   fi
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
349       continue
350     fi
351     append static $needs
352   fi
353 done
354
355 echo ""
356 # check for static libs which may conflicting header files
357 if [ "$STATIC_LIBRARIES" = "y" ]; then
358   for name in $LIBS; do
359     set - ${!name}
360     typ="$1"
361     shift 1
362     if [ "$typ" = "shared" ]; then
363       echo "warn: $name is shared and static"
364     fi
365     sta_libs=sta_$name
366     eval $name=\"static ${!sta_libs}\"
367   done
368 fi
369
370 # any unknowns are static
371 for name in $LIBS; do
372   if [ -z "${!name}" ]; then
373     sta_libs=sta_$name
374     eval $name=\"static ${!sta_libs}\"
375   fi
376 done
377
378 # dont build festival
379 festival="shared"
380 speech_tools="shared"
381
382 shared=""
383 static=""
384 for lib in $LIBS; do
385   set - ${!lib}
386   typ="$1"
387   append $typ $lib
388 done
389
390 echo "thirdparty :=$LIBS"    > config.mak
391 echo "shared_libs :=$shared" >> config.mak
392 echo "static_libs :=$static" >> config.mak
393
394 for lib in $LIBS; do
395   echo "$lib := ${!lib}"
396   inc_lib=inc_$lib
397   echo "inc_$lib := ${!inc_lib}"
398 done >> config.mak
399
400 echo >> config.mak '
401 # translate config.mak into libs/incs
402
403 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
404 lib_static=$(call pkg_path,$(1))/$(2)
405 lib_shared=$(2)
406 inc_static=-I$(1)/$(2)
407 inc_shared=
408 lib_typ=$(firstword $(1))
409 lib_refs=$(wordlist 2,$(words $(1)),$(1))
410
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)))))
420
421 #list libs/incs
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))))
426 .PHONY: list
427 list:
428
429 endif
430
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)
435 '
436