ffmpeg scan remap fix, configure.ac all or none fix, 3rd party libs: ffmpeg, turbo...
[goodguy/cinelerra.git] / cinelerra-5.1 / configure.ac
1
2 AC_PREREQ([2.69])
3 AC_INIT([cinelerra], [5.1], [mail@lists.cinelerra-gg.org])
4 AM_INIT_AUTOMAKE([foreign])
5
6 AM_PROG_AS
7 AC_LANG_CPLUSPLUS
8 AC_LANG_C
9 AC_PROG_CXX
10
11 CFG_CFLAGS+=" -fno-omit-frame-pointer -fno-math-errno -fno-signed-zeros"
12 CFG_CFLAGS+=" -pthread -Wall"
13 # misguided pedantic warnings
14 #  this is extra work, not a gain...
15 CFG_CFLAGS+=" -Wno-unknown-warning-option"
16 CFG_CFLAGS+=" -Wno-attributes"
17 CFG_CFLAGS+=" -Wno-unused-result"
18 CFG_CFLAGS+=" -Wno-stringop-overflow"
19 CFG_CFLAGS+=" -Wno-format-truncation"
20 CFG_CFLAGS+=" -Wno-format-overflow"
21 CFG_CFLAGS+=" -Wno-parentheses"
22 CFG_CFLAGS+=" -Wno-stringop-truncation"
23 CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS"
24 CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS"
25 CFG_CFLAGS+=" -DPNG_SKIP_SETJMP_CHECK=1"
26 CFG_CFLAGS+=" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
27 CFG_CFLAGS+=" -I/usr/include -I/usr/local/include"
28 CFG_CFLAGS+=" -I/usr/include/freetype2 -I/usr/local/include/freetype2"
29 CFG_CFLAGS+=" -I/usr/include/uuid -I/usr/local/include/uuid"
30 CFG_CFLAGS+=" -I/usr/include/mjpegtools -I/usr/local/include/mjpegtools"
31
32 AC_DEFUN([CHECK_WITH], [
33 AC_ARG_WITH([$1],
34   AC_HELP_STRING([--with-[$1]], [$2 ($4)]),
35   [WANT_$3=$withval], [WANT_$3='$4'])
36 AC_SUBST([WANT_$3])
37 ])
38
39 CHECK_WITH([jobs],[parallel build jobs],[JOBS],[auto])
40 CHECK_WITH([exec-name],[binary executable name],[CIN],[cin])
41 CHECK_WITH([single-user],[to install cin in bin],[CINBIN_BUILD],[no])
42 CHECK_WITH([lv2],[lv2 library support],[LV2],[yes])
43 CHECK_WITH([cinlib],[cinelerra library path],[CINLIB_DIR],[auto])
44 CHECK_WITH([cindat],[cinelerra share path],[CINDAT_DIR],[auto])
45 CHECK_WITH([plugin-dir],[plugin install dir],[PLUGIN_DIR],[auto])
46 CHECK_WITH([ladspa-dir],[ladspa install dir],[LADSPA_DIR],[auto])
47 CHECK_WITH([ladspa-build],[build ladspa library],[LADSPA_BUILD],[yes])
48 CHECK_WITH([config-dir],[.bcast config dir],[CONFIG_DIR],[$$HOME/.bcast5])
49 CHECK_WITH([nested-dir],[nested proxy dir],[NESTED_DIR],[$$HOME/Videos])
50 CHECK_WITH([snap-dir],[snapshot/grabshot dir],[SNAP_DIR],[$$HOME/Pictures])
51 CHECK_WITH([browser],[cin_browser path],[CIN_BROWSER],[firefox])
52 CHECK_WITH([git-ffmpeg],[git ffmpeg using url],[GIT_FFMPEG],[no])
53 CHECK_WITH([noelision],[use noelision/libpthread],[NOELISION],[auto])
54 CHECK_WITH([booby],[window lock trace booby trap],[BOOBY],[no])
55 CHECK_WITH([libzmpeg],[build libzmpeg],[LIBZMPEG],[yes])
56 CHECK_WITH([commercial],[enable commercial capture],[COMMERCIAL],[no])
57 CHECK_WITH([thirdparty],[use thirdparty build],[CIN_3RDPARTY],[yes])
58 CHECK_WITH([shuttle],[shuttle device],[SHUTTLE],[yes])
59 CHECK_WITH([wintv],[usb 2040:826d wintv device],[WINTV],[yes])
60 CHECK_WITH([x10tv],[usb 0bc7:0004 X10 remote device],[X10TV],[yes])
61 CHECK_WITH([vaapi],[video acceleration api],[VAAPI],[yes])
62 CHECK_WITH([vdpau],[video decode+presentation api for unix],[VDPAU],[yes])
63 CHECK_WITH([nv],[nvenc/nvdec ffnvcodec api],[NV],[yes])
64 CHECK_WITH([cuda],[nv cuda plugins],[CUDA],[auto])
65 CHECK_WITH([clang],[use clang instead of gcc/g++],[CLANG],[no])
66
67 if test "x$WANT_LV2" != "xno"; then
68   GTK2_LIBS=`pkg-config --libs gtk+-2.0`
69   AC_CHECK_LIB([m], [gtk_init], [HAVE_gtk=yes], [HAVE_gtk=no], [$GTK2_LIBS])
70   test "x$HAVE_gtk" != "xno" && test -z "`pkg-config --cflags gtk+-2.0`" && HAVE_gtk=no
71   test "x$HAVE_gtk" != "xno" && test -z "`pkg-config --libs gtk+-2.0`" && HAVE_gtk=no
72   if test "x$HAVE_gtk" = "xno"; then
73     AC_MSG_ERROR([LV2 requires gtk+-2.0 support.])
74   fi
75 fi
76
77 if test "x$WANT_COMMERCIAL" = "xyes" -a "x$WANT_LIBZMPEG" != "xyes" ; then
78   AC_MSG_ERROR([commercial requires libzmpeg support.])
79 fi
80
81 if test "x$WANT_CINBIN_BUILD" = "xyes"; then
82   WANT_LOCALE_DIR='$$CIN_LIB/locale'
83   test "x$WANT_CINDAT_DIR" = "xauto" && WANT_CINDAT_DIR='$$CIN_PATH'
84   test "x$WANT_CINLIB_DIR" = "xauto" && WANT_CINLIB_DIR='$$CIN_PATH'
85   test "x$WANT_PLUGIN_DIR" = "xauto" && WANT_PLUGIN_DIR='$$CIN_LIB/plugins'
86   test "x$WANT_LADSPA_DIR" = "xauto" && WANT_LADSPA_DIR='$$CIN_LIB/ladspa'
87 else
88   lcldir=`test "x$prefix" = "xNONE" && prefix=$ac_default_prefix; \
89     test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"; \
90     eval "dir=\"$localedir\""; eval "dir=\"$dir\""; eval "dir=\"$dir\""; \
91     echo "$dir"`
92   usrdat=`test "x$prefix" = "xNONE" && prefix=$ac_default_prefix; \
93     test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"; \
94     eval "dir=\"$datadir\""; eval "dir=\"$dir\""; eval "dir=\"$dir\""; \
95     echo "$dir"`
96   usrlib=`test "x$prefix" = "xNONE" && prefix="$ac_default_prefix"; \
97     test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"; \
98     eval "dir=\"$libdir\""; eval "dir=\"$dir\""; eval "dir=\"$dir\""; \
99     echo "$dir"`
100   test "x$usrlib" = "x/lib" -o "x$usrlib" = "x/usr/lib" -o \
101        "x$usrlib" = "x/usr/local/lib" -a -e "/usr/lib64" && \
102   test ! -e "/usr/lib" -o `ls -1 /usr/lib64 | wc -l` -gt `ls -1 /usr/lib | wc -l` && \
103     usrlib+="64"
104   WANT_LOCALE_DIR="$lcldir"
105   test "x$WANT_CINDAT_DIR" = "xauto" && WANT_CINDAT_DIR="$usrdat/$WANT_CIN"
106   test "x$WANT_CINLIB_DIR" = "xauto" && WANT_CINLIB_DIR="$usrlib/$WANT_CIN"
107   test "x$WANT_PLUGIN_DIR" = "xauto" && WANT_PLUGIN_DIR="$WANT_CINLIB_DIR/plugins"
108   test "x$WANT_LADSPA_DIR" = "xauto" && WANT_LADSPA_DIR="$WANT_CINLIB_DIR/ladspa"
109 fi
110
111 CIN_INSTALLS=""
112 CIN_UNINSTALLS=""
113 if test "x$WANT_LIBZMPEG" = "xyes"; then
114   CIN_INSTALLS+=" zmp_install"
115   CIN_UNINSTALLS+=" zmp_uninstall"
116 fi
117 if test "x$WANT_COMMERCIAL" = "xyes"; then
118   CIN_INSTALLS+=" com_install"
119   CIN_UNINSTALLS+=" com_uninstall"
120 fi
121 if test "x$WANT_LADSPA_BUILD" = "xyes"; then
122   CIN_INSTALLS+=" lad_install "
123   CIN_UNINSTALLS+=" lad_uninstall "
124 fi
125 if test "x$WANT_LV2" = "xyes"; then
126   CIN_INSTALLS+=" lv2_install "
127   CIN_UNINSTALLS+=" lv2_uninstall "
128 fi
129 AC_SUBST(CIN_INSTALLS)
130 AC_SUBST(CIN_UNINSTALLS)
131
132 if test "x$WANT_CINBIN_BUILD" = "xyes"; then
133   MAK_INSTALLS="dvl_install"
134   MAK_UNINSTALLS="dvl_uninstall"
135 else
136   MAK_INSTALLS=" sys_install"
137   MAK_UNINSTALLS="sys_uninstall"
138 fi
139 AC_SUBST(MAK_INSTALLS)
140 AC_SUBST(MAK_UNINSTALLS)
141
142 if test "x$WANT_JOBS" = "xauto"; then
143   CPUS=`grep -c "^proc" /proc/cpuinfo`
144   WANT_JOBS=`expr $CPUS + $CPUS / 2 + 2`
145 fi
146
147 AC_DEFUN([PKG_DEF],[
148 STATIC_PKGS+=" [$1]"
149 ver_$1="$2"
150 lib_$1="$3"
151 inc_$1="$4"
152 ])
153
154 AC_DEFUN([PKG_3RD],[
155 AC_ARG_ENABLE([$1],
156   AC_HELP_STRING([--enable-$1],[build $1 ($2)]),
157   [PKG_$1=$enableval], [PKG_$1=$2])
158 PKG_DEF([$1],[$3],[$4],[$5])
159 ])
160
161 # thirdparty builds
162
163 PKG_3RD([a52dec],[yes],
164   [a52dec-0.7.4],
165   [ liba52/.libs/liba52.a ],
166   [ include ])
167
168 PKG_3RD([djbfft],[yes],
169   [djbfft-0.76],
170   [ libdjbfft.a ],
171   [ . ])
172
173 PKG_3RD([audiofile],[no],
174   [audiofile-0.3.6],
175   [ libaudiofile/.libs/libaudiofile.a \
176     libaudiofile/modules/.libs/libmodules.a \
177     libaudiofile/alac/.libs/libalac.a ],
178   [ libaudiofile ])
179
180 PKG_3RD([encore],[no],
181   [encore-5.0],
182   [ \$(OBJDIR)/libencore.a ],
183   [ . ])
184
185 PKG_3RD([esound],[no],
186   [esound-0.2.41],
187   [ .libs/libesd.a \
188     .libs/libesddsp.a ],
189   [ . ])
190
191 PKG_3RD([ffmpeg],[yes],
192   [ffmpeg-4.2],
193   [ libavutil/libavutil.a \
194     libavcodec/libavcodec.a \
195     libpostproc/libpostproc.a \
196     libavdevice/libavdevice.a \
197     libavformat/libavformat.a \
198     libswscale/libswscale.a \
199     libavfilter/libavfilter.a \
200     libswresample/libswresample.a ],
201   [ . ])
202
203 if test "x$WANT_GIT_FFMPEG" != "xno" ; then
204   ver_ffmpeg="ffmpeg.git"
205 fi
206
207 PKG_3RD([fftw],[auto],
208   [fftw-3.3.8],
209   [ .libs/libfftw3.a \
210     libbench2/libbench2.a \
211     rdft/scalar/r2cb/.libs/librdft_scalar_r2cb.a \
212     rdft/scalar/r2r/.libs/librdft_scalar_r2r.a \
213     rdft/scalar/.libs/librdft_scalar.a \
214     rdft/scalar/r2cf/.libs/librdft_scalar_r2cf.a \
215     rdft/.libs/librdft.a \
216     api/.libs/libapi.a \
217     reodft/.libs/libreodft.a \
218     dft/scalar/codelets/.libs/libdft_scalar_codelets.a \
219     dft/scalar/.libs/libdft_scalar.a \
220     dft/.libs/libdft.a \
221     kernel/.libs/libkernel.a \
222     simd-support/.libs/libsimd_support.a ],
223   [ api ])
224
225 PKG_3RD([flac],[auto],
226   [flac-1.3.2],
227   [ src/libFLAC/.libs/libFLAC.a \
228     src/libFLAC++/.libs/libFLAC++.a \
229     src/share/replaygain_analysis/.libs/libreplaygain_analysis.a \
230     src/share/replaygain_synthesis/.libs/libreplaygain_synthesis.a \
231     src/share/grabbag/.libs/libgrabbag.a \
232     src/share/utf8/.libs/libutf8.a \
233     src/test_libs_common/.libs/libtest_libs_common.a ],
234   [ include ])
235
236 PKG_3RD([giflib],[yes],
237   [giflib-5.2.1],
238   [ libgif.a \
239     libutil.a ],
240   [ . ])
241
242 PKG_DEF([ladspa], [ladspa-0.4.17], [], [])
243
244 PKG_3RD([lame],[auto],
245   [lame-3.100],
246   [ libmp3lame/.libs/libmp3lame.a \
247     mpglib/.libs/libmpgdecoder.a ],
248   [ include ])
249
250 PKG_3RD([libavc1394],[auto],
251   [libavc1394-0.5.4],
252   [ libavc1394/.libs/libavc1394.a \
253     librom1394/.libs/librom1394.a \
254     common/.libs/libraw1394util.a ],
255   [ . ])
256
257 PKG_3RD([libraw1394],[auto],
258   [libraw1394-2.1.2],
259   [ src/.libs/libraw1394.a ],
260   [ . ])
261
262 PKG_3RD([libiec61883],[auto],
263   [libiec61883-1.2.0],
264   [ src/.libs/libiec61883.a ],
265   [ src ])
266
267 PKG_3RD([libdv],[auto],
268   [libdv-1.0.0],
269   [ libdv/.libs/libdv.a ],
270   [ . ])
271
272 PKG_3RD([libjpeg],[auto],
273   [libjpeg-turbo-2.0.4],
274   [ build/libjpeg.a \
275     build/libturbojpeg.a ],
276   [ opt/libjpeg-turbo/include ])
277
278 PKG_3RD([opus],[auto],
279   [opus-1.3.1],
280   [ .libs/libopus.a ],
281   [ include ])
282
283 PKG_3RD([openjpeg],[auto],
284   [openjpeg-2.3.1],
285   [ bin/libopenjp2.a ],
286   [ src/lib/openjp2 ])
287
288 PKG_3RD([libogg],[auto],
289   [libogg-1.3.4],
290   [ src/.libs/libogg.a ],
291   [ include ])
292
293 PKG_3RD([libsndfile],[auto],
294   [libsndfile-1.0.28],
295   [ src/.libs/libsndfile.a \
296     src/.libs/libcommon.a \
297     src/G72x/.libs/libg72x.a \
298     src/GSM610/.libs/libgsm.a ],
299   [ . ])
300
301 PKG_3RD([libtheora],[auto],
302   [libtheora-1.1.1],
303   [ lib/.libs/libtheora.a \
304     lib/.libs/libtheoradec.a \
305     lib/.libs/libtheoraenc.a ],
306   [ include ])
307
308 PKG_3RD([libuuid],[yes],
309   [libuuid-1.0.3],
310   [ .libs/libuuid.a ],
311   [ . ])
312
313 PKG_3RD([libvorbis],[auto],
314   [libvorbis-1.3.6],
315   [ lib/.libs/libvorbis.a \
316     lib/.libs/libvorbisenc.a \
317     lib/.libs/libvorbisfile.a ],
318   [ include . ])
319
320 PKG_3RD([mjpegtools],[yes],
321   [mjpegtools-2.1.0],
322   [ utils/mmxsse/.libs/libmmxsse.a \
323     utils/.libs/libmjpegutils.a \
324     lavtools/.libs/liblavfile.a \
325     lavtools/.libs/liblavjpeg.a \
326     mplex/.libs/libmplex2.a \
327     yuvfilters/.libs/libyuvfilters.a \
328     mpeg2enc/.libs/libmpeg2encpp.a ],
329   [ .  lavtools utils ])
330
331 PKG_3RD([openexr],[auto],
332   [openexr-2.4.1],
333   [ usr/local/lib/libHalf.a \
334     usr/local/lib/libIex.a \
335     usr/local/lib/libIexMath.a \
336     usr/local/lib/libIlmThread.a \
337     usr/local/lib/libImath.a \
338     usr/local/lib/libIlmImf.a \
339     usr/local/lib/libIlmImfUtil.a ],
340   [ usr/local/include/OpenEXR ])
341
342 PKG_3RD([openExr],[auto], [openExr], [] [])
343 PKG_3RD([ilmBase],[auto], [ilmBase], [] [])
344
345 #PKG_3RD([festival],[no],
346 #  [festival],
347 #  [],
348 #  [])
349 #PKG_3RD(speech_tools,[no],
350 #  [speech_tools],
351 #  [],
352 #  [])
353 #
354 PKG_3RD([tiff],[auto],
355   [tiff-4.1.0],
356   [ libtiff/.libs/libtiff.a \
357     libtiff/.libs/libtiffxx.a \
358     port/.libs/libport.a ],[
359    . ])
360
361 PKG_3RD([twolame],[auto],
362   [twolame-0.4.0],
363   [ libtwolame/.libs/libtwolame.a ],
364   [  libtwolame ])
365
366 PKG_3RD([x264],[auto],
367   [x264-snapshot-20191217-2245-stable],
368   [ libx264.a ],
369   [ . ])
370
371 PKG_3RD([x265],[auto],
372   [x265_3.2.1],
373   [ libx265.a ],
374   [ . source ])
375
376 PKG_3RD([libvpx],[auto],
377   [libvpx-1.8.1],
378   [ libvpx.a ],
379   [ . ])
380
381 PKG_3RD([lv2],[auto],
382   [lv2-1.16.0],
383   [ ],
384   [ usr/local/include usr/local/lib64/lv2 usr/local/lib/lv2 ])
385
386 PKG_3RD([sratom],[auto],
387   [sratom-0.6.4],
388   [ usr/local/lib/libsratom-0.a ],
389   [ usr/local/include ])
390
391 PKG_3RD([serd],[auto],
392   [serd-0.30.2],
393   [ usr/local/lib/libserd-0.a ],
394   [ usr/local/include ])
395
396 PKG_3RD([sord],[auto],
397   [sord-0.16.4],
398   [ usr/local/lib/libsord-0.a ],
399   [ usr/local/include ])
400
401 PKG_3RD([lilv],[auto],
402   [lilv-0.24.6],
403   [ usr/local/lib/liblilv-0.a ],
404   [ usr/local/include ])
405
406 PKG_3RD([suil],[auto],
407   [suil-0.10.6],
408   [ usr/local/lib/libsuil-0.a ],
409   [ usr/local/include ])
410
411 PKG_3RD([libaom],[auto],
412   [libaom-v1.0.0],
413   [ usr/local/lib*/libaom*.a ],
414   [ usr/local/include ])
415
416 PKG_3RD([dav1d],[auto],
417   [dav1d-0.5.1],
418   [ usr/local/lib*/libdav1d*.a ],
419   [ usr/local/include ])
420
421 PKG_3RD([libwebp],[auto],
422   [libwebp-1.1.0],
423   [ usr/local/lib*/libwebp*.a ],
424   [ usr/local/include ])
425
426 PKG_3RD([ffnvcodec],[auto],
427   [ffnvcodec],
428   [ ],
429   [ . ])
430
431 AC_SUBST(STATIC_PKGS)
432
433 AC_DEFUN([CHECK_ENABLE], [
434 AC_ARG_ENABLE([$1],
435   AC_HELP_STRING([--enable-[$1]], [$3 ([$4])]),
436   [WANT_$2=$enableval], [WANT_$2=[$4]])
437 ])
438
439 CHECK_ENABLE([static-build], [STATIC_BUILD], [build static], [auto])
440 CHECK_ENABLE([x264_hidepth], [X264_HIDEPTH], [build x264 10bit], [no])
441 CHECK_ENABLE([x265_hidepth], [X265_HIDEPTH], [build x265 10bit], [no])
442
443 test "x$WANT_STATIC_BUILD" = "xauto" && WANT_STATIC_BUILD=$WANT_CINBIN_BUILD
444
445 AC_DEFUN([CHECK_PROG], [
446  AC_CHECK_PROG([PROG_$1], [$2], [yes],[no])
447 ])
448 AC_DEFUN([REQUIRE_PROG], [
449  CHECK_PROG([$1],[$2])
450  if test "x$PROG_$1" = "xno"; then
451    AC_MSG_WARN([$2 is missing and required.])
452    FATAL_ERROR=1
453  fi
454 ])
455
456 ## arch dep tests
457 ARCH=[`uname -m`]
458 I86=[`expr "x$ARCH" : 'xi[346]86.*'`]
459 X86=[`expr "x$ARCH" : 'x..._64*'`]
460
461 if test "x$I86$X86" != "x00" ; then
462   # Checks for ix86 programs.
463   REQUIRE_PROG(NASM, [nasm])
464   # libx264 nasm fix
465   AC_MSG_CHECKING([nasm x264 compatible])
466   echo "vmovdqa32 [[eax]]{k1}{z}, zmm0" > conftest.asm
467   nasm conftest.asm -o conftest.o > /dev/null 2>&1
468   if test $? != 0 ; then
469    AC_MSG_RESULT([no])
470    AC_MSG_WARN([libx264 built without assembly code])
471    X264_CFG_PARAMS="$X264_CFG_PARAMS --disable-asm"
472   else
473    AC_MSG_RESULT([yes])
474   fi
475   rm -f conftest.asm conftest.o
476   REQUIRE_PROG(YASM, [yasm])
477 fi
478
479 ## end arch dep tests
480
481 REQUIRE_PROG(OBJCOPY, [objcopy])
482 if test "x$FATAL_ERROR" != "x"; then
483  AC_MSG_ERROR("fatal eror.")
484 fi
485 CHECK_PROG(PACTL, [pactl])
486 WANT_PACTL=$PROG_PACTL
487
488 AC_CHECK_DECL([X_HAVE_UTF8_STRING],,[no_utf=yes],[#include <X11/Xlib.h>])
489 if test "$no_utf" = "yes"; then
490   AC_MSG_ERROR([Cinelerra requires utf8 support in X Windows.])
491 fi
492
493 # Checks for headers/libraries.
494
495 AC_DEFUN([CHECK_HEADERS], [
496 if test "x$HAVE_$1" != "xno"; then
497  AC_CHECK_HEADER(m4_apply([m4_car],m4_split([$3])), [HAVE_$1=yes], [HAVE_$1=no],
498   [m4_foreach([i], m4_split([$3]), [[#include "]i["
499 ]])])
500  AC_SUBST([HAVE_$1])
501  AC_MSG_CHECKING([$2])
502  AC_MSG_RESULT([$HAVE_$1])
503  if test "x$HAVE_$1" = "xno"; then
504   if test "x$PKG_$1" = "x"; then RESULT=no; fi
505  fi
506 fi
507 ])
508
509 AC_DEFUN([CHECK_LIB], [
510 if test "x$HAVE_$1" != "xno"; then
511  if test "x$PKG_$1" = "x" -o "x$WANT_STATIC_BUILD" = "xno" -a "x$PKG_$1" != "xno"; then
512   AC_CHECK_LIB([$2], [$3], [HAVE_$1=yes], [HAVE_$1=no], [$4])
513   AC_SUBST([HAVE_$1])
514   if test "x$WANT_$1" != "xno"; then
515    if test "x$HAVE_$1" = "xyes"; then
516     if test "x$PKG_$1" = "x"; then
517      SYSTEM_LIBS+=" -l[$2]"
518      for lib in [$4]; do SYSTEM_LIBS+=" $lib"; done
519     else
520      SHARED_$1+=" -l[$2]"
521      for lib in [$4]; do SHARED_LIBS+=" $lib"; done
522     fi
523    elif test "x$PKG_$1" = "x"; then
524     RESULT=no
525    fi
526   fi
527  fi
528 fi
529 ])
530
531 CHECK_LIB([X11], [X11], [XOpenDisplay])
532 CHECK_HEADERS([X11], [X11 headers], [X11/X.h X11/Xlib.h X11/Xutil.h X11/cursorfont.h])
533 CHECK_HEADERS([X11], [X11 headers], [X11/keysym.h X11/Sunkeysym.h X11/Xatom.h X11/XF86keysym.h])
534 CHECK_LIB([XEXT], [Xext], [XShmQueryExtension])
535 CHECK_HEADERS([XEXT], [Xlib XShm extention], [X11/Xlib.h X11/extensions/XShm.h X11/extensions/shape.h])
536 CHECK_LIB([XINERAMA], [Xinerama], [XineramaQueryExtension])
537 CHECK_HEADERS([XINERAMA], [Xinerama headers], [X11/extensions/Xinerama.h])
538 CHECK_LIB([XFIXES], [Xfixes], [XFixesQueryVersion])
539 CHECK_LIB([BZ2], [bz2], [BZ2_bzDecompress])
540 CHECK_LIB([FONTCONFIG], [fontconfig], [FcInit])
541 CHECK_LIB([FREETYPE], [freetype], [FT_Init_FreeType])
542 CHECK_LIB([LZMA], [lzma], [lzma_version_number])
543 CHECK_LIB([PNG], [png], [png_read_png])
544 CHECK_LIB([PTHREAD], [pthread], [pthread_create])
545 CHECK_LIB([Z], [z], [gzopen])
546 CHECK_LIB([fftw], [fftw3], [fftw_execute])
547 CHECK_HEADERS([fftw], [fftw headers], [fftw3.h])
548 CHECK_LIB([libuuid], [uuid], [uuid_clear])
549 CHECK_HEADERS([libuuid], [uuid headers], [uuid/uuid.h])
550 CHECK_HEADERS([LINUX_CDROM], [linux cdrom headers], [linux/cdrom.h linux/futex.h])
551 CHECK_HEADERS([LINUX_SYS], [linux sys], [sys/ioctl.h sys/stat.h sys/types.h sys/time.h sys/syscall.h])
552 CHECK_LIB([flac], [FLAC], [FLAC__stream_decoder_new])
553 CHECK_HEADERS([flac], [FLAC headers], [FLAC/stream_decoder.h])
554 CHECK_LIB([lame], [mp3lame], [lame_init])
555 CHECK_HEADERS([lame], [lame headers], [lame/lame.h])
556 CHECK_LIB([libjpeg], [jpeg], [jpeg_start_decompress])
557 CHECK_HEADERS([libjpeg], [jpeg headers], [stdio.h jpeglib.h])
558 CHECK_LIB([openjpeg], [openjp2], [opj_version])
559 CHECK_HEADERS([openjpeg], [openjpeg headers], [openjpeg.h])
560 CHECK_LIB([libsndfile], [sndfile], [sf_open])
561 CHECK_HEADERS([libsndfile], [sndfile headers], [sndfile.h])
562 CHECK_LIB([ilmbase], [IlmImf], [ImfOpenInputFile])
563 CHECK_HEADERS([ilmbase], [IlmImf headers], [OpenEXR/ImfCRgbaFile.h])
564 CHECK_LIB([libvpx], [vpx], [vpx_codec_decode])
565 CHECK_HEADERS([libvpx], [vpx headers], [vpx/vpx_decoder.h])
566 CHECK_LIB([mjpegtools], [mjpegutils], [mjpeg_info])
567 CHECK_HEADERS([mjpegtools], [mjpegtools headers], [mjpegtools/mjpeg_types.h])
568 CHECK_LIB([tiff], [tiff], [TIFFOpen])
569 CHECK_HEADERS([tiff], [tiff headers], [tiff.h tiffio.h])
570 CHECK_LIB([twolame], [twolame], [twolame_encode_buffer_float32_interleaved])
571 CHECK_HEADERS([twolame], [twolame headers], [twolame.h])
572 CHECK_LIB([x264], [x264], [x264_encoder_encode])
573 CHECK_HEADERS([x264], [x264 headers], [stdint.h x264.h])
574 CHECK_LIB([x265], [x265], [x265_encoder_encode])
575 CHECK_HEADERS([x265], [x265 headers], [x265.h])
576 CHECK_LIB([opus], [opus], [opus_multistream_decoder_create])
577 CHECK_HEADERS([opus], [libopus headers], [opus/opus_multistream.h])
578 CHECK_LIB([libaom], [aom], [aom_codec_version])
579 CHECK_HEADERS([libaom], [libaom headers], [aom/aom.h])
580 CHECK_LIB([dav1d], [dav1d], [dav1d_version])
581 CHECK_HEADERS([dav1d], [libdav1d headers], [dav1d/dav1d.h])
582 CHECK_LIB([libwebp], [webp], [WebPGetEncoderVersion])
583 CHECK_HEADERS([libwebp], [libwebp headers], [webp/encode.h])
584 CHECK_LIB([a52dec], [a52], [a52_init])
585 CHECK_HEADERS([a52dec], [a52 headers], [stdint.h a52.h])
586 CHECK_LIB([encore], [encore], [encore])
587 CHECK_HEADERS([encore], [encore headers], [encore.h])
588 CHECK_LIB([giflib], [gif], [DGifOpen])
589 CHECK_HEADERS([giflib], [gif lib headers], [gif_lib.h])
590 CHECK_LIB([jbig], [jbig], [jbg_dec_init])
591
592 CHECK_LIB([VDPAU], [vdpau], [vdp_device_create_x11])
593 if test "x$HAVE_VDPAU" != "xyes" -a "x$WANT_VDPAU" = "xyes"; then
594   AC_MSG_ERROR([requires vdpau support.])
595 fi
596
597 CHECK_LIB([VAAPI], [va], [vaInitialize])
598 if test "x$HAVE_VAAPI" = "xyes" -a "x$WANT_VAAPI" != "xno"; then
599   CHECK_HEADERS([vaapi_x11], [va x11 headers], [va/va_x11.h])
600   CHECK_LIB([vaapi_x11], [va-x11], [vaGetDisplay])
601   CHECK_HEADERS([vaapi_drm], [va drm headers], [va/va_drm.h])
602   CHECK_LIB([vaapi_drm], [va-drm], [vaGetDisplayDRM])
603 fi
604 if test "x$HAVE_VAAPI" != "xyes" -a "x$WANT_VAAPI" = "xyes"; then
605   AC_MSG_ERROR([requires vaapi support.])
606 fi
607
608 #CHECK_LIB([NVENC], [nvidia-encode], [NvEncodeAPICreateInstance])
609
610 #if test "x$HAVE_mjpegtools" = "xyes"; then
611 #CFG_CFLAGS+=" -I/usr/include/mjpegtools -I/usr/local/include/mjpegtools"
612 #fi
613
614 AC_DEFUN([CHECK_WANT], [
615 RESULT=yes
616 # WANT_$1
617 AC_ARG_WITH(m4_tolower([$1]),
618  AC_HELP_STRING([m4_join([-],[--with],m4_tolower([$1]))], [$3] (auto)),
619   [WANT_$1=$withval],[WANT_$1=$2])
620  m4_quote($4)
621  if test "x$WANT_$1" = "xauto" ; then
622   WANT_$1="$RESULT"
623  elif test "x$WANT_$1" = "xyes" ; then
624   if test "x$RESULT" = "xno" -a "x$PKG_$1" = "x"; then
625     AC_MSG_ERROR([required for $1 support.])
626   fi
627  fi
628 CFG_WANTS+=" $1"
629 AC_SUBST([WANT_$1])
630 ])
631
632 CHECK_WANT([GL], [auto], [use opengl], [
633  CHECK_LIB([GL], [GL], [glUseProgram])
634  CHECK_LIB([GL], [GLU], [gluOrtho2D])
635  CHECK_HEADERS([GL], [opengl headers], [GL/gl.h GL/glext.h GL/glu.h GL/glx.h])])
636
637 CHECK_WANT([XV], [auto], [use xv], [
638  CHECK_LIB([xv], [Xv], [XvQueryExtension])
639  CHECK_HEADERS([xv], [Xlib Xv extention], [X11/Xlib.h X11/extensions/Xvlib.h])])
640
641 CHECK_WANT([OSS], [auto], [use OSS audio], [
642  CHECK_HEADERS([OSS], [oss headers], [sys/soundcard.h])])
643
644 CHECK_WANT([XFT], [auto], [use libXft], [
645  CHECK_LIB([XFT], [Xft], [XftInit])
646  CHECK_HEADERS([XFT], [Xft/freetype headers], [X11/Xlib.h X11/Xft/Xft.h])])
647
648 CHECK_WANT([ALSA], [auto], [use libasound/alsa], [
649  CHECK_LIB([ALSA], [asound], [snd_pcm_open])
650  CHECK_HEADERS([ALSA], [asound headers], [alsa/asoundlib.h])])
651
652 CHECK_WANT([OGG], [auto], [use ogg/theora/vorbis], [
653  CHECK_LIB([libogg], [ogg], [ogg_stream_init])
654  CHECK_HEADERS([libogg], [ogg headers], [ogg/ogg.h])
655  CHECK_LIB([libtheora], [theora], [theora_info_init], [-ltheoraenc -ltheoradec -logg])
656  CHECK_HEADERS([libtheora], [threora headers], [theora/theoraenc.h])
657  CHECK_LIB([libvorbis], [vorbisenc], [vorbis_encode_init], [-lvorbis -lvorbisfile -logg])
658  CHECK_HEADERS([libvorbis], [vorbis encoders headers], [vorbis/vorbisenc.h])
659  CHECK_LIB([libvorbis], [vorbisfile], [ov_open])
660  CHECK_HEADERS([libvorbis], [vorbis file headers], [vorbis/vorbisfile.h])])
661
662 CHECK_WANT([FIREWIRE], [auto], [use firewire], [
663  CHECK_LIB([libavc1394], [avc1394], [avc1394_init_target])
664  CHECK_HEADERS([libavc1394], [libavc1394 headers], [libavc1394/avc1394.h])
665  CHECK_LIB([libavc1394], [rom1394], [rom1394_get_bus_id])
666  CHECK_HEADERS([libavc1394], [librom1394 headers], [libavc1394/rom1394.h])
667  CHECK_LIB([libiec61883], [iec61883], [iec61883_mpeg2_recv_init])
668  CHECK_HEADERS([libiec61883], [libiec61883 headers], [libiec61883/iec61883.h])
669  CHECK_LIB([libraw1394], [raw1394], [raw1394_iso_recv_init])
670  CHECK_HEADERS([libraw1394], [libraw1394 headers], [libraw1394/raw1394.h])])
671 # have all or none
672 test "x$HAVE_libavc1394" = "xyes" && \
673 test "x$HAVE_libiec61883" = "xyes" && \
674 test "x$HAVE_libraw1394" = "xyes" && \
675   HAVE_FIREWIRE=yes || \
676 HAVE_libavc1394=no && \
677 HAVE_libiec61883=no && \
678 HAVE_libraw1394=no && \
679  HAVE_FIREWIRE=no
680
681 CHECK_WANT([DV], [auto], [use dv], [
682  CHECK_LIB([libdv], [dv], [dv_init])
683  CHECK_HEADERS([libdv], [libdv headers], [libdv/dv.h])])
684
685 CHECK_WANT([DVB], [auto], [use dvb], [
686  CHECK_HEADERS([DVB], [dvb device headers], [linux/dvb/dmx.h linux/dvb/frontend.h])])
687
688 CHECK_WANT([VIDEO4LINUX2], [auto], [use v4l2], [
689  CHECK_HEADERS([VIDEO4LINUX2], [v4l2 system headers], [linux/kernel.h linux/types.h linux/videodev2.h])])
690
691 CHECK_WANT([XXF86VM], [auto], [use xf86vmode], [
692  CHECK_HEADERS([XXF86VM], [XF86VM headers], [X11/Xlib.h X11/extensions/xf86vmode.h])])
693
694 CHECK_WANT([ESOUND], [no], [use esd], [
695  CHECK_LIB([esound], [esd], [esd_open_sound])
696  CHECK_HEADERS([esound], [esound headers], [esd.h])
697  CHECK_LIB([audiofile], [audiofile], [afOpenFile])
698  CHECK_HEADERS([audiofile], [audiofile headers], [audiofile.h])])
699 # have all or none
700 test "x$HAVE_esound" = "xyes" && \
701 test "x$HAVE_audiofile" = "xyes" && \
702   HAVE_ESOUND=yes || \
703 HAVE_esound=no && \
704 HAVE_audiofile=no && \
705   HAVE_ESOUND=no
706
707 CHECK_WANT([PULSE], [auto], [use pulseaudio], [
708  CHECK_LIB([pulse_simple], [pulse-simple], [pa_simple_new])
709  CHECK_HEADERS([pulse_simple], [pulse-simple headers], [pulse/simple.h])
710  CHECK_LIB([pulse], [pulse], [pa_context_new])
711  CHECK_HEADERS([pulse], [pulse headers], [pulse/error.h])])
712
713 CHECK_WANT([ISOFS], [auto], [use isofs], [
714  CHECK_HEADERS([isofs], [isofs headers], [linux/isofs.h])])
715
716 if test "x$WANT_LADSPA_BUILD" != "xyes" ; then
717  CHECK_WANT([LADSPA], [auto], [ladspa plugin clients], [
718   CHECK_HEADERS([ladspa], [ladspa headers], [ladspa.h])])
719 else
720  WANT_LADSPA=yes
721 fi
722
723 CHECK_WANT([SHUTTLE], [yes], [shuttle dev support], [
724  CHECK_HEADERS([keysyms], [x11 keysym defs], [X11/keysymdef.h])])
725 if test "x$WANT_SHUTTLE" = "xno"; then
726  WANT_SHUTTLE_USB="no"
727 fi
728 CHECK_WANT([SHUTTLE_USB], [yes], [use libusb-1.0], [
729  CHECK_LIB([libusbx], [usb-1.0], [libusb_init])
730  CHECK_HEADERS([libusbx], [libusb headers], [libusb-1.0/libusb.h])])
731
732 CHECK_WANT([LV2], [auto], [use lv2], [
733  saved_CFLAGS="$CFLAGS"
734  CHECK_LIB([lilv], [lilv-0], [lilv_world_new])
735  CHECK_LIB([sord], [sord-0], [sord_world_new])
736  CHECK_LIB([serd], [serd-0], [serd_reader_new])
737  CHECK_LIB([sratom], [sratom-0], [sratom_new])
738  CFLAGS="-I/usr/include/lilv-0 -I/usr/local/include/lilv-0"
739  CHECK_HEADERS([lv2], [lilv headers], [lilv/lilv.h])
740  CHECK_LIB([suil], [suil-0], [suil_instance_new])
741  CFLAGS="-I/usr/include/suil-0 -I/usr/local/include/suil-0"
742  CHECK_HEADERS([lv2], [suil headers], [suil/suil.h])
743  CFLAGS="$saved_CFLAGS"])
744 # have all or none
745 test "x$HAVE_lv2" = "xyes" && \
746 test "x$HAVE_lilv" = "xyes" && \
747 test "x$HAVE_sord" = "xyes" && \
748 test "x$HAVE_serd" = "xyes" && \
749 test "x$HAVE_sratom" = "xyes" && \
750 test "x$HAVE_suil" = "xyes" && \
751   HAVE_LV2=yes || \
752 HAVE_lv2=no && \
753 HAVE_lilv=no && \
754 HAVE_sord=no && \
755 HAVE_serd=no && \
756 HAVE_sratom=no && \
757 HAVE_suil=no && \
758   HAVE_LV2=no
759
760 CHECK_WANT([CUDA], [auto], [build cuda plugins], [
761   CHECK_HEADERS([CUDA], [cuda sdk], [${CUDA_PATH:-/usr/local/cuda}/include/cuda.h])])
762
763 CHECK_WANT([DL], [auto], [system has libdl], [
764  CHECK_LIB([DL], [dl], [dlopen])])
765
766 CHECK_WANT([OPENCV], [no], [opencv=sys/sta/dyn,git/tar=url], [
767 ])
768
769 CHECK_WANT([NUMA], [auto], [system has libnuma], [
770  CHECK_LIB([NUMA], [numa], [numa_alloc])])
771
772 CHECK_WANT([OPENEXR], [auto], [use openexr], [
773  AC_MSG_CHECKING([for openexr available])
774  saved_LIBS="$LIBS"
775  saved_CXXFLAGS="$CXXFLAGS"
776  # ilmbase libs
777  LIBS=" -lIlmImf -lIlmThread -lIex -lpthread"
778  CXXFLAGS="-I/usr/include/OpenEXR -I/usr/local/include/OpenEXR"
779  AC_LANG_PUSH(C++)
780  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
781 #include "ImfChannelList.h"
782 #include "ImfChromaticities.h"
783 #include "ImfCompression.h"
784 #include "ImfIO.h"
785 #include "ImfInputFile.h"
786 #include "ImfOutputFile.h"
787 #include "ImfPixelType.h"
788 #include "ImfRgbaFile.h"
789 #include "ImfRgbaYca.h"
790 #include "ImfVersion.h"
791 class EXRIStream : public Imf::IStream { public:
792 EXRIStream() : Imf::IStream("mypath") {} };
793 class EXROStream : public Imf::OStream { public: 
794 EXROStream() : Imf::OStream("mypath") {} };
795 ]])], [HAVE_OPENEXR=yes], [HAVE_OPENEXR=no])
796  if test "x$WANT_OPENEXR" = "xauto"; then
797    WANT_OPENEXR="yes"
798  fi
799  if test "x$WANT_OPENEXR" = "xyes" -a "x$HAVE_OPENEXR" = "xyes"; then
800   if test "x$WANT_STATIC_BUILD" = "xno"; then
801     SHARED_openexr="$LIBS"
802     SHARED_LIBS+=" $LIBS"
803     CFG_CFLAGS+=" -I/usr/include/OpenEXR -I/usr/local/include/OpenEXR"
804   fi
805  fi
806  LIBS="$saved_LIBS"
807  CXXFLAGS="$saved_CXXFLAGS"
808  AC_LANG_POP(C++)
809  AC_MSG_RESULT([$HAVE_OPENEXR])
810 ])
811 AC_SUBST([HAVE_OPENEXR])
812 # have all or none
813 test "x$HAVE_openexr" = "xyes" && \
814 test "x$HAVE_ilmbase" = "xyes" && \
815   HAVE_OPENEXR=yes || \
816 HAVE_openexr=no && \
817 HAVE_ilmbase=no &&
818   HAVE_OPENEXR=no
819
820 # build global_config
821 OBJDIR=`uname -m`
822 AC_SUBST(OBJDIR)
823
824 echo "AC_HELP_STRING([Reason],[Package])"
825 echo "AC_HELP_STRING([------],[-------])"
826
827 AC_DEFUN([PKG_DISABLED],[
828  PKG_$1="no"
829  BUILD_$1=0
830  AC_SUBST(BUILD_$1)
831  echo "AC_HELP_STRING([disabled],[$1])"
832 ])
833 AC_DEFUN([PKG_SHARED],[
834  PKG_$1="shared"
835  BUILD_$1=0
836  AC_SUBST(BUILD_$1)
837  SHARED_LIBS+="$SHARED_$1"
838 ])
839
840 AC_DEFUN([PKG_STATIC],[
841  if test "x$WANT_CIN_3RDPARTY" != "xno"; then
842   PKG_$1="yes"
843   BUILD_$1=1
844   AC_SUBST(BUILD_$1)
845   STATIC_BLDS+=" [$1]"
846   echo "AC_HELP_STRING([$2],[$1])"
847  fi
848 ])
849
850 AC_DEFUN([PKG_FORCED],[PKG_STATIC([$1],[forced])])
851
852 if test "x$WANT_CIN_3RDPARTY" != "xno"; then
853 # order matters
854 for dep in \
855         ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
856         ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/x265 \
857         libiec61883/libraw1394 libavc1394/librom1394 \
858         openexr/ilmbase ilmbase/libogg \
859         libtheora/libogg libtheora/libvorbis ; do
860   lib=`dirname $dep`;  needs=`basename $dep`
861   eval pkg_lib="\$PKG_$lib"
862   if test "x$pkg_lib" != "xno"; then
863     eval "PKG_$needs=yes"
864   fi
865 done
866 fi
867
868 AC_DEFUN([PKG_PROVIDE],[
869 if test "x$BUILD_$1" = "x" ; then
870  if test "x$PKG_$1" = "xyes"; then
871   if test "x$WANT_CIN_3RDPARTY" = "xno"; then
872     PKG_SHARED([$1])
873   else
874     PKG_FORCED([$1])
875   fi
876  elif test "x$2" = "xno" -o "x$PKG_$1" = "xno"; then
877   PKG_DISABLED([$1])
878  elif test "x$WANT_STATIC_BUILD" = "xyes"; then
879   PKG_STATIC([$1],[static])
880  elif test "x$HAVE_$1" = "xyes"; then
881   PKG_SHARED([$1])
882  else
883   PKG_STATIC([$1],[needed])
884  fi
885 fi
886 ])
887
888 PKG_PROVIDE([a52dec])
889 PKG_PROVIDE([djbfft])
890 PKG_PROVIDE([encore])
891 PKG_PROVIDE([audiofile],[$WANT_ESOUND])
892 PKG_PROVIDE([esound],[$WANT_ESOUND])
893 PKG_PROVIDE([ffmpeg])
894 PKG_PROVIDE([fftw])
895 PKG_PROVIDE([flac])
896 PKG_PROVIDE([giflib])
897 PKG_PROVIDE([ilmBase], [$WANT_OPENEXR])
898 PKG_PROVIDE([ladspa],[$WANT_LADSPA_BUILD])
899 PKG_PROVIDE([lame])
900 PKG_PROVIDE([libavc1394],[$WANT_FIREWIRE])
901 PKG_PROVIDE([libraw1394],[$WANT_FIREWIRE])
902 PKG_PROVIDE([libiec61883],[$WANT_FIREWIRE])
903 PKG_PROVIDE([libdv],[$WANT_DV])
904 PKG_PROVIDE([libjpeg])
905 PKG_PROVIDE([libogg])
906 PKG_PROVIDE([libsndfile])
907 PKG_PROVIDE([libtheora])
908 PKG_PROVIDE([libuuid])
909 PKG_PROVIDE([libvorbis])
910 PKG_PROVIDE([mjpegtools])
911 PKG_PROVIDE([libaom])
912 PKG_PROVIDE([dav1d])
913 PKG_PROVIDE([libwebp])
914 PKG_PROVIDE([openExr], [$WANT_OPENEXR])
915 PKG_PROVIDE([openexr], [$WANT_OPENEXR])
916 PKG_PROVIDE([openjpeg])
917 PKG_PROVIDE([tiff])
918 PKG_PROVIDE([twolame])
919 PKG_PROVIDE([x264])
920 PKG_PROVIDE([x265])
921 PKG_PROVIDE([libvpx])
922 PKG_PROVIDE([opus])
923 PKG_PROVIDE([lv2], [$WANT_LV2])
924 PKG_PROVIDE([lilv], [$WANT_LV2])
925 PKG_PROVIDE([sratom], [$WANT_LV2])
926 PKG_PROVIDE([serd], [$WANT_LV2])
927 PKG_PROVIDE([sord], [$WANT_LV2])
928 PKG_PROVIDE([suil], [$WANT_LV2])
929 PKG_PROVIDE([ffnvcodec], [$WANT_NV])
930
931 if test "x$WANT_LV2" = "xyes"; then
932   if test "x$HAVE_lv2" = "xyes" -a "x$BUILD_lilv" = "x0"; then
933     CFG_CFLAGS+=' -I/usr/include/lilv-0 -I/usr/local/include/lilv-0'
934     CFG_CFLAGS+=' -I/usr/include/suil-0 -I/usr/local/include/suil-0'
935   fi
936 fi
937
938 AC_SUBST(STATIC_BLDS)
939 for f in $SHARED_LIBS; do
940   echo "AC_HELP_STRING([shared],[$f])"
941 done
942 AC_SUBST(SHARED_LIBS)
943 for f in $SYSTEM_LIBS; do
944   echo "AC_HELP_STRING([system],[$f])"
945 done
946 AC_SUBST(SYSTEM_LIBS)
947
948 echo ""
949 if test "x$WANT_CIN_3RDPARTY" != "xno"; then
950   CFG_CFLAGS+=" -DHAVE_CIN_3RDPARTY"
951 fi
952 for v in GL XFT XXF86VM OSS ALSA FIREWIRE OGG DV DVB LADSPA \
953          VIDEO4LINUX2 ESOUND PULSE PACTL OPENEXR LV2 \
954          COMMERCIAL LIBZMPEG SHUTTLE SHUTTLE_USB XV \
955          VAAPI VDPAU CUDA NV WINTV X10TV; do
956   eval vv="\$WANT_$v"
957   if test "x$vv" != "xno"; then
958     CFG_CFLAGS+=" -DHAVE_$v"
959     vv=with
960   else
961     vv=without
962   fi
963   v=`echo "$v" | tr "A-Z" "a-z"`
964   echo "  using: $vv-$v"
965 done
966
967 # build extras
968 if test "x$WANT_CLANG" = "xyes" ; then
969   FFMPEG_EXTRA_CFG+=' --cc=clang --cxx=clang++'
970 fi
971 if test "x$HAVE_tiff" = "xyes"; then
972   if test "x$HAVE_jbig" = "xyes"; then
973     EXTRA_LIBS+=' -ljbig'
974   fi
975 fi
976 if test "x$HAVE_NUMA" = "xyes"; then
977   EXTRA_LIBS+=' -lnuma'
978 fi
979
980 FFMPEG_EXTRA_LDFLAGS=""
981 if test "x$WANT_VAAPI" != "xno" -a "x$HAVE_VAAPI" = "xyes"; then
982   FFMPEG_EXTRA_LDFLAGS+=' -lva'
983   EXTRA_LIBS+=' -lva'
984   WANT_VAAPI="yes"
985   if test "x$HAVE_vaapi_x11" = "xyes"; then
986     FFMPEG_EXTRA_LDFLAGS+=' -lva-x11'
987     EXTRA_LIBS+=' -lva-x11'
988   fi
989   if test "x$HAVE_vaapi_drm" = "xyes"; then
990     FFMPEG_EXTRA_LDFLAGS+=' -lva-drm'
991     EXTRA_LIBS+=' -lva-drm'
992   fi
993 fi
994 CFG_WANTS+=" VAAPI"
995
996 if test "x$WANT_VDPAU" != "xno" -a "x$HAVE_VDPAU" = "xyes"; then
997   WANT_VDPAU="yes"
998 fi
999 CFG_WANTS+=" VDPAU"
1000
1001 if test "x$WANT_NV" != "xno"; then
1002   WANT_NV="yes"
1003   CFG_WANTS+=" NV"
1004 fi
1005
1006 if test "x$HAVE_DL" = "xyes"; then
1007   EXTRA_LIBS+=' -ldl'
1008   FFMPEG_EXTRA_LDFLAGS+=' -ldl'
1009 fi
1010 if test "x$FFMPEG_EXTRA_LDFLAGS" != "x"; then
1011   FFMPEG_EXTRA_CFG+=' --extra-ldflags="'$FFMPEG_EXTRA_LDFLAGS'"'
1012 fi
1013
1014 if test "x$WANT_BOOBY" != "xno"; then
1015   CFG_CFLAGS+=" -DBOOBY"
1016 fi
1017
1018 # intel lock elision bugs
1019 if test "x$WANT_NOELISION" != "xno"; then
1020   CFG_RPATH=`ls -1fd 2> /dev/null \
1021  /usr/lib/noelision \
1022  /lib/noelision \
1023  /usr/lib64/noelision \
1024  /lib64/noelision \
1025   | tail -1`
1026 fi
1027
1028 echo "  using: with-jobs = $WANT_JOBS"
1029 echo "  using: exec-name = $WANT_CIN"
1030 echo "  using: with-cinlib = $WANT_CINLIB_DIR"
1031 echo "  using: with-cindat = $WANT_CINDAT_DIR"
1032 echo "  using: with-config-dir = $WANT_CONFIG_DIR"
1033 echo "  using: with-nested-dir = $WANT_NESTED_DIR"
1034 echo "  using: with-snap-dir = $WANT_SNAP_DIR"
1035 echo "  using: with-browser = $WANT_CIN_BROWSER"
1036 echo "  using: with-plugin-dir = $WANT_PLUGIN_DIR"
1037 echo "  using: with-ladspa-dir = $WANT_LADSPA_DIR"
1038 echo "  using: with-opencv = $WANT_OPENCV"
1039 echo "  using: with-git-ffmpeg = $WANT_GIT_FFMPEG"
1040 echo "  using: with-noelision = $WANT_NOELISION"
1041 echo "  using: with-booby = $WANT_BOOBY"
1042 echo "  using: with-clang = $WANT_CLANG"
1043 echo ""
1044 echo "  using: thirdparty build = $WANT_CIN_3RDPARTY"
1045 echo "  using: single-user  = $WANT_CINBIN_BUILD"
1046 echo "  using: static-build = $WANT_STATIC_BUILD"
1047 echo "  using: ladspa-build = $WANT_LADSPA_BUILD"
1048 echo ""
1049
1050 AC_SUBST(WANT_CIN_3RDPARTY)
1051 AC_SUBST(EXTRA_LIBS)
1052 AC_SUBST(FFMPEG_EXTRA_CFG)
1053 AC_SUBST(WANT_X264_HIDEPTH)
1054 AC_SUBST(WANT_X265_HIDEPTH)
1055
1056 AC_SUBST(CFG_CFLAGS)
1057 AC_SUBST(CFG_CXXFLAGS)
1058
1059 AC_CONFIG_FILES([Makefile])
1060 AC_OUTPUT
1061
1062 exec > global_config
1063
1064 echo "SHELL := /bin/bash"
1065 echo "export SHELL"
1066 echo "WANT_JOBS := $WANT_JOBS"
1067 if test "x$WANT_CLANG" = "xyes" ; then
1068   echo "CC = clang"
1069   echo "CXX = clang++"
1070   echo "export CC CXX"
1071 fi
1072 echo ""
1073 echo "OBJDIR := $OBJDIR"
1074 echo "BINDIR := \$(TOPDIR)/bin"
1075 echo "CINELERRA := \$(TOPDIR)/cinelerra"
1076 echo "GUICAST := \$(TOPDIR)/guicast"
1077 echo "LIBZMPEG3 := \$(TOPDIR)/libzmpeg3"
1078 echo "MPEG2ENC := \$(TOPDIR)/mpeg2enc"
1079 echo "MPLEXLO := \$(TOPDIR)/mplexlo"
1080 echo "PLUGINS := \$(TOPDIR)/plugins"
1081 echo "TDB := \$(TOPDIR)/db"
1082 echo "THIRDPARTY := \$(TOPDIR)/thirdparty"
1083 echo "EXTRA_LIBS := $EXTRA_LIBS"
1084 echo "FFMPEG_EXTRA_CFG := $FFMPEG_EXTRA_CFG"
1085 echo "export OBJDIR BINDIR CINELERRA GUICAST LIBZMPEG3"
1086 echo "export MPEG2ENC MPLEXLO PLUGINS TDB"
1087 echo "export THIRDPARTY EXTRA_LIBS FFMPEG_EXTRA_CFG"
1088 echo ""
1089
1090 echo "WANT_CIN := $WANT_CIN"
1091 CFG_WANTS+=" CIN_3RDPARTY LIBZMPEG COMMERCIAL STATIC_BUILD"
1092 for w in $CFG_WANTS; do ww=WANT_$w; echo "WANT_$w := ${!ww}"; done
1093 echo ""
1094
1095 echo "ifndef CFLAGS_"
1096 echo "ifdef CFLAGS"
1097 echo "CFLAGS_ := \$(CFLAGS)"
1098 echo "else"
1099 echo "CFLAGS_ := ${CFLAGS:--g -O2}"
1100 echo "endif"
1101 echo "endif"
1102 echo "ifndef CXXFLAGS_"
1103 echo "ifdef CXXFLAGS"
1104 echo "CXXFLAGS_ := \$(CXXFLAGS)"
1105 echo "endif"
1106 echo "endif"
1107 echo "ifndef LDFLAGS_"
1108 echo "ifdef LDFLAGS"
1109 echo "LDFLAGS_ := \$(LDFLAGS)"
1110 echo "endif"
1111 echo "endif"
1112
1113 echo "CFLAGS := \$(CFLAGS_)"
1114 echo "CFLAGS += '-DCIN=\"\$(WANT_CIN)\"'"
1115 echo "CFLAGS += '-DCINLIB_DIR=\"$WANT_CINLIB_DIR\"'"
1116 echo "CFLAGS += '-DCINDAT_DIR=\"$WANT_CINDAT_DIR\"'"
1117 echo "CFLAGS += '-DCONFIG_DIR=\"$WANT_CONFIG_DIR\"'"
1118 echo "CFLAGS += '-DNESTED_DIR=\"$WANT_NESTED_DIR\"'"
1119 echo "CFLAGS += '-DSNAP_DIR=\"$WANT_SNAP_DIR\"'"
1120 echo "CFLAGS += '-DPLUGIN_DIR=\"$WANT_PLUGIN_DIR\"'"
1121 echo "CFLAGS += '-DLOCALE_DIR=\"$WANT_LOCALE_DIR\"'"
1122 echo "CFLAGS += '-DLADSPA_DIR=\"$WANT_LADSPA_DIR\"'"
1123 echo "CFLAGS += '-DCIN_BROWSER=\"$WANT_CIN_BROWSER\"'"
1124 for flg in $CFG_CFLAGS; do echo "CFLAGS += $flg"; done
1125 echo ""
1126 if test "x$CFG_CXXFLAGS" != "x"; then
1127   for flg in $CFG_CXXFLAGS; do echo "CXXFLAGS += $flg"; done
1128   echo ""
1129 fi
1130 if test "x$CFG_LDFLAGS" != "x" ; then
1131   echo "LDFLAGS +=$CFG_LDFLAGS"
1132   echo ""
1133 fi
1134
1135 if test "x$CYGWIN" != "x" ; then
1136   echo 'FF_PATH ?= /usr/local'
1137   echo 'LDFLAGS += -L$(FF_PATH)/lib'
1138   echo 'CFLAGS += -I$(FF_PATH)/include'
1139   echo ""
1140   echo "CFLAGS += -DNO_BTRACE"
1141   echo "CFLAGS += -DNO_GDB"
1142   echo "CFLAGS += -DNO_CTX"
1143   echo "CFLAGS += -DNO_PRCTL"
1144   echo "CFLAGS += -DNO_TID"
1145   echo "CFLAGS += -DNO_XSELECT"
1146   echo ""
1147 else
1148   LDFLAGS+=" -z noexecstack"
1149 fi
1150 if test "x$BSD" != "x" ; then
1151   echo "CFLAGS += -DNO_PRCTL"
1152   echo "CFLAGS += -DNO_TID"
1153   echo "CFLAGS += -DNO_GDB"
1154 fi
1155
1156 if test "x$WANT_X264_HIDEPTH" = "xyes" ; then
1157   X264_CFG_PARAMS="$X264_CFG_PARAMS --bit-depth=10"
1158 fi
1159 if test "x$WANT_X265_HIDEPTH" = "xyes" ; then
1160   X265_CFG_PARAMS="$X265_CFG_PARAMS -DHIGH_BIT_DEPTH:BOOL=ON" # -DMAIN12:BOOL=ON"
1161 fi
1162
1163 for pkg in $STATIC_PKGS; do
1164   eval pkg_lib="\$PKG_$pkg"
1165   if test "x$pkg_lib" = "xyes"; then
1166     echo "static_pkgs += $pkg"
1167   elif test "x$pkg_lib" = "xshared"; then
1168     echo "shared_pkgs += $pkg"
1169   fi
1170 done
1171 echo ""
1172
1173 for pkg in $STATIC_BLDS; do
1174   echo "static_blds += $pkg"
1175   ver_pkg=ver_$pkg
1176   echo "$ver_pkg := \$(THIRDPARTY)/${!ver_pkg}"
1177   inc_pkg=inc_$pkg
1178   echo "$inc_pkg := \\"
1179   for inc in ${!inc_pkg}; do
1180     echo "  -I\$($ver_pkg)/$inc \\"
1181   done
1182   echo ""
1183   echo "static_incs += \$(inc_$pkg)"
1184   lib_pkg=lib_$pkg
1185   echo "$lib_pkg := \\"
1186   for lib in ${!lib_pkg}; do
1187     echo "  \$($ver_pkg)/$lib \\"
1188   done
1189   echo ""
1190   echo "static_libs += \$($lib_pkg)"
1191   echo ""
1192 done
1193 echo ""
1194
1195 for lib in $SHARED_LIBS; do echo "shared_libs += $lib"; done
1196 echo ""
1197 for lib in $SYSTEM_LIBS; do echo "system_libs += $lib"; done
1198 echo "export static_pkgs shared_pkgs static_blds shared_libs system_libs"
1199 echo ""
1200
1201 echo "thirdparty_libraries := \$(static_libs) \$(shared_libs)"
1202
1203 if test "x$CFG_RPATH" != "x"; then
1204   echo "libraries+= -Wl,-rpath=$CFG_RPATH"
1205 fi
1206
1207 echo "libraries += -Wl,--start-group"
1208 echo "libraries += \$(thirdparty_libraries)"
1209 echo "libraries += \$(shared_libs)"
1210 echo "libraries += \$(system_libs)"
1211 echo "libraries += \$(EXTRA_LIBS)"
1212 echo "libraries += -Wl,--end-group"
1213 # -Wl,--start-group ... -Wl,--end-group does not work on ubuntu
1214 echo "libraries += \$(thirdparty_libraries)"
1215 echo "libraries += \$(shared_libs)"
1216 echo "libraries += \$(system_libs)"
1217 echo "libraries += \$(EXTRA_LIBS)"
1218 echo ""
1219 echo "export thirdparty_libraries libraries"
1220 echo "export CFLAGS_ CXXFLAGS_ LDFLAGS_"
1221 echo "unexport CFLAGS CXXFLAGS LDFLAGS"
1222
1223 if test "x$HAVE_tiff" = "xyes"; then
1224   if test "x$HAVE_jbig" != "xyes"; then
1225     echo "tiff.cfg_params+= --disable-jbig"
1226   fi
1227 fi
1228
1229 if test "x$WANT_GIT_FFMPEG" != "xno"; then
1230   echo "ffmpeg.git := $WANT_GIT_FFMPEG"
1231 fi
1232 if test "x$X264_CFG_PARAMS" != "x" ; then
1233   echo "x264.cfg_params :=$X264_CFG_PARAMS --enable-static --enable-pic"
1234 fi
1235 if test "x$X265_CFG_PARAMS" != "x" ; then
1236   echo "x265.cfg_params :=$X265_CFG_PARAMS -DENABLE_SHARED=no"
1237 fi
1238