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