Merge pull request #1095 from JustinTArthur/standards-docs-sync
[vapoursynth.git] / configure.ac
blob01e6600ee3c88925d767cd02ef033e56d3c57f23
1 AC_INIT(
2         [vapoursynth],
3         m4_esyscmd_s([sed -e 's/.* \(.*\)/\1/' VAPOURSYNTH_VERSION]),
4         [https://github.com/vapoursynth/vapoursynth/issues],
5         [vapoursynth],
6         [http://www.vapoursynth.com/]
9 : ${CFLAGS=""}
10 : ${CXXFLAGS=""}
12 AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects no-define])
13 AM_SILENT_RULES([yes])
15 LT_INIT([win32-dll])
17 AC_PROG_CC
18 AC_PROG_CXX
20 AC_CONFIG_MACRO_DIRS([m4])
22 AC_SYS_LARGEFILE
23 AC_FUNC_FSEEKO
24 AX_PTHREAD
27 AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable compilation options required for debugging. (default=no)]))
28 AS_IF(
29       [test "x$enable_debug" = "xyes"],
30       [
31        AC_DEFINE([VS_CORE_DEBUG])
32        AC_SUBST([DEBUGCFLAGS], ["-O0 -g3 -ggdb -ftrapv"])
33       ],
34       [
35        AC_DEFINE([NDEBUG])
36       ]
41 AC_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.]))
42 AS_IF(
43       [test "x$enable_guard_pattern" = "xyes"],
44       [
45        AC_DEFINE([VS_FRAME_GUARD])
46       ]
51 AC_ARG_WITH(
52             [plugindir],
53             AS_HELP_STRING([--with-plugindir], [The default value for the configuration option 'SystemPluginDir' in vapoursynth.conf. (default=LIBDIR/vapoursynth)]),
54             [PLUGINDIR=$with_plugindir],
55             [PLUGINDIR=$libdir/$PACKAGE_NAME]
57 dnl Can't do it with AC_DEFINE because $libdir wouldn't be expanded fully.
58 AC_SUBST([PLUGINDIR])
62 AC_CANONICAL_HOST
65 X86="false"
66 PPC="false"
67 ARM="false"
69 AS_CASE(
70         [$host_cpu],
71         [i?86],     [BITS="32" X86="true"],
72         [x86_64],   [BITS="64" X86="true"],
73         [powerpc*], [PPC="true"],
74         [arm*],     [ARM="true"], # Maybe doesn't work for all arm systems?
75         [aarch64*], [ARM="true"]
78 AS_CASE(
79         [$host_os],
80         [darwin*],
81         [
82          AC_DEFINE([VS_TARGET_OS_DARWIN])
83          AC_SUBST([UNDEFINEDLDFLAGS], ["-Wl,-undefined,error"])
84         ],
85         [*linux*|gnu*|dragonfly*|*bsd*], # The BSDs are close enough, right?
86         [
87          AC_DEFINE([VS_TARGET_OS_LINUX])
88          AC_SUBST([UNDEFINEDLDFLAGS], ["-Wl,--no-undefined"])
89         ],
90         [cygwin*|mingw*],
91         [
92          AS_IF(
93                [test "x$BITS" = "x32"],
94                [
95                 AC_SUBST([PLUGINLDFLAGS], ["-Wl,--kill-at"])
96                 AC_SUBST([STACKREALIGN], ["-mstackrealign"])
97                ]
98          )
99          AC_DEFINE([VS_TARGET_OS_WINDOWS])
100          AC_SUBST([UNICODECFLAGS], ["-DUNICODE -D_UNICODE"])
101          AC_SUBST([UNICODELDFLAGS], ["-municode"])
102         ],
103         [AC_MSG_ERROR([Unknown host OS])]
106 AS_IF(
107       [test "x$X86" = "xtrue"],
108       [
109        AC_ARG_ENABLE([x86-asm], AS_HELP_STRING([--enable-x86-asm], [Enable assembler code for x86 CPUs. (default=yes)]))
111        AS_IF(
112              [test "x$enable_x86_asm" != "xno"],
113              [
114               AC_DEFINE([VS_TARGET_CPU_X86])
115              ]
116        )
118        AC_SUBST([MFLAGS], ["-mfpmath=sse -msse2"])
119        AC_SUBST([AVX2FLAGS], ["-mavx2 -mfma -mtune=haswell"])
120       ]
123 AS_IF(
124       [test "x$PPC" = "xtrue"],
125       [AC_DEFINE([VS_TARGET_CPU_POWERPC])]
128 AS_IF(
129       [test "x$ARM" = "xtrue"],
130       [AC_DEFINE([VS_TARGET_CPU_ARM])]
135 AC_ARG_ENABLE([core], AS_HELP_STRING([--enable-core], [Build the VapourSynth core library. (default=yes)]))
136 AS_IF(
137       [test "x$enable_core" != "xno"],
138       [
139        AC_DEFINE([VS_CORE_EXPORTS])    
140        AC_DEFINE([VS_USE_LATEST_API])
141        AC_DEFINE([VS_GRAPH_API])
143        PKG_CHECK_MODULES([ZIMG], [zimg >= 3.0.5])
145        AC_LANG_PUSH([C++])
146        saved_cppflags="$CPPFLAGS"
147        saved_libs="$LIBS"
148        CPPFLAGS="$ZIMG_CFLAGS"
149        LIBS="$ZIMG_LIBS"
150        AC_LINK_IFELSE(
151                          [AC_LANG_PROGRAM(
152                                          [[
153 #include <zimg.h>
155 #if ZIMG_API_VERSION < ZIMG_MAKE_API_VERSION(2, 4)
156 #error zimg API v2.4 or greater required
157 #endif
158                                          ]],
159                                          [[
160 unsigned major, minor, micro;
161 zimg_get_version_info(&major, &minor, &micro);
162                                          ]]
163                          )],
164                          [],
165                          [AC_MSG_ERROR([failed to link zimg. See config.log for details.])]
166        )
169        CPPFLAGS="$saved_cppflags"
170        LIBS="$saved_libs"
171        AC_LANG_POP([C++])
174        AC_CONFIG_FILES([pc/vapoursynth.pc])
176        dnl Annoying shit...
177        AS_CASE(
178                [$host_os],
179                [cygwin*|mingw*],
180                [],
181                [
182                 saved_libs="$LIBS"
183                 AC_SEARCH_LIBS([dlopen], [dl dld], [], [AC_MSG_ERROR([Unable to find the dlopen() function.])])
184                 AS_IF(
185                       [test "x$ac_cv_search_dlopen" != "xnone required"],
186                       [AC_SUBST([DLOPENLIB], ["$ac_cv_search_dlopen"])]
187                 )
188                 LIBS="$saved_libs"
189                ]
190        )
192        AC_LANG_PUSH([C++])
193        AC_MSG_CHECKING([for sched_getaffinity])
194        AC_LINK_IFELSE(
195                          [AC_LANG_PROGRAM(
196                                          [[
197 #define _GNU_SOURCE
198 #include <sched.h>
199                                          ]],
200                                          [[
201 cpu_set_t affinity;
202 sched_getaffinity(0, sizeof(cpu_set_t), &affinity);
203 int count = CPU_COUNT(&affinity);
204                                          ]]
205                          )],
206                          [
207                           AC_DEFINE([HAVE_SCHED_GETAFFINITY])
208                           AC_MSG_RESULT([yes])
209                          ],
210                          [AC_MSG_RESULT([no])]
211        )
212        AC_LANG_POP([C++])
214        AC_LANG_PUSH([C++])
215        AC_MSG_CHECKING([for cpuset_getaffinity])
216        AC_LINK_IFELSE(
217                          [AC_LANG_PROGRAM(
218                                          [[
219 #include <sys/param.h>
220 #include <sys/_cpuset.h>
221 #include <sys/cpuset.h>
222                                          ]],
223                                          [[
224 cpuset_t affinity;
225 cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), &affinity);
226 int count = CPU_COUNT(&affinity);
227                                          ]]
228                          )],
229                          [
230                           AC_DEFINE([HAVE_CPUSET_GETAFFINITY])
231                           AC_MSG_RESULT([yes])
232                          ],
233                          [AC_MSG_RESULT([no])]
234        )
235        AC_LANG_POP([C++])
236       ]
238 AM_CONDITIONAL([VSCORE], [test "x$enable_core" != "xno"])
239 AM_CONDITIONAL([X86ASM], [test "x$X86" = "xtrue" -a "x$enable_x86_asm" != "xno"])
243 AC_ARG_ENABLE([vsscript], AS_HELP_STRING([--enable-vsscript], [Enable VSScript. Requires Python 3. (default=yes)]))
244 AS_IF(
245       [test "x$enable_vsscript" != "xno"],
246       [
247        AC_DEFINE([VS_USE_LATEST_API])
248        AC_DEFINE([VSSCRIPT_USE_LATEST_API])
249       
250        AM_PATH_PYTHON([3])
252        PKG_CHECK_MODULES([PYTHON3],
253                          [python-$PYTHON_VERSION-embed],
254                          [],
255                          [
256                           PKG_CHECK_MODULES([PYTHON3],
257                                             [python-$PYTHON_VERSION])
258                          ])
260        AC_CONFIG_FILES([pc/vapoursynth-script.pc])
261       ]
263 AM_CONDITIONAL([VSSCRIPT], [test "x$enable_vsscript" != "xno"])
267 AC_ARG_ENABLE([vspipe], AS_HELP_STRING([--enable-vspipe], [Build vspipe. Requires VSScript. (default=yes)]))
268 AS_IF(
269       [test "x$enable_vsscript" = "xno"],
270       [
271        AC_DEFINE([VS_USE_LATEST_API])
272        AC_DEFINE([VS_GRAPH_API])
273        AC_DEFINE([VSSCRIPT_USE_LATEST_API])
274        AS_IF(
275              [test "x$enable_vspipe" = "xyes"],
276              [AC_MSG_ERROR([Cannot build vspipe when VSScript is disabled.])],
277              [enable_vspipe="no"]
278        )
279       ]
281 AM_CONDITIONAL([VSPIPE], [test "x$enable_vspipe" != "xno"])
285 AC_ARG_ENABLE([python-module], AS_HELP_STRING([--enable-python-module], [Build the Python module. Requires Cython, Python, and the core. (default=yes)]))
286 AS_IF(
287       [test "x$enable_core" = "xno"],
288       [
289        AS_IF(
290              [test "x$enable_python_module" = "xyes"],
291              [AC_MSG_ERROR([Cannot build the Python module when the core is disabled.])],
292              [enable_python_module="no"]
293        )
294       ],
295       [
296        AS_IF(
297              [test "x$enable_python_module" != "xno"],
298              [
299               AC_ARG_WITH([cython], AS_HELP_STRING([--with-cython], [Override the automatic detection of the Cython executable. (default=check)]), [], [with_cython=check])
300               AS_IF(
301                     [test "x$with_cython" = "xcheck"],
302                     [AC_CHECK_PROGS([CYTHON], [cython3 cython])],
303                     [CYTHON="$with_cython"]
304               )
306               AS_IF(
307                     [test "x$CYTHON" = "x"],
308                     [AC_MSG_ERROR([Cython required but not found.])]
309               )
310               AC_SUBST([CYTHON])
312               AS_IF(
313                     [test -z "$PYTHON_VERSION"],
314                     [AM_PATH_PYTHON([3])]
315               )
317               AS_IF(
318                     [test -z "$PYTHON3_LIBS"],
319                     [
320                      PKG_CHECK_MODULES([PYTHON3],
321                                        [python-$PYTHON_VERSION-embed],
322                                        [],
323                                        [
324                                         PKG_CHECK_MODULES([PYTHON3],
325                                                           [python-$PYTHON_VERSION])
326                                        ])
327                     ]
328               )
330               AS_CASE(
331                       [$host_os],
332                       [darwin*],
333                       [
334                        AC_SUBST([PYTHON_MODULE_UNDEFINED], ["-undefined dynamic_lookup"])
335                       ],
336                       [cygwin*|mingw*],
337                       [
338                        AC_SUBST([PYTHON_MODULE_UNDEFINED], ["-no-undefined"])
339                        AC_SUBST([MAYBE_PYTHON3_LIBS], ["$PYTHON3_LIBS"])
340                       ]
341                      )
342              ]
343        )
344       ]
346 AM_CONDITIONAL([PYTHONMODULE], [test "x$enable_python_module" != "xno"])
350 dnl Workaround for a bug in libtool
351 dnl The windows libtool uses a file magic checking method that only accepts
352 dnl dynamic libraries. Change it for libtool's alternative checking method.
354 dnl Workaround found in configure.ac from ffms2.
356 dnl Reproducing the error message below, for search engines and people
357 dnl looking for a solution...
359 dnl *** Warning: linker path does not have real file for library -lfftw3f.
360 dnl *** I have the capability to make that library automatically link in when
361 dnl *** you link to this library.  But I can only do this if you have a
362 dnl *** shared version of the library, which you do not appear to have
363 dnl *** because I did check the linker path looking for a file starting
364 dnl *** with libfftw3f and none of the candidates passed a file format test
365 dnl *** using a file magic. Last file checked: /home/asdf/mingw-w64/i686/mingw/lib/libfftw3f.a
366 dnl *** The inter-library dependencies that have been dropped here will be
367 dnl *** automatically added whenever a program is linked with this library
368 dnl *** or is declared to -dlopen it.
369 dnl *
370 dnl *** Since this library must not contain undefined symbols,
371 dnl *** because either the platform does not support them or
372 dnl *** it was explicitly requested with -no-undefined,
373 dnl *** libtool will only create a static version of it.
375 if test "$lt_cv_file_magic_cmd" = "func_win32_libid" ; then
376     deplibs_check_method='file_magic file format pei*-(i386|x86-64)|(.*architecture: i386)?'
377     file_magic_cmd='$OBJDUMP -f'
382 AC_CONFIG_FILES([Makefile])
383 AC_OUTPUT