1dnl ---------------------------- 2dnl Automake/autoconf input file 3dnl ---------------------------- 4 5dnl --- Package configuration --- 6 7m4_define([chafa_major_version], [1]) 8m4_define([chafa_minor_version], [8]) 9m4_define([chafa_micro_version], [0]) 10 11m4_define([chafa_version], [chafa_major_version.chafa_minor_version.chafa_micro_version]) 12 13AC_PREREQ([2.69]) 14AC_INIT([chafa],[chafa_version],[hpj@hpjansson.org]) 15AM_INIT_AUTOMAKE([1.9 foreign dist-xz no-dist-gzip -Wall]) 16 17AC_CONFIG_SRCDIR([chafa.pc.in]) 18 19AC_CONFIG_MACRO_DIRS([m4]) 20AM_CONFIG_HEADER(config.h) 21 22CHAFA_MAJOR_VERSION=chafa_major_version 23CHAFA_MINOR_VERSION=chafa_minor_version 24CHAFA_MICRO_VERSION=chafa_micro_version 25CHAFA_VERSION=chafa_version 26 27AC_SUBST(CHAFA_MAJOR_VERSION) 28AC_SUBST(CHAFA_MINOR_VERSION) 29AC_SUBST(CHAFA_MICRO_VERSION) 30AC_SUBST(CHAFA_VERSION) 31 32AC_DEFINE(CHAFA_MAJOR_VERSION, [chafa_major_version], [Chafa major version]) 33AC_DEFINE(CHAFA_MINOR_VERSION, [chafa_minor_version], [Chafa minor version]) 34AC_DEFINE(CHAFA_MICRO_VERSION, [chafa_micro_version], [Chafa micro version]) 35AC_DEFINE_UNQUOTED(CHAFA_VERSION, "$CHAFA_VERSION", [Package version string]) 36 37dnl --- Standard setup --- 38 39BASE_CFLAGS="-Wall -Wextra -Wmissing-prototypes" 40 41AM_SANITY_CHECK 42AM_MAINTAINER_MODE 43 44AC_C_CONST 45AC_PROG_CC 46AC_PROG_CC_C99 47AC_PROG_CPP 48AC_PROG_INSTALL 49AM_PROG_AR 50LT_INIT 51 52dnl --- Required standards --- 53 54dnl POSIX.1-2008 is required to get SA_RESETHAND. We should get this by default 55dnl on most systems, but keep the check around just in case. 56 57dnl AC_MSG_CHECKING(for POSIX.1-2008) 58dnl AC_EGREP_CPP(posix_200809L_supported, 59dnl [#define _POSIX_C_SOURCE 200809L 60dnl #include <unistd.h> 61dnl #ifdef _POSIX_VERSION 62dnl # if _POSIX_VERSION == 200809L 63dnl posix_200809L_supported 64dnl # endif 65dnl #endif 66dnl ], 67dnl [AC_MSG_RESULT(yes)], 68dnl [AC_MSG_RESULT(no) 69dnl AC_MSG_FAILURE([Implementation must conform to the POSIX.1-2008 standard.])] 70dnl ) 71dnl 72dnl AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Minimum POSIX standard we need]) 73 74dnl --- Dependency check --- 75 76PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.10) 77 78AC_ARG_WITH(tools, 79 [AS_HELP_STRING([--without-tools], [don't build command-line tools [default=on]])], 80 , 81 with_tools=yes) 82AM_CONDITIONAL([WANT_TOOLS], [test "$with_tools" = "yes"]) 83AS_IF([test "$with_tools" != no], [ 84 PKG_CHECK_MODULES(MAGICKWAND, [MagickWand >= 6],, 85 [AC_MSG_ERROR([You need ImageMagick-devel (or libmagickwand-dev on debian) to build command-line tools, or pass --without-tools to build without.])]) 86 PKG_CHECK_MODULES(FREETYPE, [freetype2 >= 2.0.0],, 87 [AC_MSG_ERROR([You need freetype2-devel (or libfreetype6-dev on debian) to build command-line tools, or pass --without-tools to build without.])])]) 88 89# Used by gtk-doc's fixxref. 90GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`" 91AC_SUBST(GLIB_PREFIX) 92 93dnl --- Documentation --- 94 95# gtkdocize greps for ^GTK_DOC_CHECK and parses it, so you need to have 96# it on its own line. 97m4_ifdef([GTK_DOC_CHECK], [ 98GTK_DOC_CHECK([1.20], [--flavour no-tmpl]) 99],[ 100AM_CONDITIONAL([ENABLE_GTK_DOC],[false]) 101]) 102 103AC_ARG_ENABLE(man, 104 [AS_HELP_STRING([--enable-man], 105 [generate man pages [default=auto]])],, 106 enable_man=maybe) 107 108AS_IF([test "$enable_man" != no], [ 109 AC_PATH_PROG([XSLTPROC], [xsltproc]) 110 AS_IF([test -z "$XSLTPROC"], [ 111 AS_IF([test "$enable_man" = yes], [ 112 AC_MSG_ERROR([xsltproc is required for --enable-man]) 113 ]) 114 enable_man=no 115 ]) 116]) 117 118AS_IF([ test "$enable_man" != no ], [ 119 dnl check for DocBook DTD in the local catalog 120 JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN], 121 [DocBook XML DTD V4.1.2], [have_docbook_dtd=yes], [have_docbook_dtd=no]) 122 AS_IF([test "$have_docbook_dtd" != yes], [ 123 AS_IF([test "$enable_man" = yes ], [ 124 AC_MSG_ERROR([DocBook DTD is required for --enable-man]) 125 ]) 126 enable_man=no 127 ]) 128]) 129 130AS_IF([test "$enable_man" != no], [ 131 dnl check for DocBook XSL stylesheets in the local catalog 132 JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl], 133 [DocBook XSL Stylesheets], [have_docbook_style=yes],[have_docbook_style=no]) 134 AS_IF([ test "$have_docbook_style" != yes ], [ 135 AS_IF([ test "$enable_man" = yes ], [ 136 AC_MSG_ERROR([DocBook XSL Stylesheets are required for --enable-man]) 137 ]) 138 enable_man=no 139 ]) 140]) 141 142AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no) 143 144AC_MSG_CHECKING([whether to generate man pages]) 145AS_IF([ test "$enable_man" != no ], [ 146 enable_man=yes 147 AC_MSG_RESULT([yes]) 148], [ 149 AC_MSG_RESULT([no]) 150]) 151 152dnl --- Specific checks --- 153 154AC_CHECK_FUNCS(mmap) 155 156dnl 157dnl Check for -Bsymbolic-functions linker flag used to avoid 158dnl intra-library PLT jumps, if available. 159dnl 160 161AC_ARG_ENABLE(Bsymbolic, 162 [AS_HELP_STRING([--disable-Bsymbolic], 163 [avoid linking with -Bsymbolic])],, 164 [SAVED_LDFLAGS="${LDFLAGS}" SAVED_LIBS="${LIBS}" 165 AC_MSG_CHECKING([for -Bsymbolic linker flag]) 166 LDFLAGS=-Wl,-Bsymbolic 167 LIBS= 168 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return 0]])],[AC_MSG_RESULT(yes) 169 enable_Bsymbolic=yes],[AC_MSG_RESULT(no) 170 enable_Bsymbolic=no]) 171 LDFLAGS="${SAVED_LDFLAGS}" LIBS="${SAVED_LIBS}"]) 172 173if test "x${enable_Bsymbolic}" = "xyes"; then 174 CHAFA_BDYNAMIC_FLAGS=-Wl,-Bsymbolic 175fi 176 177dnl 178dnl Check for runtime gcc x86 instruction set detection. Used in 'chafa-features.c'. 179dnl 180 181AC_CACHE_CHECK([for gcc __builtin_cpu_init function], 182 [ax_cv_gcc_check_x86_cpu_init], 183 [AC_LINK_IFELSE( 184 [AC_LANG_PROGRAM([#include <stdlib.h>], 185 [__builtin_cpu_init ();])], 186 [ax_cv_gcc_check_x86_cpu_init=yes], 187 [ax_cv_gcc_check_x86_cpu_init=no])]) 188 189AC_CACHE_CHECK([for gcc __builtin_cpu_supports function], 190 [ax_cv_gcc_check_x86_cpu_supports], 191 [AC_LINK_IFELSE( 192 [AC_LANG_PROGRAM([#include <stdlib.h>], 193 [__builtin_cpu_supports ("mmx");])], 194 [ax_cv_gcc_check_x86_cpu_supports=yes], 195 [ax_cv_gcc_check_x86_cpu_supports=no])]) 196 197dnl AM_CONDITIONAL([HAVE_GCC_X86_FEATURE_BUILTINS], [test "$ac_cv_gcc_check_x86_cpu_init" = "yes" && test "$ac_cv_gcc_check_x86_cpu_supports" = "yes"]) 198AS_IF([test "$ax_cv_gcc_check_x86_cpu_init" = "yes" && test "$ax_cv_gcc_check_x86_cpu_supports" = "yes"], [ 199 AC_DEFINE([HAVE_GCC_X86_FEATURE_BUILTINS], [1], [Define if gcc x86 feature builtins work.]) 200]) 201 202dnl Check for working MMX intrinsics 203AC_MSG_CHECKING(for working MMX intrinsics) 204SAVED_CFLAGS="${CFLAGS}" 205CFLAGS="${CFLAGS} -mmmx" 206AC_LINK_IFELSE( 207 [AC_LANG_PROGRAM( 208 [[#include <mmintrin.h>]], 209 [[_mm_empty ();]])], 210 [AC_DEFINE([HAVE_MMX_INTRINSICS], [1], [Define if MMX intrinsics work.]) 211 ac_cv_mmx_intrinsics=yes], 212 [ac_cv_mmx_intrinsics=no]) 213CFLAGS="${SAVED_CFLAGS}" 214AC_MSG_RESULT(${ac_cv_mmx_intrinsics}) 215AM_CONDITIONAL([HAVE_MMX_INTRINSICS], [test "$ac_cv_mmx_intrinsics" = "yes"]) 216 217dnl Check for working SSE intrinsics 218AC_MSG_CHECKING(for working SSE 4.1 intrinsics) 219SAVED_CFLAGS="${CFLAGS}" 220CFLAGS="${CFLAGS} -msse4.1" 221AC_LINK_IFELSE( 222 [AC_LANG_PROGRAM( 223 [[#include <smmintrin.h>]], 224 [[__m128i t = { 0 }; int r = _mm_test_all_ones (t);]])], 225 [AC_DEFINE([HAVE_SSE41_INTRINSICS], [1], [Define if SSE 4.1 intrinsics work.]) 226 ac_cv_sse41_intrinsics=yes], 227 [ac_cv_sse41_intrinsics=no]) 228CFLAGS="${SAVED_CFLAGS}" 229AC_MSG_RESULT(${ac_cv_sse41_intrinsics}) 230AM_CONDITIONAL([HAVE_SSE41_INTRINSICS], [test "$ac_cv_sse41_intrinsics" = "yes"]) 231 232dnl Check for working AVX2 intrinsics 233AC_MSG_CHECKING(for working AVX2 intrinsics) 234SAVED_CFLAGS="${CFLAGS}" 235CFLAGS="${CFLAGS} -mavx2" 236AC_LINK_IFELSE( 237 [AC_LANG_PROGRAM( 238 [[#include <immintrin.h>]], 239 [[__m256i t = { 0 }; __m256i r = _mm256_abs_epi32 (t);]])], 240 [AC_DEFINE([HAVE_AVX2_INTRINSICS], [1], [Define if AVX2 intrinsics work.]) 241 ac_cv_avx2_intrinsics=yes], 242 [ac_cv_avx2_intrinsics=no]) 243CFLAGS="${SAVED_CFLAGS}" 244AC_MSG_RESULT(${ac_cv_avx2_intrinsics}) 245AM_CONDITIONAL([HAVE_AVX2_INTRINSICS], [test "$ac_cv_avx2_intrinsics" = "yes"]) 246 247dnl Check for working 64bit popcnt intrinsics 248AC_MSG_CHECKING(for working 64bit popcnt intrinsics) 249SAVED_CFLAGS="${CFLAGS}" 250CFLAGS="${CFLAGS} -mpopcnt" 251AC_LINK_IFELSE( 252 [AC_LANG_PROGRAM( 253 [[#include <stdint.h> 254 #include <nmmintrin.h>]], 255 [[uint64_t t = 0; t = _mm_popcnt_u64 (t);]])], 256 [AC_DEFINE([HAVE_POPCNT64_INTRINSICS], [1], [Define if 64bit popcnt intrinsics work.]) 257 ac_cv_popcnt64_intrinsics=yes], 258 [ac_cv_popcnt64_intrinsics=no]) 259CFLAGS="${SAVED_CFLAGS}" 260AC_MSG_RESULT(${ac_cv_popcnt64_intrinsics}) 261 262dnl Check for working 32bit popcnt intrinsics 263AC_MSG_CHECKING(for working 32bit popcnt intrinsics) 264SAVED_CFLAGS="${CFLAGS}" 265CFLAGS="${CFLAGS} -mpopcnt" 266AC_LINK_IFELSE( 267 [AC_LANG_PROGRAM( 268 [[#include <stdint.h> 269 #include <nmmintrin.h>]], 270 [[uint32_t t = 0; t = _mm_popcnt_u32 (t);]])], 271 [AC_DEFINE([HAVE_POPCNT32_INTRINSICS], [1], [Define if 32bit popcnt intrinsics work.]) 272 ac_cv_popcnt32_intrinsics=yes], 273 [ac_cv_popcnt32_intrinsics=no]) 274CFLAGS="${SAVED_CFLAGS}" 275AC_MSG_RESULT(${ac_cv_popcnt32_intrinsics}) 276 277AM_CONDITIONAL([HAVE_POPCNT_INTRINSICS], 278 [test "$ac_cv_popcnt64_intrinsics" = "yes" -o "$ac_cv_popcnt32_intrinsics" = "yes"]) 279 280dnl 281dnl Check for -fvisibility=hidden to determine if we can do GNU-style 282dnl visibility attributes for symbol export control 283dnl 284CHAFA_VISIBILITY_CFLAGS="" 285case "$host" in 286 *-*-mingw*) 287 dnl On mingw32 we do -fvisibility=hidden and __declspec(dllexport) 288 AC_DEFINE([_CHAFA_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern], 289 [Defines how to decorate public symbols while building]) 290 CFLAGS="${CFLAGS} -fvisibility=hidden" 291 ;; 292 *) 293 dnl On other compilers, check if we can do -fvisibility=hidden 294 SAVED_CFLAGS="${CFLAGS}" 295 CFLAGS="-fvisibility=hidden" 296 AC_MSG_CHECKING([for -fvisibility=hidden compiler flag]) 297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0]])],[AC_MSG_RESULT(yes) 298 enable_fvisibility_hidden=yes],[AC_MSG_RESULT(no) 299 enable_fvisibility_hidden=no]) 300 CFLAGS="${SAVED_CFLAGS}" 301 302 AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [ 303 AC_DEFINE([_CHAFA_EXTERN], [__attribute__((visibility("default"))) extern], 304 [defines how to decorate public symbols while building]) 305 CHAFA_VISIBILITY_CFLAGS="-fvisibility=hidden" 306 ]) 307 ;; 308esac 309 310dnl 311dnl We're not picky about floating point behavior, and this makes e.g. 312dnl lrintf() a lot faster. 313dnl 314AX_CHECK_COMPILE_FLAG([-ffast-math], 315 [BASE_CFLAGS="$BASE_CFLAGS -ffast-math"], 316 , 317 [-Werror]) 318 319dnl --- ImageMagick checks --- 320 321dnl ImageMagick 6 needs #include <wand/MagickWand.h> 322dnl ImageMagick 7 needs #include <MagickWand/MagickWand.h> 323 324SAVED_CPPFLAGS=$CPPFLAGS 325CPPFLAGS="$CFLAGS $MAGICKWAND_CFLAGS" 326AC_CHECK_HEADERS([wand/MagickWand.h]) 327AC_CHECK_HEADERS([MagickWand/MagickWand.h]) 328CPPFLAGS=$SAVED_CPPFLAGS 329 330AC_MSG_CHECKING(for 4-arg MagickResizeImage) 331SAVED_CFLAGS=$CFLAGS 332CFLAGS="$CFLAGS $MAGICKWAND_CFLAGS" 333SAVED_LDFLAGS=$LDFLAGS 334LDFLAGS="$MAGICKWAND_LIBS $LDFLAGS" 335AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 336#ifdef HAVE_WAND_MAGICKWAND_H 337# include <wand/MagickWand.h> 338#else 339# include <MagickWand/MagickWand.h> 340#endif 341]], [[MagickResizeImage (0, 0, 0, 0);]])], 342 AC_DEFINE([HAVE_MAGICK_RESIZE_IMAGE_4], [1], [Define if MagickResizeImage takes 4 arguments.]) 343 AC_MSG_RESULT(yes), 344 AC_MSG_RESULT(no)) 345CFLAGS=$SAVED_CFLAGS 346LDFLAGS=$SAVED_LDFLAGS 347 348AC_MSG_CHECKING(for 5-arg MagickResizeImage) 349SAVED_CFLAGS=$CFLAGS 350CFLAGS="$CFLAGS $MAGICKWAND_CFLAGS" 351SAVED_LDFLAGS=$LDFLAGS 352LDFLAGS="$MAGICKWAND_LIBS $LDFLAGS" 353AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 354#ifdef HAVE_WAND_MAGICKWAND_H 355# include <wand/MagickWand.h> 356#else 357# include <MagickWand/MagickWand.h> 358#endif 359]], [[MagickResizeImage (0, 0, 0, 0, 1.0);]])], 360 AC_DEFINE([HAVE_MAGICK_RESIZE_IMAGE_5], [1], [Define if MagickResizeImage takes 5 arguments.]) 361 AC_MSG_RESULT(yes), 362 AC_MSG_RESULT(no)) 363CFLAGS=$SAVED_CFLAGS 364LDFLAGS=$SAVED_LDFLAGS 365 366AC_MSG_CHECKING(for MagickAutoOrientImage) 367SAVED_CFLAGS=$CFLAGS 368CFLAGS="$CFLAGS $MAGICKWAND_CFLAGS" 369SAVED_LDFLAGS=$LDFLAGS 370LDFLAGS="$MAGICKWAND_LIBS $LDFLAGS" 371AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 372#ifdef HAVE_WAND_MAGICKWAND_H 373# include <wand/MagickWand.h> 374#else 375# include <MagickWand/MagickWand.h> 376#endif 377]], [[MagickAutoOrientImage (0);]])], 378 AC_DEFINE([HAVE_MAGICK_AUTO_ORIENT_IMAGE], [1], [Define if we have MagickAutoOrientImage.]) 379 AC_MSG_RESULT(yes), 380 AC_MSG_RESULT(no)) 381CFLAGS=$SAVED_CFLAGS 382LDFLAGS=$SAVED_LDFLAGS 383 384dnl --- Set compiler flags --- 385 386LIBCHAFA_CFLAGS="$BASE_CFLAGS $CHAFA_VISIBILITY_CFLAGS" 387LIBCHAFA_LDFLAGS="$CHAFA_BDYNAMIC_FLAGS" 388 389CHAFA_CFLAGS="$BASE_CFLAGS $CHAFA_VISIBILITY_CFLAGS" 390CHAFA_LDFLAGS="$CHAFA_BDYNAMIC_FLAGS" 391 392AC_SUBST(LIBCHAFA_CFLAGS) 393AC_SUBST(LIBCHAFA_LDFLAGS) 394 395AC_SUBST(CHAFA_CFLAGS) 396AC_SUBST(CHAFA_LDFLAGS) 397 398AC_ARG_ENABLE(rpath, 399 [AS_HELP_STRING([--enable-rpath], 400 [use rpath [default=no]])]) 401 402AM_CONDITIONAL(ENABLE_RPATH, test "$enable_rpath" == yes) 403 404dnl --- Output --- 405 406AC_CONFIG_FILES([Makefile 407 chafa/Makefile 408 chafa/chafaconfig.h 409 chafa/internal/Makefile 410 chafa/internal/smolscale/Makefile 411 libnsgif/Makefile 412 chafa.pc 413 docs/Makefile 414 docs/version.xml 415 tests/Makefile 416 tools/Makefile 417 tools/chafa/Makefile 418 tools/fontgen/Makefile]) 419AC_OUTPUT 420 421echo >&AS_MESSAGE_FD 422echo >&AS_MESSAGE_FD "Build command-line tool ..... $with_tools" 423echo >&AS_MESSAGE_FD "Build man page .............. $enable_man" 424echo >&AS_MESSAGE_FD "Rebuild API documentation ... ${enable_gtk_doc:-no} (--enable-gtk-doc)" 425echo >&AS_MESSAGE_FD "Support MMX ................. $ac_cv_mmx_intrinsics" 426echo >&AS_MESSAGE_FD "Support SSE 4.1 ............. $ac_cv_sse41_intrinsics" 427echo >&AS_MESSAGE_FD "Support AVX2 ................ $ac_cv_avx2_intrinsics" 428echo >&AS_MESSAGE_FD "Support popcount32 .......... $ac_cv_popcnt32_intrinsics" 429echo >&AS_MESSAGE_FD "Support popcount64 .......... $ac_cv_popcnt64_intrinsics" 430echo >&AS_MESSAGE_FD "Install prefix .............. $prefix" 431echo >&AS_MESSAGE_FD 432echo >&AS_MESSAGE_FD "You can now type \"gmake\" or \"make\" to build the project." 433