f10af67ef952e0a04e9841421957b4262e125f43
[goodguy/cinelerra.git] / 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],[yes])
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_3RD([ilmbase],[auto],
243   [ilmbase-2.2.1],
244   [ Iex/.libs/libIex.a \
245     IexMath/.libs/libIexMath.a \
246     Half/.libs/libHalf.a \
247     Imath/.libs/libImath.a \
248     IlmThread/.libs/libIlmThread.a ],
249   [ Iex Half Imath config IlmThread ])
250
251 PKG_DEF([ladspa], [ladspa-0.4.17], [], [])
252
253 PKG_3RD([lame],[auto],
254   [lame-3.100],
255   [ libmp3lame/.libs/libmp3lame.a \
256     mpglib/.libs/libmpgdecoder.a ],
257   [ include ])
258
259 PKG_3RD([libavc1394],[auto],
260   [libavc1394-0.5.4],
261   [ libavc1394/.libs/libavc1394.a \
262     librom1394/.libs/librom1394.a \
263     common/.libs/libraw1394util.a ],
264   [ . ])
265
266 PKG_3RD([libraw1394],[auto],
267   [libraw1394-2.1.2],
268   [ src/.libs/libraw1394.a ],
269   [ . ])
270
271 PKG_3RD([libiec61883],[auto],
272   [libiec61883-1.2.0],
273   [ src/.libs/libiec61883.a ],
274   [ src ])
275
276 PKG_3RD([libdv],[auto],
277   [libdv-1.0.0],
278   [ libdv/.libs/libdv.a ],
279   [ . ])
280
281 PKG_3RD([libjpeg],[auto],
282   [libjpeg-turbo-2.0.4],
283   [ build/libjpeg.a \
284     build/libturbojpeg.a ],
285   [ opt/libjpeg-turbo/include ])
286
287 PKG_3RD([opus],[auto],
288   [opus-1.3.1],
289   [ .libs/libopus.a ],
290   [ include ])
291
292 PKG_3RD([openjpeg],[auto],
293   [openjpeg-2.3.1],
294   [ bin/libopenjp2.a ],
295   [ src/lib/openjp2 ])
296
297 PKG_3RD([libogg],[auto],
298   [libogg-1.3.4],
299   [ src/.libs/libogg.a ],
300   [ include ])
301
302 PKG_3RD([libsndfile],[auto],
303   [libsndfile-1.0.28],
304   [ src/.libs/libsndfile.a \
305     src/.libs/libcommon.a \
306     src/G72x/.libs/libg72x.a \
307     src/GSM610/.libs/libgsm.a ],
308   [ . ])
309
310 PKG_3RD([libtheora],[auto],
311   [libtheora-1.1.1],
312   [ lib/.libs/libtheora.a \
313     lib/.libs/libtheoradec.a \
314     lib/.libs/libtheoraenc.a ],
315   [ . ])
316
317 PKG_3RD([libuuid],[yes],
318   [libuuid-1.0.3],
319   [ .libs/libuuid.a ],
320   [ . ])
321
322 PKG_3RD([libvorbis],[auto],
323   [libvorbis-1.3.6],
324   [ lib/.libs/libvorbis.a \
325     lib/.libs/libvorbisenc.a \
326     lib/.libs/libvorbisfile.a ],
327   [ include . ])
328
329 PKG_3RD([mjpegtools],[yes],
330   [mjpegtools-2.1.0],
331   [ utils/mmxsse/.libs/libmmxsse.a \
332     utils/.libs/libmjpegutils.a \
333     lavtools/.libs/liblavfile.a \
334     lavtools/.libs/liblavjpeg.a \
335     mplex/.libs/libmplex2.a \
336     yuvfilters/.libs/libyuvfilters.a \
337     mpeg2enc/.libs/libmpeg2encpp.a ],
338   [ .  lavtools utils ])
339
340 PKG_3RD([openexr],[auto],
341   [openexr-2.2.1],
342   [ IlmImf/.libs/libIlmImf.a \
343     IlmImfUtil/.libs/libIlmImfUtil.a ],
344   [ IlmImf config ])
345
346 #PKG_3RD([festival],[no],
347 #  [festival],
348 #  [],
349 #  [])
350 #PKG_3RD(speech_tools,[no],
351 #  [speech_tools],
352 #  [],
353 #  [])
354 #
355 PKG_3RD([tiff],[auto],
356   [tiff-4.1.0],
357   [ libtiff/.libs/libtiff.a \
358     libtiff/.libs/libtiffxx.a \
359     port/.libs/libport.a ],[
360    . ])
361
362 PKG_3RD([twolame],[auto],
363   [twolame-0.4.0],
364   [ libtwolame/.libs/libtwolame.a ],
365   [  libtwolame ])
366
367 PKG_3RD([x264],[auto],
368   [x264-snapshot-20191217-2245-stable],
369   [ libx264.a ],
370   [ . ])
371
372 PKG_3RD([x265],[auto],
373   [x265_3.2.1],
374   [ libx265.a ],
375   [ . source ])
376
377 PKG_3RD([libvpx],[auto],
378   [libvpx-1.8.1],
379   [ libvpx.a ],
380   [ . ])
381
382 PKG_3RD([lv2],[auto],
383   [lv2-1.16.0],
384   [ ],
385   [ usr/local/include usr/local/lib64/lv2 usr/local/lib/lv2 ])
386
387 PKG_3RD([sratom],[auto],
388   [sratom-0.6.4],
389   [ usr/local/lib/libsratom-0.a ],
390   [ usr/local/include ])
391
392 PKG_3RD([serd],[auto],
393   [serd-0.30.2],
394   [ usr/local/lib/libserd-0.a ],
395   [ usr/local/include ])
396
397 PKG_3RD([sord],[auto],
398   [sord-0.16.4],
399   [ usr/local/lib/libsord-0.a ],
400   [ usr/local/include ])
401
402 PKG_3RD([lilv],[auto],
403   [lilv-0.24.6],
404   [ usr/local/lib/liblilv-0.a ],
405   [ usr/local/include ])
406
407 PKG_3RD([suil],[auto],
408   [suil-0.10.6],
409   [ usr/local/lib/libsuil-0.a ],
410   [ usr/local/include ])
411
412 PKG_3RD([libaom],[auto],
413   [libaom-v1.0.0],
414   [ usr/local/lib*/libaom*.a ],
415   [ usr/local/include ])
416
417 PKG_3RD([dav1d],[auto],
418   [dav1d-0.6.0],
419   [ usr/local/lib*/libdav1d*.a ],
420   [ usr/local/include ])
421
422 PKG_3RD([libwebp],[auto],
423   [libwebp-1.1.0],
424   [ usr/local/lib*/libwebp*.a ],
425   [ usr/local/include ])
426
427 PKG_3RD([ffnvcodec],[auto],
428   [ffnvcodec],
429   [ ],
430   [ . ])
431
432 AC_SUBST(STATIC_PKGS)
433
434 AC_DEFUN([CHECK_ENABLE], [
435 AC_ARG_ENABLE([$1],
436   AC_HELP_STRING([--enable-[$1]], [$3 ([$4])]),
437   [WANT_$2=$enableval], [WANT_$2=[$4]])
438 ])
439
440 CHECK_ENABLE([static-build], [STATIC_BUILD], [build static], [auto])
441 CHECK_ENABLE([x264_hidepth], [X264_HIDEPTH], [build x264 10bit], [no])
442 CHECK_ENABLE([x265_hidepth], [X265_HIDEPTH], [build x265 10bit], [no])
443
444 test "x$WANT_STATIC_BUILD" = "xauto" && WANT_STATIC_BUILD=$WANT_CINBIN_BUILD
445
446 AC_DEFUN([CHECK_PROG], [
447  AC_CHECK_PROG([PROG_$1], [$2], [yes],[no])
448 ])
449 AC_DEFUN([REQUIRE_PROG], [
450  CHECK_PROG([$1],[$2])
451  if test "x$PROG_$1" = "xno"; then
452    AC_MSG_WARN([$2 is missing and required.])
453    FATAL_ERROR=1
454  fi
455 ])
456
457 ## arch dep tests
458 ARCH=[`uname -m`]
459 I86=[`expr "x$ARCH" : 'xi[346]86.*'`]
460 X86=[`expr "x$ARCH" : 'x..._64*'`]
461
462 if test "x$I86$X86" != "x00" ; then
463   # Checks for ix86 programs.
464   REQUIRE_PROG(NASM, [nasm])
465   # libx264 nasm fix
466   AC_MSG_CHECKING([nasm x264 compatible])
467   echo "vmovdqa32 [[eax]]{k1}{z}, zmm0" > conftest.asm
468   nasm conftest.asm -o conftest.o > /dev/null 2>&1
469   if test $? != 0 ; then
470    AC_MSG_RESULT([no])
471    AC_MSG_WARN([libx264 built without assembly code])
472    X264_CFG_PARAMS="$X264_CFG_PARAMS --disable-asm"
473   else
474    AC_MSG_RESULT([yes])
475   fi
476   rm -f conftest.asm conftest.o
477   REQUIRE_PROG(YASM, [yasm])
478 fi
479
480 ## end arch dep tests
481
482 REQUIRE_PROG(OBJCOPY, [objcopy])
483 if test "x$FATAL_ERROR" != "x"; then
484  AC_MSG_ERROR("fatal eror.")
485 fi
486 CHECK_PROG(PACTL, [pactl])
487 WANT_PACTL=$PROG_PACTL
488
489 AC_CHECK_DECL([X_HAVE_UTF8_STRING],,[no_utf=yes],[#include <X11/Xlib.h>])
490 if test "$no_utf" = "yes"; then
491   AC_MSG_ERROR([Cinelerra requires utf8 support in X Windows.])
492 fi
493
494 # Checks for headers/libraries.
495
496 AC_DEFUN([CHECK_HEADERS], [
497 if test "x$HAVE_$1" != "xno"; then
498  AC_CHECK_HEADER(m4_apply([m4_car],m4_split([$3])), [HAVE_$1=yes], [HAVE_$1=no],
499   [m4_foreach([i], m4_split([$3]), [[#include "]i["
500 ]])])
501  AC_SUBST([HAVE_$1])
502  AC_MSG_CHECKING([$2])
503  AC_MSG_RESULT([$HAVE_$1])
504  if test "x$HAVE_$1" = "xno"; then
505   if test "x$PKG_$1" = "x"; then RESULT=no; fi
506  fi
507 fi
508 ])
509
510 AC_DEFUN([CHECK_LIB], [
511 if test "x$HAVE_$1" != "xno"; then
512  if test "x$PKG_$1" = "x" -o "x$WANT_STATIC_BUILD" = "xno" -a "x$PKG_$1" != "xno"; then
513   AC_CHECK_LIB([$2], [$3], [HAVE_$1=yes], [HAVE_$1=no], [$4])
514   AC_SUBST([HAVE_$1])
515   if test "x$WANT_$1" != "xno"; then
516    if test "x$HAVE_$1" = "xyes"; then
517     if test "x$PKG_$1" = "x"; then
518      SYSTEM_LIBS+=" -l[$2]"
519      for lib in [$4]; do SYSTEM_LIBS+=" $lib"; done
520     else
521      SHARED_$1+=" -l[$2]"
522      for lib in [$4]; do SHARED_LIBS+=" $lib"; done
523     fi
524    elif test "x$PKG_$1" = "x"; then
525     RESULT=no
526    fi
527   fi
528  fi
529 fi
530 ])
531
532 CHECK_LIB([X11], [X11], [XOpenDisplay])
533 CHECK_HEADERS([X11], [X11 headers], [X11/X.h X11/Xlib.h X11/Xutil.h X11/cursorfont.h])
534 CHECK_HEADERS([X11], [X11 headers], [X11/keysym.h X11/Sunkeysym.h X11/Xatom.h X11/XF86keysym.h])
535 CHECK_LIB([XEXT], [Xext], [XShmQueryExtension])
536 CHECK_HEADERS([XEXT], [Xlib XShm extention], [X11/Xlib.h X11/extensions/XShm.h X11/extensions/shape.h])
537 CHECK_LIB([XINERAMA], [Xinerama], [XineramaQueryExtension])
538 CHECK_HEADERS([XINERAMA], [Xinerama headers], [X11/extensions/Xinerama.h])
539 CHECK_LIB([XFIXES], [Xfixes], [XFixesQueryVersion])
540 CHECK_LIB([BZ2], [bz2], [BZ2_bzDecompress])
541 CHECK_LIB([FONTCONFIG], [fontconfig], [FcInit])
542 CHECK_LIB([FREETYPE], [freetype], [FT_Init_FreeType])
543 CHECK_LIB([LZMA], [lzma], [lzma_version_number])
544 CHECK_LIB([PNG], [png], [png_read_png])
545 CHECK_LIB([PTHREAD], [pthread], [pthread_create])
546 CHECK_LIB([Z], [z], [gzopen])
547 CHECK_LIB([fftw], [fftw3], [fftw_execute])
548 CHECK_HEADERS([fftw], [fftw headers], [fftw3.h])
549 CHECK_LIB([libuuid], [uuid], [uuid_clear])
550 CHECK_HEADERS([libuuid], [uuid headers], [uuid/uuid.h])
551 CHECK_HEADERS([LINUX_CDROM], [linux cdrom headers], [linux/cdrom.h linux/futex.h])
552 CHECK_HEADERS([LINUX_SYS], [linux sys], [sys/ioctl.h sys/stat.h sys/types.h sys/time.h sys/syscall.h])
553 CHECK_LIB([flac], [FLAC], [FLAC__stream_decoder_new])
554 CHECK_HEADERS([flac], [FLAC headers], [FLAC/stream_decoder.h])
555 CHECK_LIB([lame], [mp3lame], [lame_init])
556 CHECK_HEADERS([lame], [lame headers], [lame/lame.h])
557 CHECK_LIB([libjpeg], [jpeg], [jpeg_start_decompress])
558 CHECK_HEADERS([libjpeg], [jpeg headers], [stdio.h jpeglib.h])
559 CHECK_LIB([openjpeg], [openjp2], [opj_version])
560 CHECK_HEADERS([openjpeg], [openjpeg headers], [openjpeg.h])
561 CHECK_LIB([libsndfile], [sndfile], [sf_open])
562 CHECK_HEADERS([libsndfile], [sndfile headers], [sndfile.h])
563 CHECK_LIB([ilmbase], [IlmImf], [ImfOpenInputFile])
564 CHECK_HEADERS([ilmbase], [IlmImf headers], [OpenEXR/ImfCRgbaFile.h])
565 CHECK_LIB([libvpx], [vpx], [vpx_codec_decode])
566 CHECK_HEADERS([libvpx], [vpx headers], [vpx/vpx_decoder.h])
567 CHECK_LIB([mjpegtools], [mjpegutils], [mjpeg_info])
568 CHECK_HEADERS([mjpegtools], [mjpegtools headers], [mjpegtools/mjpeg_types.h])
569 CHECK_LIB([tiff], [tiff], [TIFFOpen])
570 CHECK_HEADERS([tiff], [tiff headers], [tiff.h tiffio.h])
571 CHECK_LIB([twolame], [twolame], [twolame_encode_buffer_float32_interleaved])
572 CHECK_HEADERS([twolame], [twolame headers], [twolame.h])
573 CHECK_LIB([x264], [x264], [x264_encoder_encode])
574 CHECK_HEADERS([x264], [x264 headers], [stdint.h x264.h])
575 CHECK_LIB([x265], [x265], [x265_encoder_encode])
576 CHECK_HEADERS([x265], [x265 headers], [x265.h])
577 CHECK_LIB([opus], [opus], [opus_multistream_decoder_create])
578 CHECK_HEADERS([opus], [libopus headers], [opus/opus_multistream.h])
579 CHECK_LIB([libaom], [aom], [aom_codec_version])
580 CHECK_HEADERS([libaom], [libaom headers], [aom/aom.h])
581 CHECK_LIB([dav1d], [dav1d], [dav1d_version])
582 CHECK_HEADERS([dav1d], [libdav1d headers], [dav1d/dav1d.h])
583 CHECK_LIB([libwebp], [webp], [WebPGetEncoderVersion])
584 CHECK_HEADERS([libwebp], [libwebp headers], [webp/encode.h])
585 CHECK_LIB([a52dec], [a52], [a52_init])
586 CHECK_HEADERS([a52dec], [a52 headers], [stdint.h a52.h])
587 CHECK_LIB([encore], [encore], [encore])
588 CHECK_HEADERS([encore], [encore headers], [encore.h])
589 CHECK_LIB([giflib], [gif], [DGifOpen])
590 CHECK_HEADERS([giflib], [gif lib headers], [gif_lib.h])
591 CHECK_LIB([jbig], [jbig], [jbg_dec_init])
592
593 CHECK_LIB([VDPAU], [vdpau], [vdp_device_create_x11])
594 if test "x$HAVE_VDPAU" != "xyes" -a "x$WANT_VDPAU" = "xyes"; then
595   AC_MSG_ERROR([requires vdpau support.])
596 fi
597
598 CHECK_LIB([VAAPI], [va], [vaInitialize])
599 if test "x$HAVE_VAAPI" = "xyes" -a "x$WANT_VAAPI" != "xno"; then
600   CHECK_HEADERS([vaapi_x11], [va x11 headers], [va/va_x11.h])
601   CHECK_LIB([vaapi_x11], [va-x11], [vaGetDisplay])
602   CHECK_HEADERS([vaapi_drm], [va drm headers], [va/va_drm.h])
603   CHECK_LIB([vaapi_drm], [va-drm], [vaGetDisplayDRM])
604 fi
605 if test "x$HAVE_VAAPI" != "xyes" -a "x$WANT_VAAPI" = "xyes"; then
606   AC_MSG_ERROR([requires vaapi support.])
607 fi
608
609 #CHECK_LIB([NVENC], [nvidia-encode], [NvEncodeAPICreateInstance])
610
611 #if test "x$HAVE_mjpegtools" = "xyes"; then
612 #CFG_CFLAGS+=" -I/usr/include/mjpegtools -I/usr/local/include/mjpegtools"
613 #fi
614
615 AC_DEFUN([CHECK_WANT], [
616 RESULT=yes
617 # WANT_$1
618 AC_ARG_WITH(m4_tolower([$1]),
619  AC_HELP_STRING([m4_join([-],[--with],m4_tolower([$1]))], [$3] (auto)),
620   [WANT_$1=$withval],[WANT_$1=$2])
621  m4_quote($4)
622  if test "x$WANT_$1" = "xauto" ; then
623   WANT_$1="$RESULT"
624  elif test "x$WANT_$1" = "xyes" ; then
625   if test "x$RESULT" = "xno" -a "x$PKG_$1" = "x"; then
626     AC_MSG_ERROR([required for $1 support.])
627   fi
628  fi
629 CFG_WANTS+=" $1"
630 AC_SUBST([WANT_$1])
631 ])
632
633 CHECK_WANT([GL], [auto], [use opengl], [
634  CHECK_LIB([GL], [GL], [glUseProgram])
635  CHECK_LIB([GL], [GLU], [gluOrtho2D])
636  CHECK_HEADERS([GL], [opengl headers], [GL/gl.h GL/glext.h GL/glu.h GL/glx.h])])
637
638 CHECK_WANT([XV], [auto], [use xv], [
639  CHECK_LIB([xv], [Xv], [XvQueryExtension])
640  CHECK_HEADERS([xv], [Xlib Xv extention], [X11/Xlib.h X11/extensions/Xvlib.h])])
641
642 CHECK_WANT([OSS], [auto], [use OSS audio], [
643  CHECK_HEADERS([OSS], [oss headers], [sys/soundcard.h])])
644
645 CHECK_WANT([XFT], [auto], [use libXft], [
646  CHECK_LIB([XFT], [Xft], [XftInit])
647  CHECK_HEADERS([XFT], [Xft/freetype headers], [X11/Xlib.h X11/Xft/Xft.h])])
648
649 CHECK_WANT([ALSA], [auto], [use libasound/alsa], [
650  CHECK_LIB([ALSA], [asound], [snd_pcm_open])
651  CHECK_HEADERS([ALSA], [asound headers], [alsa/asoundlib.h])])
652
653 CHECK_WANT([OGG], [auto], [use ogg/theora/vorbis], [
654  CHECK_LIB([libogg], [ogg], [ogg_stream_init])
655  CHECK_HEADERS([libogg], [ogg headers], [ogg/ogg.h])
656  CHECK_LIB([libtheora], [theora], [theora_info_init], [-ltheoraenc -ltheoradec -logg])
657  CHECK_HEADERS([libtheora], [threora headers], [theora/theoraenc.h])
658  CHECK_LIB([libvorbis], [vorbisenc], [vorbis_encode_init], [-lvorbis -lvorbisfile -logg])
659  CHECK_HEADERS([libvorbis], [vorbis encoders headers], [vorbis/vorbisenc.h])
660  CHECK_LIB([libvorbis], [vorbisfile], [ov_open])
661  CHECK_HEADERS([libvorbis], [vorbis file headers], [vorbis/vorbisfile.h])])
662
663 CHECK_WANT([FIREWIRE], [auto], [use firewire], [
664  CHECK_LIB([libavc1394], [avc1394], [avc1394_init_target])
665  CHECK_HEADERS([libavc1394], [libavc1394 headers], [libavc1394/avc1394.h])
666  CHECK_LIB([libavc1394], [rom1394], [rom1394_get_bus_id])
667  CHECK_HEADERS([libavc1394], [librom1394 headers], [libavc1394/rom1394.h])
668  CHECK_LIB([libiec61883], [iec61883], [iec61883_mpeg2_recv_init])
669  CHECK_HEADERS([libiec61883], [libiec61883 headers], [libiec61883/iec61883.h])
670  CHECK_LIB([libraw1394], [raw1394], [raw1394_iso_recv_init])
671  CHECK_HEADERS([libraw1394], [libraw1394 headers], [libraw1394/raw1394.h])])
672 # have all or none
673 test "x$HAVE_libavc1394" = "xyes" && \
674 test "x$HAVE_libiec61883" = "xyes" && \
675 test "x$HAVE_libraw1394" = "xyes" && \
676   HAVE_FIREWIRE=yes || \
677 HAVE_libavc1394=no && \
678 HAVE_libiec61883=no && \
679 HAVE_libraw1394=no && \
680  HAVE_FIREWIRE=no
681
682 CHECK_WANT([DV], [auto], [use dv], [
683  CHECK_LIB([libdv], [dv], [dv_init])
684  CHECK_HEADERS([libdv], [libdv headers], [libdv/dv.h])])
685
686 CHECK_WANT([DVB], [auto], [use dvb], [
687  CHECK_HEADERS([DVB], [dvb device headers], [linux/dvb/dmx.h linux/dvb/frontend.h])])
688
689 CHECK_WANT([VIDEO4LINUX2], [auto], [use v4l2], [
690  CHECK_HEADERS([VIDEO4LINUX2], [v4l2 system headers], [linux/kernel.h linux/types.h linux/videodev2.h])])
691
692 CHECK_WANT([XXF86VM], [auto], [use xf86vmode], [
693  CHECK_HEADERS([XXF86VM], [XF86VM headers], [X11/Xlib.h X11/extensions/xf86vmode.h])])
694
695 CHECK_WANT([ESOUND], [no], [use esd], [
696  CHECK_LIB([esound], [esd], [esd_open_sound])
697  CHECK_HEADERS([esound], [esound headers], [esd.h])
698  CHECK_LIB([audiofile], [audiofile], [afOpenFile])
699  CHECK_HEADERS([audiofile], [audiofile headers], [audiofile.h])])
700 # have all or none
701 test "x$HAVE_esound" = "xyes" && \
702 test "x$HAVE_audiofile" = "xyes" && \
703   HAVE_ESOUND=yes || \
704 HAVE_esound=no && \
705 HAVE_audiofile=no && \
706   HAVE_ESOUND=no
707
708 CHECK_WANT([PULSE], [auto], [use pulseaudio], [
709  CHECK_LIB([pulse_simple], [pulse-simple], [pa_simple_new])
710  CHECK_HEADERS([pulse_simple], [pulse-simple headers], [pulse/simple.h])
711  CHECK_LIB([pulse], [pulse], [pa_context_new])
712  CHECK_HEADERS([pulse], [pulse headers], [pulse/error.h])])
713
714 CHECK_WANT([ISOFS], [auto], [use isofs], [
715  CHECK_HEADERS([isofs], [isofs headers], [linux/isofs.h])])
716
717 if test "x$WANT_LADSPA_BUILD" != "xyes" ; then
718  CHECK_WANT([LADSPA], [auto], [ladspa plugin clients], [
719   CHECK_HEADERS([ladspa], [ladspa headers], [ladspa.h])])
720 else
721  WANT_LADSPA=yes
722 fi
723
724 CHECK_WANT([SHUTTLE], [yes], [shuttle dev support], [
725  CHECK_HEADERS([keysyms], [x11 keysym defs], [X11/keysymdef.h])])
726 if test "x$WANT_SHUTTLE" = "xno"; then
727  WANT_SHUTTLE_USB="no"
728 fi
729 CHECK_WANT([SHUTTLE_USB], [yes], [use libusb-1.0], [
730  CHECK_LIB([libusbx], [usb-1.0], [libusb_init])
731  CHECK_HEADERS([libusbx], [libusb headers], [libusb-1.0/libusb.h])])
732
733 CHECK_WANT([LV2], [auto], [use lv2], [
734  saved_CFLAGS="$CFLAGS"
735  CHECK_LIB([lilv], [lilv-0], [lilv_world_new])
736  CHECK_LIB([sord], [sord-0], [sord_world_new])
737  CHECK_LIB([serd], [serd-0], [serd_reader_new])
738  CHECK_LIB([sratom], [sratom-0], [sratom_new])
739  CFLAGS="-I/usr/include/lilv-0 -I/usr/local/include/lilv-0"
740  CHECK_HEADERS([lv2], [lilv headers], [lilv/lilv.h])
741  CHECK_LIB([suil], [suil-0], [suil_instance_new])
742  CFLAGS="-I/usr/include/suil-0 -I/usr/local/include/suil-0"
743  CHECK_HEADERS([lv2], [suil headers], [suil/suil.h])
744  CFLAGS="$saved_CFLAGS"])
745 # have all or none
746 test "x$HAVE_lv2" = "xyes" && \
747 test "x$HAVE_lilv" = "xyes" && \
748 test "x$HAVE_sord" = "xyes" && \
749 test "x$HAVE_serd" = "xyes" && \
750 test "x$HAVE_sratom" = "xyes" && \
751 test "x$HAVE_suil" = "xyes" && \
752   HAVE_LV2=yes || \
753 HAVE_lv2=no && \
754 HAVE_lilv=no && \
755 HAVE_sord=no && \
756 HAVE_serd=no && \
757 HAVE_sratom=no && \
758 HAVE_suil=no && \
759   HAVE_LV2=no
760
761 CHECK_WANT([CUDA], [auto], [build cuda plugins], [
762   CHECK_HEADERS([CUDA], [cuda sdk], [${CUDA_PATH:-/usr/local/cuda}/include/cuda.h])])
763
764 CHECK_WANT([DL], [auto], [system has libdl], [
765  CHECK_LIB([DL], [dl], [dlopen])])
766
767 CHECK_WANT([OPENCV], [no], [opencv=sys/sta/dyn,git/tar=url], [
768 ])
769
770 CHECK_WANT([NUMA], [auto], [system has libnuma], [
771  CHECK_LIB([NUMA], [numa], [numa_alloc])])
772
773 CHECK_WANT([OPENEXR], [auto], [use openexr], [
774  AC_MSG_CHECKING([for openexr available])
775  saved_LIBS="$LIBS"
776  saved_CXXFLAGS="$CXXFLAGS"
777  # ilmbase libs
778  LIBS=" -lIlmImf -lIlmThread -lIex -lpthread"
779  CXXFLAGS="-I/usr/include/OpenEXR -I/usr/local/include/OpenEXR"
780  AC_LANG_PUSH(C++)
781  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
782 #include "ImfChannelList.h"
783 #include "ImfChromaticities.h"
784 #include "ImfCompression.h"
785 #include "ImfIO.h"
786 #include "ImfInputFile.h"
787 #include "ImfOutputFile.h"
788 #include "ImfPixelType.h"
789 #include "ImfRgbaFile.h"
790 #include "ImfRgbaYca.h"
791 #include "ImfVersion.h"
792 class EXRIStream : public Imf::IStream { public:
793 EXRIStream() : Imf::IStream("mypath") {} };
794 class EXROStream : public Imf::OStream { public: 
795 EXROStream() : Imf::OStream("mypath") {} };
796 ]])], [HAVE_OPENEXR=yes], [HAVE_OPENEXR=no])
797  if test "x$WANT_OPENEXR" = "xauto"; then
798    WANT_OPENEXR="yes"
799  fi
800  if test "x$WANT_OPENEXR" = "xyes" -a "x$HAVE_OPENEXR" = "xyes"; then
801   if test "x$WANT_STATIC_BUILD" = "xno"; then
802     SHARED_openexr="$LIBS"
803     SHARED_LIBS+=" $LIBS"
804     CFG_CFLAGS+=" -I/usr/include/OpenEXR -I/usr/local/include/OpenEXR"
805   fi
806  fi
807  LIBS="$saved_LIBS"
808  CXXFLAGS="$saved_CXXFLAGS"
809  AC_LANG_POP(C++)
810  AC_MSG_RESULT([$HAVE_OPENEXR])
811 ])
812 AC_SUBST([HAVE_OPENEXR])
813 # have all or none
814 test "x$HAVE_openexr" = "xyes" && \
815 test "x$HAVE_ilmbase" = "xyes" && \
816   HAVE_OPENEXR=yes || \
817 HAVE_openexr=no && \
818 HAVE_ilmbase=no &&
819   HAVE_OPENEXR=no
820
821 # build global_config
822 OBJDIR=`uname -m`
823 AC_SUBST(OBJDIR)
824
825 echo "AC_HELP_STRING([Reason],[Package])"
826 echo "AC_HELP_STRING([------],[-------])"
827
828 AC_DEFUN([PKG_DISABLED],[
829  PKG_$1="no"
830  BUILD_$1=0
831  AC_SUBST(BUILD_$1)
832  echo "AC_HELP_STRING([disabled],[$1])"
833 ])
834 AC_DEFUN([PKG_SHARED],[
835  PKG_$1="shared"
836  BUILD_$1=0
837  AC_SUBST(BUILD_$1)
838  SHARED_LIBS+="$SHARED_$1"
839 ])
840
841 AC_DEFUN([PKG_STATIC],[
842  if test "x$WANT_CIN_3RDPARTY" != "xno"; then
843   PKG_$1="yes"
844   BUILD_$1=1
845   AC_SUBST(BUILD_$1)
846   STATIC_BLDS+=" [$1]"
847   echo "AC_HELP_STRING([$2],[$1])"
848  fi
849 ])
850
851 AC_DEFUN([PKG_FORCED],[PKG_STATIC([$1],[forced])])
852
853 if test "x$WANT_CIN_3RDPARTY" != "xno"; then
854 # order matters
855 for dep in \
856         ffmpeg/twolame ffmpeg/lame ffmpeg/openjpeg \
857         ffmpeg/libvorbis ffmpeg/libtheora ffmpeg/x264 ffmpeg/x265 \
858         libiec61883/libraw1394 libavc1394/librom1394 \
859         openexr/ilmbase ilmbase/libogg \
860         libtheora/libogg libtheora/libvorbis ; do
861   lib=`dirname $dep`;  needs=`basename $dep`
862   eval pkg_lib="\$PKG_$lib"
863   if test "x$pkg_lib" != "xno"; then
864     eval "PKG_$needs=yes"
865   fi
866 done
867 fi
868
869 AC_DEFUN([PKG_PROVIDE],[
870 if test "x$BUILD_$1" = "x" ; then
871  if test "x$PKG_$1" = "xyes"; then
872   if test "x$WANT_CIN_3RDPARTY" = "xno"; then
873     PKG_SHARED([$1])
874   else
875     PKG_FORCED([$1])
876   fi
877  elif test "x$2" = "xno" -o "x$PKG_$1" = "xno"; then
878   PKG_DISABLED([$1])
879  elif test "x$WANT_STATIC_BUILD" = "xyes"; then
880   PKG_STATIC([$1],[static])
881  elif test "x$HAVE_$1" = "xyes"; then
882   PKG_SHARED([$1])
883  else
884   PKG_STATIC([$1],[needed])
885  fi
886 fi
887 ])
888
889 PKG_PROVIDE([a52dec])
890 PKG_PROVIDE([djbfft])
891 PKG_PROVIDE([encore])
892 PKG_PROVIDE([audiofile],[$WANT_ESOUND])
893 PKG_PROVIDE([esound],[$WANT_ESOUND])
894 PKG_PROVIDE([ffmpeg])
895 PKG_PROVIDE([fftw])
896 PKG_PROVIDE([flac])
897 PKG_PROVIDE([giflib])
898 PKG_PROVIDE([ilmbase], [$WANT_OPENEXR])
899 PKG_PROVIDE([ladspa],[$WANT_LADSPA_BUILD])
900 PKG_PROVIDE([lame])
901 PKG_PROVIDE([libavc1394],[$WANT_FIREWIRE])
902 PKG_PROVIDE([libraw1394],[$WANT_FIREWIRE])
903 PKG_PROVIDE([libiec61883],[$WANT_FIREWIRE])
904 PKG_PROVIDE([libdv],[$WANT_DV])
905 PKG_PROVIDE([libjpeg])
906 PKG_PROVIDE([libogg])
907 PKG_PROVIDE([libsndfile])
908 PKG_PROVIDE([libtheora])
909 PKG_PROVIDE([libuuid])
910 PKG_PROVIDE([libvorbis])
911 PKG_PROVIDE([mjpegtools])
912 PKG_PROVIDE([libaom])
913 PKG_PROVIDE([dav1d])
914 PKG_PROVIDE([libwebp])
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