added keyframe reticle, fixes: DEL, transition at endtrk, DVD/BD render menu
[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 \
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 inc_ladspa=""
137 add_library ladspa
138 inc_lame="include"
139 add_library lame \
140         libmp3lame/.libs/libmp3lame.a \
141         mpglib/.libs/libmpgdecoder.a
142 if [ "$HAVE_FIREWIRE" = "y" ]; then
143 inc_libavc1394="."
144 add_library libavc1394 \
145         libavc1394/.libs/libavc1394.a \
146         librom1394/.libs/librom1394.a \
147         common/.libs/libraw1394util.a
148 inc_libraw1394="."
149 add_library libraw1394 \
150         src/.libs/libraw1394.a
151 inc_libiec61883="src"
152 add_library libiec61883 \
153         src/.libs/libiec61883.a
154 fi
155 if [ "$HAVE_DV" = "y" ]; then
156 inc_libdv="."
157 add_library libdv \
158         libdv/.libs/libdv.a
159 fi
160 inc_libjpeg="."
161 add_library libjpeg \
162         .libs/libjpeg.a \
163         .libs/libturbojpeg.a \
164         simd/.libs/libsimd.a
165 inc_openjpeg="src/lib/openjp2"
166 add_library openjpeg \
167         bin/libopenjp2.a
168 inc_libogg="include"
169 add_library libogg \
170         src/.libs/libogg.a
171 inc_libsndfile="."
172 add_library libsndfile \
173         src/.libs/libsndfile.a \
174         src/.libs/libcommon.a \
175         src/G72x/.libs/libg72x.a \
176         src/GSM610/.libs/libgsm.a
177 inc_libtheora="."
178 add_library libtheora \
179         lib/.libs/libtheora.a \
180         lib/.libs/libtheoradec.a \
181         lib/.libs/libtheoraenc.a
182 inc_libuuid="."
183 add_library libuuid \
184         .libs/libuuid.a
185 inc_libvorbis="include ."
186 add_library libvorbis \
187         lib/.libs/libvorbis.a \
188         lib/.libs/libvorbisenc.a \
189         lib/.libs/libvorbisfile.a
190 inc_mjpegtools=". lavtools utils"
191 add_library mjpegtools \
192         utils/mmxsse/.libs/libmmxsse.a \
193         utils/.libs/libmjpegutils.a \
194         lavtools/.libs/liblavfile.a \
195         lavtools/.libs/liblavjpeg.a \
196         yuvfilters/.libs/libyuvfilters.a \
197         mpeg2enc/.libs/libmpeg2encpp.a \
198         mplex/.libs/libmplex2.a
199 inc_openexr="IlmImf config"
200 add_library openexr \
201         IlmImf/.libs/libIlmImf.a \
202         IlmImfUtil/.libs/libIlmImfUtil.a
203 inc_speech_tools="."
204 add_library speech_tools \
205         lib/libestools.a \
206         lib/libeststring.a \
207         lib/libestbase.a
208 inc_tiff="."
209 add_library tiff \
210         libtiff/.libs/libtiff.a \
211         libtiff/.libs/libtiffxx.a \
212         port/.libs/libport.a
213 inc_twolame="libtwolame"
214 add_library twolame \
215         libtwolame/.libs/libtwolame.a
216 inc_x264="."
217 add_library x264 \
218         libx264.a
219 inc_x265=". source"
220 add_library x265 \
221         libx265.a
222 inc_libvpx="."
223 add_library libvpx \
224         libvpx.a \
225
226 echo ""
227 if [ -n "$libs" ]; then
228   LIBS="$libs"
229 fi
230
231 n=0
232 for lib in $LIBS; do
233   echo -n " $lib"
234   if [ $(((n+=1) % 8)) = 0 ]; then echo ""; fi
235 done
236 if [ $((n % 8)) != 0 ]; then echo ""; fi
237 echo ""
238
239 # dynamic library paths
240 probe() {
241   if ! `echo $LIBS | grep -qw $1`; then return 0; fi
242   local name="$1"
243   if [ -n "${!name}" ]; then return 0; fi
244   local headers="$2"
245   local func="$3"
246   shift 3
247
248   : ${TMPDIR:=$TEMPDIR}
249   : ${TMPDIR:=$TMP}
250   : ${TMPDIR:=/tmp}
251
252   local exe=$(mktemp -u "${TMPDIR}/cine-${name}.XXXXXXXX")
253   trap "rm -f -- ${exe}" EXIT
254
255   {
256     for hdr in $headers; do
257       test "${hdr%.h}" = "${hdr}" &&
258         echo "#include $hdr"    ||
259         echo "#include <$hdr>"
260     done
261     for func in $func; do
262       echo "long check_$func(void) { return (long) $func; }"
263     done
264     echo "int main(void) { return 0; }"
265   } | cc -x c - -o $exe $@ $EXTRA_LIBS >& /dev/null
266   ret=$?
267   rm -f "${exe}"
268   if [ $ret = 0 ]; then
269     eval $name=\"shared $*\"
270     echo "exists shared $name"
271     return 0
272   fi
273   local sta_libs=sta_$name
274   eval $name=\"static ${!sta_libs}\"
275   echo "build  static $name"
276   return 1
277 }
278
279 # test for shared libs/header files
280 probe a52dec "a52.h" a52_init -la52
281 probe audiofile "audiofile.h" afOpenFile -laudiofile
282 probe faac "stdint.h faac.h" faacEncGetVersion -lfaac
283 probe faad2 "faad.h" NeAACDecInit -lfaad
284 # dont build festival in shared build
285 if [ "$STATIC_LIBRARIES" = "n" ]; then festival="shared"; fi
286 if [ "$STATIC_LIBRARIES" = "n" ]; then speech_tools="shared"; fi
287 probe fftw "fftw3.h" fftw_execute -lfftw3
288 probe flac "FLAC/stream_decoder.h" FLAC__stream_decoder_new -lFLAC
289 probe lame "lame/lame.h" hip_decode_init -lmp3lame
290 probe libavc1394 "libavc1394/avc1394.h librom1394/rom1394.h" avc1394_init_target -lavc1394
291 probe libdv "libdv/dv.h" dv_init -ldv
292 probe libiec61883 "libiec61883/iec61883.h" iec61883_mpeg2_recv_init -liec61883
293 probe libjpeg "stdio.h unistd.h jpeglib.h" jpeg_start_decompress -ljpeg
294 probe libogg "ogg/ogg.h" ogg_stream_init -logg
295 probe openjpeg "openjpeg.h" opj_version -lopenjp2 -DOPJ_STATIC || \
296 probe openjpeg "openjpeg-1.5/openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC || \
297 probe openjpeg "openjpeg.h" opj_version -lopenjpeg -DOPJ_STATIC
298 probe libraw1394 "libraw1394/raw1394.h" raw1394_iso_recv_init -lraw1394
299 probe libsndfile "sndfile.h" sf_open -lsndfile
300 probe ilmbase "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
301 probe openexr "OpenEXR/ImfCRgbaFile.h" ImfOpenInputFile -lIlmImf -lIlmThread -lIex
302 probe libtheora "theora/theoraenc.h" th_info_init -ltheora -ltheoraenc -ltheoradec -logg
303 probe libvorbis "vorbis/vorbisenc.h" vorbis_info_init -lvorbisenc -lvorbis -lvorbisfile -logg
304 probe libvpx "vpx/vpx_decoder.h" vpx_codec_decode -lvpx
305 probe tiff "tiff.h tiffio.h" TIFFOpen -ltiff
306 probe twolame "twolame.h" twolame_encode_buffer_float32_interleaved -ltwolame
307 probe x264 "stdint.h x264.h" x264_encoder_encode -lx264
308 probe x265 "x265.h" x265_encoder_encode -lx265
309
310 forced_libs="$forced_libs a52dec encore ffmpeg giflib libuuid openjpeg"
311
312 # for ffmpeg link/broken disto libs
313 for name in $LIBS; do
314   if is_in $name $forced_libs; then
315     set - ${!name}
316     typ="$1"
317     shift 1
318     if [ "$typ" = "shared" ]; then
319       echo "warn: $name forced static"
320       sta_libs=sta_$name
321       eval $name=\"static ${!sta_libs}\"
322     fi
323   fi
324 done
325
326 # add dependencies (order matters)
327 for dep in \
328         ffmpeg/faac ffmpeg/faad2 ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
329         ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/fdk \
330         libiec61883/libraw1394 libavc1394/librom1394 \
331         openexr/ilmbase ilmbase/libogg \
332         libtheora/libogg libtheora/libvorbis ; do
333   lib="${dep%%/*}"
334   needs="${dep##*/}"
335   if is_in $lib $shared; then
336     if is_in $needs $shared; then continue; fi
337     if is_in $needs $static; then
338       echo warn: shared $lib using static $needs
339       continue
340     fi
341     append shared $needs
342   fi
343   if is_in $lib $static; then
344     if is_in $needs $static; then continue; fi
345     if is_in $needs $shared; then
346       echo warn: static $lib using shared $needs
347       continue
348     fi
349     append static $needs
350   fi
351 done
352
353 echo ""
354 # check for static libs which may conflicting header files
355 if [ "$STATIC_LIBRARIES" = "y" ]; then
356   for name in $LIBS; do
357     set - ${!name}
358     typ="$1"
359     shift 1
360     if [ "$typ" = "shared" ]; then
361       echo "warn: $name is shared and static"
362     fi
363     sta_libs=sta_$name
364     eval $name=\"static ${!sta_libs}\"
365   done
366 fi
367
368 # any unknowns are static
369 for name in $LIBS; do
370   if [ -z "${!name}" ]; then
371     sta_libs=sta_$name
372     eval $name=\"static ${!sta_libs}\"
373   fi
374 done
375
376 # dont build festival
377 festival="shared"
378 speech_tools="shared"
379
380 shared=""
381 static=""
382 for lib in $LIBS; do
383   set - ${!lib}
384   typ="$1"
385   append $typ $lib
386 done
387
388 echo "thirdparty :=$LIBS"    > config.mak
389 echo "shared_libs :=$shared" >> config.mak
390 echo "static_libs :=$static" >> config.mak
391
392 for lib in $LIBS; do
393   echo "$lib := ${!lib}"
394   inc_lib=inc_$lib
395   echo "inc_$lib := ${!inc_lib}"
396 done >> config.mak
397
398 echo >> config.mak '
399 # translate config.mak into libs/incs
400
401 pkg_path=$(lastword $(wildcard $(THIRDPARTY)/$(1)*))
402 lib_static=$(call pkg_path,$(1))/$(2)
403 lib_shared=$(2)
404 inc_static=-I$(1)/$(2)
405 inc_shared=
406 lib_typ=$(firstword $(1))
407 lib_refs=$(wordlist 2,$(words $(1)),$(1))
408
409 $(foreach lib,$(thirdparty), \
410   $(eval pkg_$(lib) := $(call pkg_path,$(lib))) \
411   $(eval typ_$(lib) := $(call lib_typ,$($(lib)))) \
412   $(eval lib_$(lib) := \
413     $(foreach ref, $(call lib_refs,$($(lib))), \
414        $(call lib_$(typ_$(lib)),$(lib),$(ref)))) \
415   $(eval inc_$(lib) := \
416     $(foreach inc, $(inc_$(lib)), \
417        $(call inc_$(typ_$(lib)),$(pkg_$(lib)),$(inc)))))
418
419 #list libs/incs
420 ifeq ($(MAKECMDGOALS),list)
421 $(foreach lib,$(thirdparty),$(info $(lib) := $(typ_$(lib)) $(pkg_$(lib))) \
422    $(foreach ref,$(lib_$(lib)), $(info == $(ref))) \
423    $(foreach ref,$(inc_$(lib)), $(info -- $(ref))))
424 .PHONY: list
425 list:
426
427 endif
428
429 static_includes := $(foreach lib,$(static_libs), $(inc_$(lib)))
430 static_libraries := $(foreach lib,$(static_libs),$(lib_$(lib)))
431 shared_libraries := $(foreach lib,$(shared_libs),$(lib_$(lib)))
432 thirdparty_libraries := $(static_libraries) $(shared_libraries)
433 '
434