1m4_define([LIBASS_VERSION], [0.15.2]) 2AC_INIT(libass, LIBASS_VERSION) 3AM_INIT_AUTOMAKE([foreign]) 4AC_CONFIG_MACRO_DIR([m4]) 5# Disable Fortran checks 6define([AC_LIBTOOL_LANG_F77_CONFIG], [:]) 7LT_INIT 8AC_CONFIG_SRCDIR([libass/ass.c]) 9AC_CONFIG_HEADERS([config.h]) 10 11# Checks for programs. 12AC_PROG_CC 13AM_PROG_CC_C_O 14 15# Checks for header files. 16AC_CHECK_HEADERS_ONCE([iconv.h]) 17 18# Checks for library functions. 19AC_CHECK_FUNCS([strdup strndup]) 20 21# Query configuration parameters and set their description 22AC_ARG_ENABLE([test], AS_HELP_STRING([--enable-test], 23 [enable test program (requires libpng) @<:@default=no@:>@])) 24AC_ARG_ENABLE([compare], AS_HELP_STRING([--enable-compare], 25 [enable compare program (requires libpng) @<:@default=no@:>@])) 26AC_ARG_ENABLE([profile], AS_HELP_STRING([--enable-profile], 27 [enable profiling program @<:@default=no@:>@])) 28AC_ARG_ENABLE([fontconfig], AS_HELP_STRING([--disable-fontconfig], 29 [disable fontconfig support @<:@default=enabled@:>@])) 30AC_ARG_ENABLE([directwrite], AS_HELP_STRING([--disable-directwrite], 31 [disable DirectWrite support (Windows only) @<:@default=check@:>@])) 32AC_ARG_ENABLE([coretext], AS_HELP_STRING([--disable-coretext], 33 [disable CoreText support (OSX only) @<:@default=check@:>@])) 34AC_ARG_ENABLE([require-system-font-provider], AS_HELP_STRING([--disable-require-system-font-provider], 35 [allow compilation even if no system font provider was found @<:@default=enabled:>@])) 36AC_ARG_ENABLE([asm], AS_HELP_STRING([--disable-asm], 37 [disable compiling with ASM @<:@default=check@:>@])) 38AC_ARG_ENABLE([large-tiles], AS_HELP_STRING([--enable-large-tiles], 39 [use larger tiles in the rasterizer (better performance, slightly worse quality) @<:@default=disabled@:>@])) 40 41# Checks for available libraries and define corresponding C Macros 42# Start with system libs, then check everything else via pkg-config 43AS_IF([test "x$ac_cv_header_iconv_h" = xyes], [ 44 ## Some iconv libraries like GNU's libiconv define iconv_open as a macro to 45 ## libiconv_open. As SEARCH_LIBS tests linking not compilation, check for 46 ## libiconv_open first. SEARCH_LIBS is smart enough to not add -liconv a second 47 ## time in case both versions are defined in the local libiconv. 48 use_libiconv=false 49 AC_SEARCH_LIBS([libiconv_open], [iconv], [ 50 use_libiconv=true 51 ]) 52 AC_SEARCH_LIBS([iconv_open], [iconv], [ 53 use_libiconv=true 54 ]) 55 AS_IF([test "x$use_libiconv" = xtrue], [ 56 AC_DEFINE(CONFIG_ICONV, 1, [use iconv]) 57 ]) 58]) 59# Locate math functions. Most systems have it either in libc or libm, but a few 60# have some, eg C89, functions in libc and others in libm. Use C99 lrint to probe. 61AC_SEARCH_LIBS([lrint], [m], [ 62 # noop 63], [ 64 AC_MSG_ERROR([Unable to locate math functions!]) 65]) 66pkg_libs="$LIBS" 67 68## Check for libraries via pkg-config 69PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 9.10.3], [ 70 CFLAGS="$CFLAGS $FREETYPE_CFLAGS" 71 LIBS="$LIBS $FREETYPE_LIBS" 72 AC_DEFINE(CONFIG_FREETYPE, 1, [found freetype2 via pkg-config]) 73]) 74 75PKG_CHECK_MODULES([FRIBIDI], [fribidi >= 0.19.0], [ 76 CFLAGS="$CFLAGS $FRIBIDI_CFLAGS" 77 LIBS="$LIBS $FRIBIDI_LIBS" 78 AC_DEFINE(CONFIG_FRIBIDI, 1, [found fribidi via pkg-config]) 79]) 80 81PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 1.2.3], [ 82 CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS" 83 LIBS="$LIBS $HARFBUZZ_LIBS" 84 AC_DEFINE(CONFIG_HARFBUZZ, 1, [found harfbuzz via pkg-config]) 85]) 86 87libpng=false 88AS_IF([test "x$enable_test" = xyes || test "x$enable_compare" = xyes], [ 89 PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.2.0], [ 90 CFLAGS="$CFLAGS $LIBPNG_CFLAGS" 91 AC_DEFINE(CONFIG_LIBPNG, 1, [found libpng via pkg-config]) 92 libpng=true 93 ]) 94]) 95 96## Check for system font providers 97### Fontconfig 98AS_IF([test "x$enable_fontconfig" != xno], [ 99 PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.10.92], [ 100 CFLAGS="$CFLAGS $FONTCONFIG_CFLAGS" 101 LIBS="$LIBS $FONTCONFIG_LIBS" 102 AC_DEFINE(CONFIG_FONTCONFIG, 1, [found fontconfig via pkg-config]) 103 fontconfig=true 104 ], [ 105 fontconfig=false 106 ]) 107]) 108 109### Coretext 110AS_IF([test "x$enable_coretext" != xno], [ 111 # Linking to CoreText directly only works from Mountain Lion and iOS. 112 # In earlier OS X releases CoreText was part of the ApplicationServices 113 # umbrella framework. 114 AC_MSG_CHECKING([for CORETEXT]) 115 AC_COMPILE_IFELSE([ 116 AC_LANG_PROGRAM( dnl# First test for legacy include 117 [[#include <ApplicationServices/ApplicationServices.h>]], 118 [[CTFontDescriptorCopyAttribute(NULL, kCTFontURLAttribute);]] 119 ) 120 ], [ 121 LIBS="$LIBS -framework ApplicationServices -framework CoreFoundation" 122 AC_DEFINE(CONFIG_CORETEXT, 1, [found CoreText in ApplicationServices framework]) 123 coretext=true 124 AC_MSG_RESULT([yes]) 125 ], [ 126 AC_COMPILE_IFELSE([ 127 AC_LANG_PROGRAM( dnl# Otherwise check newer include style 128 [[#include <CoreText/CoreText.h>]], 129 [[CTFontDescriptorCopyAttribute(NULL, kCTFontURLAttribute);]] 130 ) 131 ], [ 132 LIBS="$LIBS -framework CoreText -framework CoreFoundation" 133 AC_DEFINE(CONFIG_CORETEXT, 1, [found CoreText framework]) 134 coretext=true 135 AC_MSG_RESULT([yes]) 136 ], [ 137 coretext=false 138 AC_MSG_RESULT([no]) 139 ]) 140 ]) 141]) 142 143### DirectWrite 144AS_IF([test "x$enable_directwrite" != xno], [ 145 # Linking to DirectWrite directly only works from Windows 146 AC_MSG_CHECKING([for DIRECTWRITE]) 147 AC_COMPILE_IFELSE([ 148 AC_LANG_PROGRAM([[#include <windows.h>]], [[;]]) 149 ], [ 150 directwrite=true 151 AC_MSG_RESULT([yes]) 152 AC_MSG_CHECKING([for Win32 desktop APIs]) 153 AC_COMPILE_IFELSE([ 154 AC_LANG_PROGRAM([[ 155 #include <winapifamily.h> 156 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 157 #error Win32 desktop APIs are available 158 #endif 159 ]], [[;]]) 160 ], [ 161 # WinRT/UWP/app build: GDI and LoadLibrary are 162 # unavailable, but DirectWrite is always present 163 LIBS="$LIBS -ldwrite" 164 AC_DEFINE(CONFIG_DIRECTWRITE, 1, [found DirectWrite (WinRT/UWP)]) 165 AC_MSG_RESULT([no]) 166 ], [ 167 # Win32/desktop build: GDI is always present; 168 # DirectWrite is optional but can be loaded via LoadLibrary 169 LIBS="$LIBS -lgdi32" 170 AC_DEFINE(CONFIG_DIRECTWRITE, 1, [found DirectWrite and GDI (Win32)]) 171 AC_MSG_RESULT([yes]) 172 ]) 173 ], [ 174 directwrite=false 175 AC_MSG_RESULT([no]) 176 ]) 177]) 178 179## Require at least one system font provider by default 180AS_IF([test "x$enable_require_system_font_provider" != xno dnl 181 && test "x$fontconfig" != xtrue dnl 182 && test "x$directwrite" != xtrue dnl 183 && test "x$coretext" != xtrue ], [ 184 AC_MSG_ERROR(m4_text_wrap(m4_normalize([ 185 Either DirectWrite (on Windows), CoreText (on OSX), or Fontconfig 186 (Linux, other) is required. If you really want to compile without 187 a system font provider, add --disable-require-system-font-provider]), 188 [ ], 189 [No system font provider!], 190 [78] 191 )) 192]) 193 194## Now add packages to pkg_requires 195pkg_requires="freetype2 >= 9.10.3" 196pkg_requires="fribidi >= 0.19.0, ${pkg_requires}" 197pkg_requires="harfbuzz >= 1.2.3, ${pkg_requires}" 198AS_IF([test "x$fontconfig" = xtrue], [ 199 pkg_requires="fontconfig >= 2.10.92, ${pkg_requires}" 200]) 201 202 203# Locate and configure Assembler appropriately 204AS_IF([test "x$enable_asm" != xno], [ 205 AS_CASE([$host], 206 [i?86-*], [ 207 INTEL=true 208 AS=nasm 209 X86=true 210 BITS=32 211 BITTYPE=32 212 ASFLAGS="$ASFLAGS -DARCH_X86_64=0" 213 ], 214 [x86_64-*-gnux32|amd64-*-gnux32], [ 215 AS=nasm 216 INTEL=true 217 X64=true 218 BITS=64 219 BITTYPE=x32 220 ASFLAGS="$ASFLAGS -DARCH_X86_64=1" 221 ], 222 [x86_64-*|amd64-*], [ 223 AS=nasm 224 INTEL=true 225 X64=true 226 BITS=64 227 BITTYPE=64 228 ASFLAGS="$ASFLAGS -DARCH_X86_64=1" 229 ], 230 [ # default 231 INTEL=false 232 ] 233 ) 234 AS_IF([test "x$INTEL" = xtrue], [ 235 AC_CHECK_PROG([nasm_check], [$AS], [yes]) 236 AS_IF([test "x$nasm_check" != xyes], [ 237 AC_MSG_WARN(nasm was not found; ASM functions are disabled.) 238 AC_MSG_WARN(Install nasm for a significantly faster libass build.) 239 enable_asm=no 240 ], [ 241 AS_CASE([$host], 242 [*darwin*], [ 243 ASFLAGS="$ASFLAGS -f macho$BITTYPE -DPREFIX -DSTACK_ALIGNMENT=16" 244 ], 245 [*linux*|*solaris*|*haiku*], [ 246 ASFLAGS="$ASFLAGS -f elf$BITTYPE -DSTACK_ALIGNMENT=16" 247 ], 248 [*dragonfly*|*bsd*], [ 249 ASFLAGS="$ASFLAGS -f elf$BITTYPE" 250 ], 251 [*cygwin*|*mingw*], [ 252 ASFLAGS="$ASFLAGS -f win$BITTYPE" 253 AS_IF([test "x$BITS" = x32], [ 254 ASFLAGS="$ASFLAGS -DPREFIX" 255 ]) 256 ], 257 [ # default 258 AC_MSG_ERROR(m4_text_wrap(m4_normalize([ 259 Please contact libass upstream to figure out if ASM 260 support for your platform can be added. 261 In the meantime you will need to use --disable-asm.]), 262 [ ], 263 [could not identify NASM format for $host !], 264 [78] 265 )) 266 ] 267 ) 268 ASFLAGS="$ASFLAGS -Dprivate_prefix=ass" 269 AC_MSG_CHECKING([if $AS supports vpmovzxwd]) 270 echo "vpmovzxwd ymm0, xmm0" > conftest.asm 271 AS_IF([$AS conftest.asm $ASFLAGS -o conftest.o >conftest.log 2>&1], [ 272 AC_MSG_RESULT([yes]) 273 ], [ 274 AC_MSG_RESULT([no]) 275 VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1` 276 AC_MSG_WARN([nasm is too old (found $VER); ASM functions are disabled.]) 277 AC_MSG_WARN([Install nasm-2.10 or later for a significantly faster libass build.]) 278 enable_asm=no 279 ]) 280 rm conftest.asm conftest.o > /dev/null 2>&1 281 ]) 282 ]) 283]) 284 285 286# Relay config results to output files 287 288## Tell Makefiles which assembler and flags to use 289AC_SUBST([ASFLAGS], ["$ASFLAGS"]) 290AC_SUBST([AS], ["$AS"]) 291 292## Relay package configuration to libass.pc.in 293AC_SUBST([PKG_LIBS_PRIVATE], [${pkg_libs}]) 294AC_SUBST([PKG_REQUIRES_PRIVATE], [${pkg_requires}]) 295 296## Setup conditionals for use in Makefiles 297AM_CONDITIONAL([ASM], [test "x$enable_asm" != xno]) 298AM_CONDITIONAL([INTEL], [test "x$INTEL" = xtrue]) 299AM_CONDITIONAL([X86], [test "x$X86" = xtrue]) 300AM_CONDITIONAL([X64], [test "x$X64" = xtrue]) 301 302AM_CONDITIONAL([ENABLE_LARGE_TILES], [test "x$enable_large_tiles" = xyes]) 303 304AM_CONDITIONAL([ENABLE_COMPARE], [test "x$enable_compare" = xyes && test "x$libpng" = xtrue]) 305AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = xyes && test "x$libpng" = xtrue]) 306AM_CONDITIONAL([ENABLE_PROFILE], [test "x$enable_profile" = xyes]) 307 308AM_CONDITIONAL([FONTCONFIG], [test "x$fontconfig" = xtrue]) 309AM_CONDITIONAL([CORETEXT], [test "x$coretext" = xtrue]) 310AM_CONDITIONAL([DIRECTWRITE], [test "x$directwrite" = xtrue]) 311 312## Define C Macros not relating to libraries 313AM_COND_IF([ASM], [ 314 AC_DEFINE(CONFIG_ASM, 1, [ASM enabled]) 315], [ 316 AC_DEFINE(CONFIG_ASM, 0, [ASM enabled]) 317]) 318 319AM_COND_IF([ENABLE_LARGE_TILES], [ 320 AC_DEFINE(CONFIG_LARGE_TILES, 1, [use large tiles]) 321], [ 322 AC_DEFINE(CONFIG_LARGE_TILES, 0, [use small tiles]) 323]) 324 325## Make a guess about the source code version 326AS_IF([test -d "${srcdir}/.git"], [ 327 AC_PATH_PROG([git_bin], [git]) 328 AS_IF([test -n "$git_bin"], [ 329 srcversion_string="commit: $("$git_bin" -C "$srcdir" describe --tags --long --always --dirty --broken --abbrev=40)" 330 ], [ 331 srcversion_string="custom after: LIBASS_VERSION" 332 ]) 333], [ 334 dnl# Hope no one creates custom tarballs without adjusting the version 335 srcversion_string="tarball: LIBASS_VERSION" 336]) 337AC_DEFINE_UNQUOTED([CONFIG_SOURCEVERSION], ["$srcversion_string"], 338 [string containing info about the used source]) 339 340## Setup output beautifier. 341m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 342 343AC_CONFIG_FILES([Makefile libass/Makefile test/Makefile compare/Makefile profile/Makefile libass.pc]) 344AC_OUTPUT 345