• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2AC_INIT([libpsl], [0.21.1], [tim.ruehsen@gmx.de], [libpsl], [https://github.com/rockdaboot/libpsl])
3AC_PREREQ([2.59])
4AC_CONFIG_AUX_DIR([build-aux])
5AM_INIT_AUTOMAKE([1.10 no-define foreign dist-lzip])
6
7# Generate two configuration headers; one for building the library itself with
8# an autogenerated template, and a second one that will be installed alongside
9# the library.
10AC_CONFIG_HEADERS([config.h])
11AC_PROG_CC
12m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
13#LT_INIT([disable-static])
14LT_INIT([win32-dll])
15AC_CONFIG_MACRO_DIR([m4])
16m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
17
18dnl Check that compiler understands inline
19AC_C_INLINE
20
21dnl Check for visibility support
22gl_VISIBILITY
23
24#
25# Generate version defines for include file
26#
27AC_SUBST([LIBPSL_VERSION_MAJOR], [`echo $VERSION|cut -d'.' -f1`])
28AC_SUBST([LIBPSL_VERSION_MINOR], [`echo $VERSION|cut -d'.' -f2`])
29AC_SUBST([LIBPSL_VERSION_PATCH], [`echo $VERSION|cut -d'.' -f3`])
30AC_SUBST([LIBPSL_VERSION_NUMBER], [`printf '0x%02x%02x%02x' $LIBPSL_VERSION_MAJOR $LIBPSL_VERSION_MINOR $LIBPSL_VERSION_PATCH`])
31AC_CONFIG_FILES([include/libpsl.h])
32
33#
34# Gettext
35#
36AM_GNU_GETTEXT([external],[need-ngettext])
37AM_GNU_GETTEXT_VERSION([0.18.1])
38
39#
40# check for gtk-doc
41#
42m4_ifdef([GTK_DOC_CHECK], [
43GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
44],[
45AM_CONDITIONAL([ENABLE_GTK_DOC], false)
46])
47# needed for some older versions of gtk-doc
48m4_ifdef([GTK_DOC_USE_LIBTOOL], [], [
49AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], false)
50])
51
52if test x"$have_gtk_doc" = xyes -a x"$enable_gtk_doc" = xyes; then
53  AC_SUBST([LIBPSL_DOCS], [docs/libpsl])
54fi
55
56#
57# enable creation of man pages
58#
59AC_ARG_ENABLE([man],
60  [AC_HELP_STRING([--enable-man], [generate man pages [default=auto]])],
61  [
62    if test "$enable_man" = yes; then
63      AC_PATH_PROG([XSLTPROC], [xsltproc])
64      AS_IF([test -z "$XSLTPROC"], [
65        AC_MSG_ERROR([xsltproc is required for --enable-man])
66        enable_man="no (xsltproc not found)"
67      ])
68    fi
69  ], [ enable_man=no ])
70AM_CONDITIONAL(ENABLE_MAN, test x$enable_man = xyes)
71
72# src/psl-make-dafsa needs python 2.7+
73AM_PATH_PYTHON([2.7])
74
75PKG_PROG_PKG_CONFIG
76
77AC_ARG_ENABLE([cfi],
78  [AS_HELP_STRING([--enable-cfi], [Turn on clang's Control Flow Integrity (CFI)])],
79  [
80    if test "$enable_cfi" = yes; then
81      CFLAGS=$CFLAGS" -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all"
82      AC_LINK_IFELSE([
83        AC_LANG_PROGRAM([], [])
84      ], [], [
85        AC_MSG_ERROR([clang 3.7+ and the 'gold' linker are required for --enable-cfi])
86      ])
87    fi
88  ], [ enable_cfi=no ])
89
90AC_ARG_ENABLE([ubsan],
91  [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])],
92  [
93    if test "$enable_ubsan" = yes; then
94      CFLAGS=$CFLAGS" -fsanitize=undefined -fno-sanitize-recover=undefined"
95    fi
96  ], [ enable_ubsan=no ])
97
98AC_ARG_ENABLE([asan],
99  [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])],
100  [
101    if test "$enable_asan" = yes; then
102      CFLAGS=$CFLAGS" -fsanitize=address -fno-omit-frame-pointer"
103      AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"])
104    fi
105  ], [ enable_asan=no ])
106
107# Define these substitutions here to keep all version information in one place.
108# For information on how to properly maintain the library version information,
109# refer to the libtool manual, section "Updating library version information":
110# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
111#
112# 1. Start with version information of ‘0:0:0’ for each libtool library.
113# 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.
114# 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’).
115# 4. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
116# 5. If any interfaces have been added since the last public release, then increment age.
117# 6. If any existing interfaces have been removed or changed since the last public release, then set age to 0.
118AC_SUBST([LIBPSL_SO_VERSION], [8:3:3])
119AC_SUBST([LIBPSL_VERSION], $VERSION)
120
121# Check for enable/disable runtime PSL data
122AC_ARG_ENABLE(runtime,
123  [
124  --enable-runtime[[=IDNA library]]
125      Specify the IDNA library used for libpsl run-time conversions:
126        libidn2 [[default]]: IDNA2008 library (also needs libunistring)
127        libicu:            IDNA2008 UTS#46 library
128        libidn:            IDNA2003 library (also needs libunistring)
129  --disable-runtime        Do not link runtime IDNA functionality
130  ], [
131    if test "$enableval" = "libidn2" -o "$enableval" = "yes"; then
132      enable_runtime=libidn2
133      AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2])
134    elif test "$enableval" = "libicu"; then
135      enable_runtime=libicu
136      AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu])
137    elif test "$enableval" = "libidn"; then
138      enable_runtime=libidn
139      AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn])
140    elif test "$enableval" = "no"; then
141      enable_runtime=no
142    else
143      AC_MSG_ERROR([Unknown value $enableval for --enable-runtime])
144    fi
145  ], [
146    # this is the default if neither --enable-runtime nor --disable-runtime were specified
147    enable_runtime=auto
148  ])
149
150# Check for enable/disable builtin PSL data
151AC_ARG_ENABLE(builtin,
152  [
153  --enable-builtin[[=IDNA library]]
154      Specify the IDNA library used for built-in data generation:
155        libidn2 [[default]]: IDNA2008 library (also needs libunistring)
156        libicu: IDNA2008   UTS#46 library
157        libidn:            IDNA2003 library (also needs libunistring)
158  --disable-builtin        Do not generate built-in PSL data
159  ], [
160    if test "$enableval" = "libidn2" -o "$enableval" = "yes"; then
161      enable_builtin=libidn2
162      AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2])
163    elif test "$enableval" = "libicu"; then
164      enable_builtin=libicu
165      AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu])
166    elif test "$enableval" = "libidn"; then
167      enable_builtin=libidn
168      AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn])
169    elif test "$enableval" = "no"; then
170      enable_builtin=no
171    else
172      AC_MSG_ERROR(Unknown value $enableval)
173    fi
174  ], [
175    # this is the default if neither --enable-builtin nor --disable-builtin were specified
176    enable_builtin=auto
177  ])
178
179if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then
180  # Check for libidn2
181  PKG_CHECK_MODULES([LIBIDN2], [libidn2], [
182    HAVE_LIBIDN2=yes
183    if test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "auto"; then
184      LIBS="$LIBIDN2_LIBS $LIBS"
185      CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
186    fi
187  ], [
188    AC_SEARCH_LIBS(idn2_lookup_u8, idn2, HAVE_LIBIDN2=yes,
189    [
190       if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2"; then
191          AC_MSG_ERROR(You requested libidn2 but it is not installed.)
192       fi
193    ], -lunistring)
194  ])
195
196  if test "x$HAVE_LIBIDN2" = "xyes"; then
197    if test "$enable_runtime" = "auto"; then
198      enable_runtime=libidn2
199      AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2])
200    fi
201    if test "$enable_builtin" = "auto"; then
202      enable_builtin=libidn2
203      AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2])
204    fi
205  fi
206fi
207
208if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then
209  # Check for libicu
210  # using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit
211  # using AC_SEARCH_LIBS also don't work since functions have the library version appended
212  PKG_CHECK_MODULES([LIBICU], [icu-uc], [
213    HAVE_LIBICU=yes
214    if test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"; then
215      LIBS="$LIBICU_LIBS $LIBS"
216      CFLAGS="$LIBICU_CFLAGS $CFLAGS"
217    fi
218  ], [
219    OLDLIBS=$LIBS
220    LIBS="-licuuc $LIBS"
221    AC_MSG_CHECKING([for ICU unicode library])
222    AC_LINK_IFELSE(
223      [AC_LANG_PROGRAM(
224        [[#include <unicode/ustring.h>]],
225        [[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]])],
226      [HAVE_LIBICU=yes; LIBICU_LIBS="-licuuc"; AC_MSG_RESULT([yes])],
227      [ AC_MSG_RESULT([no]);
228        if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu"; then
229          AC_MSG_ERROR(You requested libicu but it is not installed.)
230        fi
231        LIBS=$OLDLIBS
232      ])
233  ])
234
235  if test "x$HAVE_LIBICU" = "xyes"; then
236    if test "$enable_runtime" = "auto"; then
237      enable_runtime=libicu
238      AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu])
239    fi
240    if test "$enable_builtin" = "auto"; then
241      enable_builtin=libicu
242      AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu])
243    fi
244  fi
245fi
246
247if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then
248  # Check for libidn
249  PKG_CHECK_MODULES([LIBIDN], [libidn], [
250    HAVE_LIBIDN=yes
251    if test "$enable_runtime" = "libidn" -o "$enable_runtime" = "auto"; then
252      LIBS="$LIBIDN_LIBS $LIBS"
253      CFLAGS="$LIBIDN_CFLAGS $CFLAGS"
254    fi
255  ], [
256    AC_SEARCH_LIBS(idna_to_ascii_8z, idn, HAVE_LIBIDN=yes,
257    [
258      if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn"; then
259        AC_MSG_ERROR(You requested libidn but it is not installed.)
260      fi
261    ])
262  ])
263
264  if test "x$HAVE_LIBIDN" = "xyes"; then
265    if test "$enable_runtime" = "auto"; then
266      enable_runtime=libidn
267      AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn])
268    fi
269    if test "$enable_builtin" = "auto"; then
270      enable_builtin=libidn
271      AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn])
272    fi
273  fi
274fi
275
276# last fallback is noruntime/nobuiltin
277if test "$enable_runtime" = "auto"; then
278  enable_runtime=no
279fi
280if test "$enable_builtin" = "auto"; then
281  enable_builtin=no
282fi
283
284if test "x$HAVE_LIBIDN2" = "xyes" -o "x$HAVE_LIBIDN" = "xyes"; then
285  # Check for libunistring, we need it for psl_str_to_utf8lower()
286  AC_SEARCH_LIBS(u8_tolower, unistring, HAVE_UNISTRING=yes, AC_MSG_ERROR(You requested libidn2|libidn but libunistring is not installed.))
287fi
288
289# AM_ICONV sets @LIBICONV@ and @LTLIBICONV@ for use in Makefile.am
290# do not use AM_ICONV conditionally
291AM_ICONV
292
293AM_CONDITIONAL([WITH_LIBICU], test "x$enable_runtime" = "xlibicu")
294AM_CONDITIONAL([WITH_LIBIDN2], test "x$enable_runtime" = "xlibidn2")
295AM_CONDITIONAL([WITH_LIBIDN], test "x$enable_runtime" = "xlibidn")
296AM_CONDITIONAL([BUILTIN_GENERATOR_LIBICU], test "x$enable_builtin" = "xlibicu")
297AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN2], test "x$enable_builtin" = "xlibidn2")
298AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN], test "x$enable_builtin" = "xlibidn")
299AM_CONDITIONAL([WITH_BUILTIN], test $enable_builtin = yes)
300
301# Solaris has socket in libsocket and inet_ntop in libnsl, but also needs libsocket, so the order is important here
302AC_CHECK_LIB([socket], [socket], [NEEDS_SOCKET=yes], [])
303if test -n "$NEEDS_SOCKET" ; then
304  AC_CHECK_LIB([nsl], [inet_ntop], [NEEDS_NSL=yes], [])
305fi
306if test -n "$NEEDS_SOCKET" && test -n "$NEEDS_NSL" ; then
307  LIBS="$LIBS -lsocket -lnsl"
308elif test -n "$NEEDS_SOCKET" ; then
309  LIBS="$LIBS -lsocket"
310elif test -n "$NEEDS_NSL" ; then
311  LIBS="$LIBS -lnsl"
312else
313  # Platform dependant options
314  case "${host_os}" in
315    # MinGW / Windows
316    *mingw*)
317      # Select Windows NT/2000 and later, for WSAStringToAddressW()
318      CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x500"
319      # Needed for network support
320      LIBS="$LIBS -lws2_32"
321      ;;
322    *)
323      ;;
324  esac
325fi
326
327# Check for clock_gettime() used for performance measurement
328AC_SEARCH_LIBS(clock_gettime, rt)
329
330# Check for valgrind
331ac_enable_valgrind=no
332AC_ARG_ENABLE(valgrind-tests,
333  AS_HELP_STRING([--enable-valgrind-tests], [enable using Valgrind for tests]),
334  [ac_enable_valgrind=$enableval],
335  [ac_enable_valgrind=no])
336
337if test "${ac_enable_valgrind}" = "yes" ; then
338  AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
339  if test "$HAVE_VALGRIND" = "yes" ; then
340    VALGRIND_ENVIRONMENT="valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-origins=yes"
341    AC_SUBST(VALGRIND_ENVIRONMENT)
342    TESTS_INFO="Test suite will be run under Valgrind"
343  else
344    TESTS_INFO="Valgrind not found"
345  fi
346else
347  TESTS_INFO="Valgrind testing not enabled"
348fi
349
350# Check for distribution-wide PSL file
351AC_ARG_WITH(psl-distfile,
352  AC_HELP_STRING([--with-psl-distfile=[PATH]], [path to distribution-wide PSL file]),
353  PSL_DISTFILE=$withval AC_SUBST(PSL_DISTFILE))
354
355# Check for custom PSL file
356AC_ARG_WITH(psl-file,
357  AC_HELP_STRING([--with-psl-file=[PATH]], [path to PSL file]),
358  PSL_FILE=$withval,
359  PSL_FILE="\$(top_srcdir)/list/public_suffix_list.dat")
360AC_SUBST(PSL_FILE)
361
362# Check for custom PSL test file
363AC_ARG_WITH(psl-testfile,
364  AC_HELP_STRING([--with-psl-testfile=[PATH]], [path to PSL test file]),
365  PSL_TESTFILE=$withval,
366  PSL_TESTFILE="\$(top_srcdir)/list/tests/tests.txt")
367AC_SUBST(PSL_TESTFILE)
368
369# check for alloca / alloca.h
370AC_FUNC_ALLOCA
371AC_CHECK_FUNCS([strndup clock_gettime fmemopen nl_langinfo])
372
373# check for dirent.h
374AC_HEADER_DIRENT
375
376# strings.h may not exist on WIN32
377AC_CHECK_HEADERS([strings.h])
378
379# Override the template file name of the generated .pc file, so that there
380# is no need to rename the template file when the API version changes.
381AC_CONFIG_FILES([Makefile
382                 include/Makefile
383                 src/Makefile
384                 tools/Makefile
385                 po/Makefile.in
386                 fuzz/Makefile
387                 tests/Makefile
388                 docs/libpsl/Makefile docs/libpsl/version.xml
389                 libpsl.pc:libpsl.pc.in
390                 meson.build
391                 msvc/Makefile
392                 msvc/config.h.win32
393                 msvc/config-msvc.mak])
394AC_OUTPUT
395
396AC_MSG_NOTICE([Summary of build options:
397
398  Version:           ${PACKAGE_VERSION}
399  Host OS:           ${host_os}
400  Install prefix:    ${prefix}
401  Compiler:          ${CC}
402  CFlags:            ${CFLAGS} ${CPPFLAGS}
403  LDFlags:           ${LDFLAGS}
404  Libs:              ${LIBS}
405  Runtime:           ${enable_runtime}
406  Builtin:           ${enable_builtin}
407  PSL Dist File:     ${PSL_DISTFILE}
408  PSL File:          ${PSL_FILE}
409  PSL Test File:     ${PSL_TESTFILE}
410  Sanitizers:        UBSan $enable_ubsan, ASan $enable_asan, CFI $enable_cfi
411  Docs:              $enable_gtk_doc
412  Man pages:         $enable_man
413  Tests:             ${TESTS_INFO}
414])
415