AC_INIT([libpsl], [0.21.0], [tim.ruehsen@gmx.de], [libpsl], [https://github.com/rockdaboot/libpsl]) AC_PREREQ([2.59]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([1.10 no-define foreign dist-lzip]) # Generate two configuration headers; one for building the library itself with # an autogenerated template, and a second one that will be installed alongside # the library. AC_CONFIG_HEADERS([config.h]) AC_PROG_CC m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) #LT_INIT([disable-static]) LT_INIT([win32-dll]) AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl Check that compiler understands inline AC_C_INLINE dnl Check for visibility support gl_VISIBILITY # # Generate version defines for include file # AC_SUBST([LIBPSL_VERSION_MAJOR], [`echo $VERSION|cut -d'.' -f1`]) AC_SUBST([LIBPSL_VERSION_MINOR], [`echo $VERSION|cut -d'.' -f2`]) AC_SUBST([LIBPSL_VERSION_PATCH], [`echo $VERSION|cut -d'.' -f3`]) AC_SUBST([LIBPSL_VERSION_NUMBER], [`printf '0x%02x%02x%02x' $LIBPSL_VERSION_MAJOR $LIBPSL_VERSION_MINOR $LIBPSL_VERSION_PATCH`]) AC_CONFIG_FILES([include/libpsl.h]) # # Gettext # AM_GNU_GETTEXT([external],[need-ngettext]) AM_GNU_GETTEXT_VERSION([0.18.1]) # # check for gtk-doc # m4_ifdef([GTK_DOC_CHECK], [ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ],[ AM_CONDITIONAL([ENABLE_GTK_DOC], false) ]) # needed for some older versions of gtk-doc m4_ifdef([GTK_DOC_USE_LIBTOOL], [], [ AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], false) ]) if test x"$have_gtk_doc" = xyes -a x"$enable_gtk_doc" = xyes; then AC_SUBST([LIBPSL_DOCS], [docs/libpsl]) fi # # enable creation of man pages # AC_ARG_ENABLE([man], [AC_HELP_STRING([--enable-man], [generate man pages [default=auto]])], [ if test "$enable_man" = yes; then AC_PATH_PROG([XSLTPROC], [xsltproc]) AS_IF([test -z "$XSLTPROC"], [ AC_MSG_ERROR([xsltproc is required for --enable-man]) enable_man="no (xsltproc not found)" ]) fi ], [ enable_man=no ]) AM_CONDITIONAL(ENABLE_MAN, test x$enable_man = xyes) # src/psl-make-dafsa needs python 2.7+ AM_PATH_PYTHON([2.7]) PKG_PROG_PKG_CONFIG AC_ARG_ENABLE([cfi], [AS_HELP_STRING([--enable-cfi], [Turn on clang's Control Flow Integrity (CFI)])], [ if test "$enable_cfi" = yes; then CFLAGS=$CFLAGS" -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all" AC_LINK_IFELSE([ AC_LANG_PROGRAM([], []) ], [], [ AC_MSG_ERROR([clang 3.7+ and the 'gold' linker are required for --enable-cfi]) ]) fi ], [ enable_cfi=no ]) AC_ARG_ENABLE([ubsan], [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])], [ if test "$enable_ubsan" = yes; then CFLAGS=$CFLAGS" -fsanitize=undefined -fno-sanitize-recover=undefined" fi ], [ enable_ubsan=no ]) AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])], [ if test "$enable_asan" = yes; then CFLAGS=$CFLAGS" -fsanitize=address -fno-omit-frame-pointer" AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"]) fi ], [ enable_asan=no ]) # Define these substitutions here to keep all version information in one place. # For information on how to properly maintain the library version information, # refer to the libtool manual, section "Updating library version information": # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html # # 1. Start with version information of ‘0:0:0’ for each libtool library. # 2. Update the version information only immediately before a public release of your software. More frequent updates are unnecessary, and only guarantee that the current interface number gets larger faster. # 3. If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’). # 4. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. # 5. If any interfaces have been added since the last public release, then increment age. # 6. If any existing interfaces have been removed or changed since the last public release, then set age to 0. AC_SUBST([LIBPSL_SO_VERSION], [8:2:3]) AC_SUBST([LIBPSL_VERSION], $VERSION) # Check for enable/disable runtime PSL data AC_ARG_ENABLE(runtime, [ --enable-runtime[[=IDNA library]] Specify the IDNA library used for libpsl run-time conversions: libidn2 [[default]]: IDNA2008 library (also needs libunistring) libicu: IDNA2008 UTS#46 library libidn: IDNA2003 library (also needs libunistring) --disable-runtime Do not link runtime IDNA functionality ], [ if test "$enableval" = "libidn2" -o "$enableval" = "yes"; then enable_runtime=libidn2 AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2]) elif test "$enableval" = "libicu"; then enable_runtime=libicu AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) elif test "$enableval" = "libidn"; then enable_runtime=libidn AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn]) elif test "$enableval" = "no"; then enable_runtime=no else AC_MSG_ERROR([Unknown value $enableval for --enable-runtime]) fi ], [ # this is the default if neither --enable-runtime nor --disable-runtime were specified enable_runtime=auto ]) # Check for enable/disable builtin PSL data AC_ARG_ENABLE(builtin, [ --enable-builtin[[=IDNA library]] Specify the IDNA library used for built-in data generation: libidn2 [[default]]: IDNA2008 library (also needs libunistring) libicu: IDNA2008 UTS#46 library libidn: IDNA2003 library (also needs libunistring) --disable-builtin Do not generate built-in PSL data ], [ if test "$enableval" = "libidn2" -o "$enableval" = "yes"; then enable_builtin=libidn2 AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2]) elif test "$enableval" = "libicu"; then enable_builtin=libicu AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu]) elif test "$enableval" = "libidn"; then enable_builtin=libidn AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn]) elif test "$enableval" = "no"; then enable_builtin=no else AC_MSG_ERROR(Unknown value $enableval) fi ], [ # this is the default if neither --enable-builtin nor --disable-builtin were specified enable_builtin=auto ]) if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then # Check for libidn2 PKG_CHECK_MODULES([LIBIDN2], [libidn2], [ HAVE_LIBIDN2=yes if test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "auto"; then LIBS="$LIBIDN2_LIBS $LIBS" CFLAGS="$LIBIDN2_CFLAGS $CFLAGS" fi ], [ AC_SEARCH_LIBS(idn2_lookup_u8, idn2, HAVE_LIBIDN2=yes, [ if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2"; then AC_MSG_ERROR(You requested libidn2 but it is not installed.) fi ], -lunistring) ]) if test "x$HAVE_LIBIDN2" = "xyes"; then if test "$enable_runtime" = "auto"; then enable_runtime=libidn2 AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2]) fi if test "$enable_builtin" = "auto"; then enable_builtin=libidn2 AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2]) fi fi fi if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then # Check for libicu # using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit # using AC_SEARCH_LIBS also don't work since functions have the library version appended PKG_CHECK_MODULES([LIBICU], [icu-uc], [ HAVE_LIBICU=yes if test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"; then LIBS="$LIBICU_LIBS $LIBS" CFLAGS="$LIBICU_CFLAGS $CFLAGS" fi ], [ OLDLIBS=$LIBS LIBS="-licuuc $LIBS" AC_MSG_CHECKING([for ICU unicode library]) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include ]], [[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]])], [HAVE_LIBICU=yes; LIBICU_LIBS="-licuuc"; AC_MSG_RESULT([yes])], [ AC_MSG_RESULT([no]); if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu"; then AC_MSG_ERROR(You requested libicu but it is not installed.) fi LIBS=$OLDLIBS ]) ]) if test "x$HAVE_LIBICU" = "xyes"; then if test "$enable_runtime" = "auto"; then enable_runtime=libicu AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) fi if test "$enable_builtin" = "auto"; then enable_builtin=libicu AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu]) fi fi fi if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then # Check for libidn PKG_CHECK_MODULES([LIBIDN], [libidn], [ HAVE_LIBIDN=yes if test "$enable_runtime" = "libidn" -o "$enable_runtime" = "auto"; then LIBS="$LIBIDN_LIBS $LIBS" CFLAGS="$LIBIDN_CFLAGS $CFLAGS" fi ], [ AC_SEARCH_LIBS(idna_to_ascii_8z, idn, HAVE_LIBIDN=yes, [ if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn"; then AC_MSG_ERROR(You requested libidn but it is not installed.) fi ]) ]) if test "x$HAVE_LIBIDN" = "xyes"; then if test "$enable_runtime" = "auto"; then enable_runtime=libidn AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn]) fi if test "$enable_builtin" = "auto"; then enable_builtin=libidn AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn]) fi fi fi # last fallback is noruntime/nobuiltin if test "$enable_runtime" = "auto"; then enable_runtime=no fi if test "$enable_builtin" = "auto"; then enable_builtin=no fi if test "x$HAVE_LIBIDN2" = "xyes" -o "x$HAVE_LIBIDN" = "xyes"; then # Check for libunistring, we need it for psl_str_to_utf8lower() AC_SEARCH_LIBS(u8_tolower, unistring, HAVE_UNISTRING=yes, AC_MSG_ERROR(You requested libidn2|libidn but libunistring is not installed.)) fi # AM_ICONV sets @LIBICONV@ and @LTLIBICONV@ for use in Makefile.am # do not use AM_ICONV conditionally AM_ICONV AM_CONDITIONAL([WITH_LIBICU], test "x$enable_runtime" = "xlibicu") AM_CONDITIONAL([WITH_LIBIDN2], test "x$enable_runtime" = "xlibidn2") AM_CONDITIONAL([WITH_LIBIDN], test "x$enable_runtime" = "xlibidn") AM_CONDITIONAL([BUILTIN_GENERATOR_LIBICU], test "x$enable_builtin" = "xlibicu") AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN2], test "x$enable_builtin" = "xlibidn2") AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN], test "x$enable_builtin" = "xlibidn") AM_CONDITIONAL([WITH_BUILTIN], test $enable_builtin = yes) # Solaris has socket in libsocket and inet_ntop in libnsl, but also needs libsocket, so the order is important here AC_CHECK_LIB([socket], [socket], [NEEDS_SOCKET=yes], []) if test -n "$NEEDS_SOCKET" ; then AC_CHECK_LIB([nsl], [inet_ntop], [NEEDS_NSL=yes], []) fi if test -n "$NEEDS_SOCKET" && test -n "$NEEDS_NSL" ; then LIBS="$LIBS -lsocket -lnsl" elif test -n "$NEEDS_SOCKET" ; then LIBS="$LIBS -lsocket" elif test -n "$NEEDS_NSL" ; then LIBS="$LIBS -lnsl" else # Platform dependant options case "${host_os}" in # MinGW / Windows *mingw*) # Select Windows NT/2000 and later, for WSAStringToAddressW() CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x500" # Needed for network support LIBS="$LIBS -lws2_32" ;; *) ;; esac fi # Check for clock_gettime() used for performance measurement AC_SEARCH_LIBS(clock_gettime, rt) # Check for valgrind ac_enable_valgrind=no AC_ARG_ENABLE(valgrind-tests, AS_HELP_STRING([--enable-valgrind-tests], [enable using Valgrind for tests]), [ac_enable_valgrind=$enableval], [ac_enable_valgrind=no]) if test "${ac_enable_valgrind}" = "yes" ; then AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) if test "$HAVE_VALGRIND" = "yes" ; then VALGRIND_ENVIRONMENT="valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-origins=yes" AC_SUBST(VALGRIND_ENVIRONMENT) TESTS_INFO="Test suite will be run under Valgrind" else TESTS_INFO="Valgrind not found" fi else TESTS_INFO="Valgrind testing not enabled" fi # Check for distribution-wide PSL file AC_ARG_WITH(psl-distfile, AC_HELP_STRING([--with-psl-distfile=[PATH]], [path to distribution-wide PSL file]), PSL_DISTFILE=$withval AC_SUBST(PSL_DISTFILE)) # Check for custom PSL file AC_ARG_WITH(psl-file, AC_HELP_STRING([--with-psl-file=[PATH]], [path to PSL file]), PSL_FILE=$withval, PSL_FILE="\$(top_srcdir)/list/public_suffix_list.dat") AC_SUBST(PSL_FILE) # Check for custom PSL test file AC_ARG_WITH(psl-testfile, AC_HELP_STRING([--with-psl-testfile=[PATH]], [path to PSL test file]), PSL_TESTFILE=$withval, PSL_TESTFILE="\$(top_srcdir)/list/tests/tests.txt") AC_SUBST(PSL_TESTFILE) # check for alloca / alloca.h AC_FUNC_ALLOCA AC_CHECK_FUNCS([strndup clock_gettime fmemopen nl_langinfo]) # check for dirent.h AC_HEADER_DIRENT # strings.h may not exist on WIN32 AC_CHECK_HEADERS([strings.h]) # Override the template file name of the generated .pc file, so that there # is no need to rename the template file when the API version changes. AC_CONFIG_FILES([Makefile include/Makefile src/Makefile tools/Makefile po/Makefile.in fuzz/Makefile tests/Makefile docs/libpsl/Makefile docs/libpsl/version.xml libpsl.pc:libpsl.pc.in meson.build msvc/Makefile msvc/config.h.win32 msvc/config-msvc.mak]) AC_OUTPUT AC_MSG_NOTICE([Summary of build options: Version: ${PACKAGE_VERSION} Host OS: ${host_os} Install prefix: ${prefix} Compiler: ${CC} CFlags: ${CFLAGS} ${CPPFLAGS} LDFlags: ${LDFLAGS} Libs: ${LIBS} Runtime: ${enable_runtime} Builtin: ${enable_builtin} PSL Dist File: ${PSL_DISTFILE} PSL File: ${PSL_FILE} PSL Test File: ${PSL_TESTFILE} Sanitizers: UBSan $enable_ubsan, ASan $enable_asan, CFI $enable_cfi Docs: $enable_gtk_doc Man pages: $enable_man Tests: ${TESTS_INFO} ])