Don't use invalid python constant
[vapoursynth.git] / configure.ac
blob5c8c2dca9cf9f2f8ec89289036954aec048a892d
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        AM_PATH_PYTHON([3])
249        PKG_CHECK_MODULES([PYTHON3],
250                          [python-$PYTHON_VERSION-embed],
251                          [],
252                          [
253                           PKG_CHECK_MODULES([PYTHON3],
254                                             [python-$PYTHON_VERSION])
255                          ])
257        AC_CONFIG_FILES([pc/vapoursynth-script.pc])
258       ]
260 AM_CONDITIONAL([VSSCRIPT], [test "x$enable_vsscript" != "xno"])
264 AC_ARG_ENABLE([vspipe], AS_HELP_STRING([--enable-vspipe], [Build vspipe. Requires VSScript. (default=yes)]))
265 AS_IF(
266       [test "x$enable_vsscript" = "xno"],
267       [
268        AC_DEFINE([VS_GRAPH_API])
269        AS_IF(
270              [test "x$enable_vspipe" = "xyes"],
271              [AC_MSG_ERROR([Cannot build vspipe when VSScript is disabled.])],
272              [enable_vspipe="no"]
273        )
274       ]
276 AM_CONDITIONAL([VSPIPE], [test "x$enable_vspipe" != "xno"])
280 AC_ARG_ENABLE([python-module], AS_HELP_STRING([--enable-python-module], [Build the Python module. Requires Cython, Python, and the core. (default=yes)]))
281 AS_IF(
282       [test "x$enable_core" = "xno"],
283       [
284        AS_IF(
285              [test "x$enable_python_module" = "xyes"],
286              [AC_MSG_ERROR([Cannot build the Python module when the core is disabled.])],
287              [enable_python_module="no"]
288        )
289       ],
290       [
291        AS_IF(
292              [test "x$enable_python_module" != "xno"],
293              [
294               AC_ARG_WITH([cython], AS_HELP_STRING([--with-cython], [Override the automatic detection of the Cython executable. (default=check)]), [], [with_cython=check])
295               AS_IF(
296                     [test "x$with_cython" = "xcheck"],
297                     [AC_CHECK_PROGS([CYTHON], [cython3 cython])],
298                     [CYTHON="$with_cython"]
299               )
301               AS_IF(
302                     [test "x$CYTHON" = "x"],
303                     [AC_MSG_ERROR([Cython required but not found.])]
304               )
305               AC_SUBST([CYTHON])
307               AS_IF(
308                     [test -z "$PYTHON_VERSION"],
309                     [AM_PATH_PYTHON([3])]
310               )
312               AS_IF(
313                     [test -z "$PYTHON3_LIBS"],
314                     [
315                      PKG_CHECK_MODULES([PYTHON3],
316                                        [python-$PYTHON_VERSION-embed],
317                                        [],
318                                        [
319                                         PKG_CHECK_MODULES([PYTHON3],
320                                                           [python-$PYTHON_VERSION])
321                                        ])
322                     ]
323               )
325               AS_CASE(
326                       [$host_os],
327                       [darwin*],
328                       [
329                        AC_SUBST([PYTHON_MODULE_UNDEFINED], ["-undefined dynamic_lookup"])
330                       ],
331                       [cygwin*|mingw*],
332                       [
333                        AC_SUBST([PYTHON_MODULE_UNDEFINED], ["-no-undefined"])
334                        AC_SUBST([MAYBE_PYTHON3_LIBS], ["$PYTHON3_LIBS"])
335                       ]
336                      )
337              ]
338        )
339       ]
341 AM_CONDITIONAL([PYTHONMODULE], [test "x$enable_python_module" != "xno"])
345 dnl Workaround for a bug in libtool
346 dnl The windows libtool uses a file magic checking method that only accepts
347 dnl dynamic libraries. Change it for libtool's alternative checking method.
349 dnl Workaround found in configure.ac from ffms2.
351 dnl Reproducing the error message below, for search engines and people
352 dnl looking for a solution...
354 dnl *** Warning: linker path does not have real file for library -lfftw3f.
355 dnl *** I have the capability to make that library automatically link in when
356 dnl *** you link to this library.  But I can only do this if you have a
357 dnl *** shared version of the library, which you do not appear to have
358 dnl *** because I did check the linker path looking for a file starting
359 dnl *** with libfftw3f and none of the candidates passed a file format test
360 dnl *** using a file magic. Last file checked: /home/asdf/mingw-w64/i686/mingw/lib/libfftw3f.a
361 dnl *** The inter-library dependencies that have been dropped here will be
362 dnl *** automatically added whenever a program is linked with this library
363 dnl *** or is declared to -dlopen it.
364 dnl *
365 dnl *** Since this library must not contain undefined symbols,
366 dnl *** because either the platform does not support them or
367 dnl *** it was explicitly requested with -no-undefined,
368 dnl *** libtool will only create a static version of it.
370 if test "$lt_cv_file_magic_cmd" = "func_win32_libid" ; then
371     deplibs_check_method='file_magic file format pei*-(i386|x86-64)|(.*architecture: i386)?'
372     file_magic_cmd='$OBJDUMP -f'
377 AC_CONFIG_FILES([Makefile])
378 AC_OUTPUT