1AC_INIT([vapoursynth], [54], [https://github.com/vapoursynth/vapoursynth/issues], [vapoursynth], [http://www.vapoursynth.com/]) 2 3: ${CFLAGS=""} 4: ${CXXFLAGS=""} 5 6AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects no-define]) 7AM_SILENT_RULES([yes]) 8 9LT_INIT([win32-dll]) 10 11AC_PROG_CC 12AC_PROG_CXX 13 14AC_CONFIG_MACRO_DIRS([m4]) 15 16AC_SYS_LARGEFILE 17AC_FUNC_FSEEKO 18AX_PTHREAD 19 20 21AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable compilation options required for debugging. (default=no)])) 22AS_IF( 23 [test "x$enable_debug" = "xyes"], 24 [ 25 AC_DEFINE([VS_CORE_DEBUG]) 26 AC_SUBST([DEBUGCFLAGS], ["-O0 -g3 -ggdb -ftrapv"]) 27 ], 28 [ 29 AC_DEFINE([NDEBUG]) 30 ] 31) 32 33 34 35AC_ARG_ENABLE([guard-pattern], AS_HELP_STRING([--enable-guard-pattern], [Adds 32 bytes on the left and the right sides of each frame, fills them with a certain value, and checks their integrity after each filter. It can be used to detect buggy filters that write a little outside the frame.])) 36AS_IF( 37 [test "x$enable_guard_pattern" = "xyes"], 38 [ 39 AC_DEFINE([VS_FRAME_GUARD]) 40 ] 41) 42 43 44 45AC_ARG_WITH( 46 [plugindir], 47 AS_HELP_STRING([--with-plugindir], [The default value for the configuration option 'SystemPluginDir' in vapoursynth.conf. (default=LIBDIR/vapoursynth)]), 48 [PLUGINDIR=$with_plugindir], 49 [PLUGINDIR=$libdir/$PACKAGE_NAME] 50) 51dnl Can't do it with AC_DEFINE because $libdir wouldn't be expanded fully. 52AC_SUBST([PLUGINDIR]) 53 54 55 56AC_CANONICAL_HOST 57 58 59X86="false" 60PPC="false" 61ARM="false" 62 63AS_CASE( 64 [$host_cpu], 65 [i?86], [BITS="32" X86="true"], 66 [x86_64|amd64], [BITS="64" X86="true"], 67 [powerpc*], [PPC="true"], 68 [arm*], [ARM="true"], # Maybe doesn't work for all arm systems? 69 [aarch64*], [ARM="true"] 70) 71 72AS_CASE( 73 [$host_os], 74 [darwin*], 75 [ 76 AC_DEFINE([VS_TARGET_OS_DARWIN]) 77 AC_SUBST([UNDEFINEDLDFLAGS], ["-Wl,-undefined,error"]) 78 ], 79 [*linux*|gnu*|dragonfly*|*bsd*], # The BSDs are close enough, right? 80 [ 81 AC_DEFINE([VS_TARGET_OS_LINUX]) 82 AC_SUBST([UNDEFINEDLDFLAGS], ["-Wl,--no-undefined"]) 83 ], 84 [cygwin*|mingw*], 85 [ 86 AS_IF( 87 [test "x$BITS" = "x32"], 88 [ 89 AC_SUBST([PLUGINLDFLAGS], ["-Wl,--kill-at"]) 90 AC_SUBST([STACKREALIGN], ["-mstackrealign"]) 91 ] 92 ) 93 AC_DEFINE([VS_TARGET_OS_WINDOWS]) 94 AC_SUBST([UNICODECFLAGS], ["-DUNICODE -D_UNICODE"]) 95 AC_SUBST([UNICODELDFLAGS], ["-municode"]) 96 ], 97 [AC_MSG_ERROR([Unknown host OS])] 98) 99 100AS_IF( 101 [test "x$X86" = "xtrue"], 102 [ 103 AC_ARG_ENABLE([x86-asm], AS_HELP_STRING([--enable-x86-asm], [Enable assembler code for x86 CPUs. (default=yes)])) 104 105 AS_IF( 106 [test "x$enable_x86_asm" != "xno"], 107 [ 108 AC_DEFINE([VS_TARGET_CPU_X86]) 109 ] 110 ) 111 112 AC_SUBST([MFLAGS], ["-mfpmath=sse -msse2"]) 113 AC_SUBST([AVX2FLAGS], ["-mavx2 -mfma -mtune=haswell"]) 114 ] 115) 116 117AS_IF( 118 [test "x$PPC" = "xtrue"], 119 [AC_DEFINE([VS_TARGET_CPU_POWERPC])] 120) 121 122AS_IF( 123 [test "x$ARM" = "xtrue"], 124 [AC_DEFINE([VS_TARGET_CPU_ARM])] 125) 126 127 128 129AC_ARG_ENABLE([core], AS_HELP_STRING([--enable-core], [Build the VapourSynth core library. (default=yes)])) 130AS_IF( 131 [test "x$enable_core" != "xno"], 132 [ 133 AC_DEFINE([VS_CORE_EXPORTS]) 134 135 PKG_CHECK_MODULES([ZIMG], [zimg]) 136 137 AC_LANG_PUSH([C++]) 138 saved_cppflags="$CPPFLAGS" 139 saved_libs="$LIBS" 140 CPPFLAGS="$ZIMG_CFLAGS" 141 LIBS="$ZIMG_LIBS" 142 AC_LINK_IFELSE( 143 [AC_LANG_PROGRAM( 144 [[ 145#include <zimg.h> 146 147#if ZIMG_API_VERSION < ZIMG_MAKE_API_VERSION(2, 3) 148#error zimg API v2.3 or greater required 149#endif 150 ]], 151 [[ 152unsigned major, minor, micro; 153zimg_get_version_info(&major, &minor, µ); 154 ]] 155 )], 156 [], 157 [AC_MSG_ERROR([failed to link zimg. See config.log for details.])] 158 ) 159 160 161 CPPFLAGS="$saved_cppflags" 162 LIBS="$saved_libs" 163 AC_LANG_POP([C++]) 164 165 166 AC_CONFIG_FILES([pc/vapoursynth.pc]) 167 168 dnl Annoying shit... 169 AS_CASE( 170 [$host_os], 171 [cygwin*|mingw*], 172 [], 173 [ 174 saved_libs="$LIBS" 175 AC_SEARCH_LIBS([dlopen], [dl dld], [], [AC_MSG_ERROR([Unable to find the dlopen() function.])]) 176 AS_IF( 177 [test "x$ac_cv_search_dlopen" != "xnone required"], 178 [AC_SUBST([DLOPENLIB], ["$ac_cv_search_dlopen"])] 179 ) 180 LIBS="$saved_libs" 181 ] 182 ) 183 184 AC_LANG_PUSH([C++]) 185 AC_MSG_CHECKING([for sched_getaffinity]) 186 AC_LINK_IFELSE( 187 [AC_LANG_PROGRAM( 188 [[ 189#define _GNU_SOURCE 190#include <sched.h> 191 ]], 192 [[ 193cpu_set_t affinity; 194sched_getaffinity(0, sizeof(cpu_set_t), &affinity); 195int count = CPU_COUNT(&affinity); 196 ]] 197 )], 198 [ 199 AC_DEFINE([HAVE_SCHED_GETAFFINITY]) 200 AC_MSG_RESULT([yes]) 201 ], 202 [AC_MSG_RESULT([no])] 203 ) 204 AC_LANG_POP([C++]) 205 206 AC_LANG_PUSH([C++]) 207 AC_MSG_CHECKING([for cpuset_getaffinity]) 208 AC_LINK_IFELSE( 209 [AC_LANG_PROGRAM( 210 [[ 211#include <sys/param.h> 212#include <sys/_cpuset.h> 213#include <sys/cpuset.h> 214 ]], 215 [[ 216cpuset_t affinity; 217cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), &affinity); 218int count = CPU_COUNT(&affinity); 219 ]] 220 )], 221 [ 222 AC_DEFINE([HAVE_CPUSET_GETAFFINITY]) 223 AC_MSG_RESULT([yes]) 224 ], 225 [AC_MSG_RESULT([no])] 226 ) 227 AC_LANG_POP([C++]) 228 ] 229) 230AM_CONDITIONAL([VSCORE], [test "x$enable_core" != "xno"]) 231AM_CONDITIONAL([X86ASM], [test "x$X86" = "xtrue" -a "x$enable_x86_asm" != "xno"]) 232 233 234 235AC_ARG_ENABLE([vsscript], AS_HELP_STRING([--enable-vsscript], [Enable VSScript. Requires Python 3. (default=yes)])) 236AS_IF( 237 [test "x$enable_vsscript" != "xno"], 238 [ 239 AM_PATH_PYTHON([3]) 240 241 PKG_CHECK_MODULES([PYTHON3], 242 [python-$PYTHON_VERSION-embed], 243 [], 244 [ 245 PKG_CHECK_MODULES([PYTHON3], 246 [python-$PYTHON_VERSION]) 247 ]) 248 249 AC_CONFIG_FILES([pc/vapoursynth-script.pc]) 250 ] 251) 252AM_CONDITIONAL([VSSCRIPT], [test "x$enable_vsscript" != "xno"]) 253 254 255 256AC_ARG_ENABLE([vspipe], AS_HELP_STRING([--enable-vspipe], [Build vspipe. Requires VSScript. (default=yes)])) 257AS_IF( 258 [test "x$enable_vsscript" = "xno"], 259 [ 260 AS_IF( 261 [test "x$enable_vspipe" = "xyes"], 262 [AC_MSG_ERROR([Cannot build vspipe when VSScript is disabled.])], 263 [enable_vspipe="no"] 264 ) 265 ] 266) 267AM_CONDITIONAL([VSPIPE], [test "x$enable_vspipe" != "xno"]) 268 269 270 271AC_ARG_ENABLE([python-module], AS_HELP_STRING([--enable-python-module], [Build the Python module. Requires Cython, Python, and the core. (default=yes)])) 272AS_IF( 273 [test "x$enable_core" = "xno"], 274 [ 275 AS_IF( 276 [test "x$enable_python_module" = "xyes"], 277 [AC_MSG_ERROR([Cannot build the Python module when the core is disabled.])], 278 [enable_python_module="no"] 279 ) 280 ], 281 [ 282 AS_IF( 283 [test "x$enable_python_module" != "xno"], 284 [ 285 AC_ARG_WITH([cython], AS_HELP_STRING([--with-cython], [Override the automatic detection of the Cython executable. (default=check)]), [], [with_cython=check]) 286 AS_IF( 287 [test "x$with_cython" = "xcheck"], 288 [AC_CHECK_PROGS([CYTHON], [cython3 cython])], 289 [CYTHON="$with_cython"] 290 ) 291 292 AS_IF( 293 [test "x$CYTHON" = "x"], 294 [AC_MSG_ERROR([Cython required but not found.])] 295 ) 296 AC_SUBST([CYTHON]) 297 298 AS_IF( 299 [test -z "$PYTHON_VERSION"], 300 [AM_PATH_PYTHON([3])] 301 ) 302 303 AS_IF( 304 [test -z "$PYTHON3_LIBS"], 305 [ 306 PKG_CHECK_MODULES([PYTHON3], 307 [python-$PYTHON_VERSION-embed], 308 [], 309 [ 310 PKG_CHECK_MODULES([PYTHON3], 311 [python-$PYTHON_VERSION]) 312 ]) 313 ] 314 ) 315 316 AS_CASE( 317 [$host_os], 318 [darwin*], 319 [ 320 AC_SUBST([PYTHON_MODULE_UNDEFINED], ["-undefined dynamic_lookup"]) 321 ], 322 [cygwin*|mingw*], 323 [ 324 AC_SUBST([PYTHON_MODULE_UNDEFINED], ["-no-undefined"]) 325 AC_SUBST([MAYBE_PYTHON3_LIBS], ["$PYTHON3_LIBS"]) 326 ] 327 ) 328 ] 329 ) 330 ] 331) 332AM_CONDITIONAL([PYTHONMODULE], [test "x$enable_python_module" != "xno"]) 333 334 335 336AC_ARG_ENABLE([plugins], AS_HELP_STRING([--enable-plugins], [Enable all included plugins. Each individual plugin has a switch which overrides this. (default=)])) 337 338AC_ARG_ENABLE([subtext], AS_HELP_STRING([--enable-subtext], [Enable the subtitle rendering plugin. Requires libass and ffmpeg. (default=auto)])) 339AC_ARG_ENABLE([eedi3], AS_HELP_STRING([--enable-eedi3], [Enable the eedi3 plugin. (default=yes)])) 340AC_ARG_ENABLE([imwri], AS_HELP_STRING([--enable-imwri], [Enable the image reader/writer plugin. Requires ImageMagick. (default=auto)])) 341AC_ARG_ENABLE([miscfilters], AS_HELP_STRING([--enable-miscfilters], [Enable the miscellaneous filters plugin. (default=yes)])) 342AC_ARG_ENABLE([morpho], AS_HELP_STRING([--enable-morpho], [Enable the morpho plugin. (default=yes)])) 343AC_ARG_ENABLE([ocr], AS_HELP_STRING([--enable-ocr], [Enable the ocr plugin. Requires tesseract. (default=auto)])) 344AC_ARG_ENABLE([removegrain], AS_HELP_STRING([--enable-removegrain], [Enable the removegrain plugin. (default=yes)])) 345AC_ARG_ENABLE([vinverse], AS_HELP_STRING([--enable-vinverse], [Enable the vinverse plugin. (default=yes)])) 346AC_ARG_ENABLE([vivtc], AS_HELP_STRING([--enable-vivtc], [Enable the vivtc plugin. (default=yes)])) 347 348subtext="" 349eedi3="" 350imwri="" 351miscfilters="" 352morpho="" 353ocr="" 354removegrain="" 355vinverse="" 356vivtc="" 357 358AS_CASE( 359 [$enable_plugins], 360 [yes], [ 361 AS_IF([test "x$enable_subtext" != "xno"], [subtext="yes"]) 362 AS_IF([test "x$enable_eedi3" != "xno"], [eedi3="yes"]) 363 AS_IF([test "x$enable_imwri" != "xno"], [imwri="yes"]) 364 AS_IF([test "x$enable_miscfilters" != "xno"], [miscfilters="yes"]) 365 AS_IF([test "x$enable_morpho" != "xno"], [morpho="yes"]) 366 AS_IF([test "x$enable_ocr" != "xno"], [ocr="yes"]) 367 AS_IF([test "x$enable_removegrain" != "xno"], [removegrain="yes"]) 368 AS_IF([test "x$enable_vinverse" != "xno"], [vinverse="yes"]) 369 AS_IF([test "x$enable_vivtc" != "xno"], [vivtc="yes"]) 370 ], 371 [no], [ 372 AS_IF([test "x$enable_subtext" = "xyes"], [subtext="yes"]) 373 AS_IF([test "x$enable_eedi3" = "xyes"], [eedi3="yes"]) 374 AS_IF([test "x$enable_imwri" = "xyes"], [imwri="yes"]) 375 AS_IF([test "x$enable_miscfilters" = "xyes"], [miscfilters="yes"]) 376 AS_IF([test "x$enable_morpho" = "xyes"], [morpho="yes"]) 377 AS_IF([test "x$enable_ocr" = "xyes"], [ocr="yes"]) 378 AS_IF([test "x$enable_removegrain" = "xyes"], [removegrain="yes"]) 379 AS_IF([test "x$enable_vinverse" = "xyes"], [vinverse="yes"]) 380 AS_IF([test "x$enable_vivtc" = "xyes"], [vivtc="yes"]) 381 ], 382 [ 383 AS_IF([test "x$enable_subtext" != "xno"], [AS_IF([test "x$enable_subtext" = "xyes"], [subtext="yes"], [subtext="auto"])]) 384 AS_IF([test "x$enable_eedi3" != "xno"], [eedi3="yes"]) 385 AS_IF([test "x$enable_imwri" != "xno"], [AS_IF([test "x$enable_imwri" = "xyes"], [imwri="yes"], [imwri="auto"])]) 386 AS_IF([test "x$enable_miscfilters" != "xno"], [miscfilters="yes"]) 387 AS_IF([test "x$enable_morpho" != "xno"], [morpho="yes"]) 388 AS_IF([test "x$enable_ocr" != "xno"], [AS_IF([test "x$enable_ocr" = "xyes"], [ocr="yes"], [ocr="auto"])]) 389 AS_IF([test "x$enable_removegrain" != "xno"], [removegrain="yes"]) 390 AS_IF([test "x$enable_vinverse" != "xno"], [vinverse="yes"]) 391 AS_IF([test "x$enable_vivtc" != "xno"], [vivtc="yes"]) 392 ] 393) 394 395AC_CHECK_HEADERS( 396 [iconv.h], 397 [], 398 [ 399 AS_IF( 400 [test "x$subtext" = "xyes"], 401 [AC_MSG_ERROR([the subtext plugin was explicitly enabled, but iconv.h cannot be found.])], 402 [subtext=""] 403 ) 404 ] 405 ) 406 407AC_SEARCH_LIBS([iconv_open], [iconv]) 408 409AS_IF( 410 [test "x$ac_cv_search_iconv_open" = "xno"], 411 [ 412 AS_IF( 413 [test "x$subtext" = "xyes"], 414 [AC_MSG_ERROR([the subtext plugin was explicitly enabled, but iconv_open cannot be found.])], 415 [subtext=""] 416 ) 417 ] 418 ) 419 420PKG_CHECK_MODULES( 421 [LIBASS], 422 [libass], 423 [], 424 [ 425 AS_IF( 426 [test "x$subtext" = "xyes"], 427 [AC_MSG_ERROR([the subtext plugin was explicitly enabled, but libass cannot be found.])], 428 [subtext=""] 429 ) 430 ] 431 ) 432 433PKG_CHECK_MODULES( 434 [FFMPEG], 435 [libavcodec libavformat libavutil], 436 [ 437 saved_cppflags="$CPPFLAGS" 438 CPPFLAGS="$FFMPEG_CFLAGS $CPPFLAGS" 439 AC_COMPILE_IFELSE( 440 [ 441 AC_LANG_SOURCE( 442 [[ 443 #ifdef __cplusplus 444 extern "C" { 445 #endif 446 447 #include <libavcodec/avcodec.h> 448 449 #ifdef __cplusplus 450 } 451 #endif 452 453 void foo() { 454 AVSubtitleRect r; 455 r.data[0] = 0; 456 } 457 ]] 458 ) 459 ], 460 [], 461 [AC_DEFINE([VS_HAVE_AVSUBTITLERECT_AVPICTURE])] 462 ) 463 CPPFLAGS="$saved_cppflags" 464 ], 465 [ 466 AS_IF( 467 [test "x$subtext" = "xyes"], 468 [AC_MSG_ERROR([the subtext plugin was explicitly enabled, but the required ffmpeg libraries cannot be found.])], 469 [subtext=""] 470 ) 471 ] 472 ) 473 474PKG_CHECK_MODULES( 475 [IMAGEMAGICK], 476 [Magick++ >= 7], 477 [ 478 AC_MSG_CHECKING([whether imagemagick is usable]) 479 480 saved_cppflags="$CPPFLAGS" 481 CPPFLAGS="$IMAGEMAGICK_CFLAGS $CPPFLAGS" 482 AC_COMPILE_IFELSE( 483 [ 484 AC_LANG_SOURCE( 485 [[ 486#if !defined(MAGICKCORE_QUANTUM_DEPTH) || (MAGICKCORE_QUANTUM_DEPTH != 16 && MAGICKCORE_QUANTUM_DEPTH != 32) 487#error imwri plugin requires ImageMagick with quantum depth of 16 or 32. 488#endif 489 490#if !defined(MAGICKCORE_HDRI_ENABLE) || MAGICKCORE_HDRI_ENABLE == 0 491#error imwri plugin requires ImageMagick with HDRI enabled. 492#endif 493 ]] 494 ) 495 ], 496 [usable_imagemagick="yes"], 497 [usable_imagemagick="no"] 498 ) 499 CPPFLAGS="$saved_cppflags" 500 501 AC_MSG_RESULT([$usable_imagemagick]) 502 503 AS_CASE([$imwri], 504 [yes], [ 505 AS_IF( 506 [test "x$usable_imagemagick" = "xno"], 507 [AC_MSG_ERROR([the imwri plugin was explicitly enabled, but imagemagick is not usable.])] 508 ) 509 ], 510 [auto], [ 511 AS_IF( 512 [test "x$usable_imagemagick" = "xno"], 513 [imwri=""] 514 ) 515 ] 516 ) 517 ], 518 [ 519 AS_IF( 520 [test "x$imwri" = "xyes"], 521 [AC_MSG_ERROR([the imwri plugin was explicitly enabled, but imagemagick cannot be found.])], 522 [imwri=""] 523 ) 524 ] 525 ) 526 527PKG_CHECK_MODULES( 528 [TESSERACT], 529 [tesseract], 530 [], 531 [ 532 AS_IF( 533 [test "x$ocr" = "xyes"], 534 [AC_MSG_ERROR([the ocr plugin was explicitly enabled, but tesseract cannot be found.])], 535 [ocr=""] 536 ) 537 ] 538 ) 539 540AM_CONDITIONAL([SUBTEXT], [test "$subtext"]) 541AM_CONDITIONAL([EEDI3], [test "$eedi3"]) 542AM_CONDITIONAL([IMWRI], [test "$imwri"]) 543AM_CONDITIONAL([MISCFILTERS], [test "$miscfilters"]) 544AM_CONDITIONAL([MORPHO], [test "$morpho"]) 545AM_CONDITIONAL([OCR], [test "$ocr"]) 546AM_CONDITIONAL([REMOVEGRAIN], [test "$removegrain"]) 547AM_CONDITIONAL([VINVERSE], [test "$vinverse"]) 548AM_CONDITIONAL([VIVTC], [test "$vivtc"]) 549 550 551AS_IF( 552 [test "x$enable_core" != "xno" -o "x$enable_vsscript" != "xno" -o "x$enable_vspipe" != "xno" -o "x$imwri" != "x"], 553 [ 554 saved_cxxflags="$CXXFLAGS" 555 CXXFLAGS="-std=c++11" 556 AC_LANG_PUSH([C++]) 557 AC_COMPILE_IFELSE( 558 [AC_LANG_SOURCE( 559 [[ 560#include <mutex> 561 562std::mutex test_mutex; 563 ]] 564 )], 565 [], 566 [AC_MSG_ERROR([C++ compiler does not understand std::mutex (a C++11 feature).])] 567 ) 568 569 AC_LANG_POP([C++]) 570 CXXFLAGS="$saved_cxxflags" 571 ] 572) 573 574 575 576dnl Workaround for a bug in libtool 577dnl The windows libtool uses a file magic checking method that only accepts 578dnl dynamic libraries. Change it for libtool's alternative checking method. 579 580dnl Workaround found in configure.ac from ffms2. 581 582dnl Reproducing the error message below, for search engines and people 583dnl looking for a solution... 584 585dnl *** Warning: linker path does not have real file for library -lfftw3f. 586dnl *** I have the capability to make that library automatically link in when 587dnl *** you link to this library. But I can only do this if you have a 588dnl *** shared version of the library, which you do not appear to have 589dnl *** because I did check the linker path looking for a file starting 590dnl *** with libfftw3f and none of the candidates passed a file format test 591dnl *** using a file magic. Last file checked: /home/asdf/mingw-w64/i686/mingw/lib/libfftw3f.a 592dnl *** The inter-library dependencies that have been dropped here will be 593dnl *** automatically added whenever a program is linked with this library 594dnl *** or is declared to -dlopen it. 595dnl * 596dnl *** Since this library must not contain undefined symbols, 597dnl *** because either the platform does not support them or 598dnl *** it was explicitly requested with -no-undefined, 599dnl *** libtool will only create a static version of it. 600 601if test "$lt_cv_file_magic_cmd" = "func_win32_libid" ; then 602 deplibs_check_method='file_magic file format pei*-(i386|x86-64)|(.*architecture: i386)?' 603 file_magic_cmd='$OBJDUMP -f' 604fi 605 606 607 608AC_CONFIG_FILES([Makefile]) 609AC_OUTPUT 610