configure.ac revision 74835918
1
2# Initialize Autoconf
3AC_PREREQ([2.60])
4AC_INIT([libXpm], [3.5.16],
5        [https://gitlab.freedesktop.org/xorg/lib/libxpm/-/issues/], [libXpm])
6AC_CONFIG_SRCDIR([Makefile.am])
7AC_CONFIG_HEADERS([config.h])
8AC_CONFIG_MACRO_DIR([m4])
9
10# Initialize Automake
11AM_INIT_AUTOMAKE([foreign dist-xz])
12
13# Initialize libtool
14LT_INIT
15
16# Require X.Org macros 1.16 or later for XORG_MEMORY_CHECK_FLAGS
17m4_ifndef([XORG_MACROS_VERSION],
18          [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
19XORG_MACROS_VERSION(1.16)
20XORG_DEFAULT_OPTIONS
21
22# Checks for library functions
23AC_CHECK_FUNCS([strlcat])
24AC_CHECK_FUNC([fork],[], AC_DEFINE(NO_ZPIPE))
25
26# Obtain compiler/linker options for dependencies
27PKG_CHECK_MODULES(XPM, xproto x11)
28PKG_CHECK_MODULES(SXPM, [x11 xt xext xextproto xproto >= 7.0.17],
29                  [build_sxpm=true], [build_sxpm=false])
30AM_CONDITIONAL(BUILD_SXPM, test x$build_sxpm = xtrue)
31
32# Internationalization & localization support
33AC_SEARCH_LIBS([gettext], [intl], [USE_GETTEXT="yes"], [USE_GETTEXT="no"])
34AC_MSG_CHECKING([where to install localized messages])
35AC_ARG_WITH([localedir], AS_HELP_STRING([--with-localedir=<path>],
36	[Path to install message files in (default: datadir/locale)]),
37	[LOCALEDIR=${withval}], [LOCALEDIR=${datadir}/locale])
38AX_DEFINE_DIR([LOCALEDIR], [LOCALEDIR], [Location of translated messages])
39if test "x$LOCALEDIR" = "xno" -o "x$USE_GETTEXT" = "xno" ; then
40	AC_MSG_RESULT([nowhere])
41	USE_GETTEXT="no"
42else
43	AC_MSG_RESULT([$LOCALEDIR])
44fi
45
46if test "x$USE_GETTEXT" = "xyes" ; then
47	AC_DEFINE([USE_GETTEXT], 1,
48		  [Define to 1 if you want to use the gettext() function.])
49fi
50AM_CONDITIONAL(USE_GETTEXT, test "x$USE_GETTEXT" = "xyes")
51
52dnl Helper macro to find absolute path to program and add a #define for it
53AC_DEFUN([XPM_PATH_PROG],[
54AC_PATH_PROG([$1], [$2], [])
55AS_IF([test "x$$1" = "x"], [$3],
56      [AC_DEFINE_UNQUOTED([$1], ["$$1"], [Path to $2])])
57]) dnl End of AC_DEFUN([XPM_PATH_PROG]...
58
59# Optional feature: When a filename ending in .Z or .gz is requested,
60# open a pipe to a newly forked compress/uncompress/gzip command to
61# handle it.
62AC_MSG_CHECKING([whether to handle compressed pixmaps])
63case $host_os in
64        *mingw*)        zpipe_default="no" ;;
65        *)              zpipe_default="yes" ;;
66esac
67AC_ARG_ENABLE(open-zfile,
68        AS_HELP_STRING([--enable-open-zfile],
69                        [Search for files with .Z & .gz extensions automatically @<:@default=auto@:>@]),
70              [OPEN_ZFILE=$enableval], [OPEN_ZFILE=yes])
71AC_MSG_RESULT([$OPEN_ZFILE])
72AM_CONDITIONAL(COMPRESSED_PIXMAPS, test "x$OPEN_ZFILE" = "xyes")
73if test x$OPEN_ZFILE = xno ; then
74        AC_DEFINE(NO_ZPIPE, 1, [Define to 1 to disable decompression via pipes])
75else
76        # gzip is absolutely required for the compressed file handling code
77        XPM_PATH_PROG([XPM_PATH_GZIP], [gzip],
78            [AC_MSG_ERROR([gzip not found, set XPM_PATH_GZIP or use --disable-open-zfile])])
79
80        # if compress is not found, we disable writing to .Z files,
81        # but leave the rest of the compression code active
82        XPM_PATH_PROG([XPM_PATH_COMPRESS], [compress],
83            [AC_MSG_WARN([compress not found, disabling writing of .Z files])])
84        # if uncompress is not found, we use gzip to read .Z files
85        XPM_PATH_PROG([XPM_PATH_UNCOMPRESS], [uncompress])
86
87        AC_CHECK_FUNCS([closefrom close_range], [break])
88fi
89
90# Optional feature: When ___.xpm is requested, also look for ___.xpm.Z & .gz
91# Replaces ZFILEDEF = -DSTAT_ZFILE in old Imakefile
92AC_MSG_CHECKING([whether to search for compressed pixmaps])
93AC_ARG_ENABLE(stat-zfile,
94        AS_HELP_STRING([--enable-stat-zfile],
95                        [Search for files with .Z & .gz extensions automatically @<:@default=auto@:>@]),
96              [STAT_ZFILE=$enableval], [STAT_ZFILE=$OPEN_ZFILE])
97AC_MSG_RESULT([$STAT_ZFILE])
98if test x$STAT_ZFILE = xyes ; then
99        AC_DEFINE(STAT_ZFILE, 1, [Define to 1 to automatically look for files with .Z & .gz extensions])
100fi
101
102# --enable-unit-tests
103AC_REQUIRE_AUX_FILE([tap-driver.sh])
104XORG_ENABLE_UNIT_TESTS
105XORG_WITH_GLIB([2.46])
106XORG_MEMORY_CHECK_FLAGS
107
108AC_CONFIG_FILES([Makefile
109                 doc/Makefile
110                 include/Makefile
111                 man/Makefile
112                 src/Makefile
113                 sxpm/Makefile
114                 cxpm/Makefile
115                 test/Makefile
116                 xpm.pc])
117AC_OUTPUT
118