forked from openslide/openslide
-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure.ac
263 lines (235 loc) · 7.9 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.69)
AC_INIT([OpenSlide], [3.4.1], [[email protected]], [openslide], [https://openslide.org])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign subdir-objects 1.11.1 dist-xz])
AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
# Check for cross build
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# Checks for programs.
AM_PROG_CC_C_O
AC_PROG_CC_CC
# Largefile
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
LT_PREREQ([2.2.5])
LT_INIT([win32-dll disable-static])
LT_LANG([Windows Resource])
# Windows resources and manifest
AM_CONDITIONAL([WINDOWS_RESOURCES], [test $host_os = mingw32])
WINDOWS_VERSIONINFO=$(echo "${VERSION}.0.0.0" | cut -f1-4 -d. | tr . ,)
AC_SUBST([WINDOWS_VERSIONINFO])
# Suffix appended to version string
AC_ARG_WITH([version-suffix],
AS_HELP_STRING([--with-version-suffix=STRING],
[suffix to append to the package version string]))
AC_MSG_CHECKING([version string])
if test "x$with_version_suffix" != "x"; then
SUFFIXED_VERSION="$VERSION-$with_version_suffix"
else
SUFFIXED_VERSION="$VERSION"
fi
AC_MSG_RESULT([$SUFFIXED_VERSION])
AC_DEFINE_UNQUOTED([SUFFIXED_VERSION], ["$SUFFIXED_VERSION"],
[Define to the package version string including any suffix.])
AC_SUBST([SUFFIXED_VERSION])
# libraries
AC_SEARCH_LIBS([floor], [m],, AC_MSG_FAILURE([cannot find math library]))
PKG_CHECK_MODULES(ZLIB, [zlib], [], [
dnl for BSD
AC_SEARCH_LIBS([inflate], [z],, AC_MSG_FAILURE([cannot find zlib]))
])
PKG_CHECK_MODULES(LIBJPEG, [libjpeg], [], [
dnl IJG libjpeg, or libjpeg-turbo < 1.5.0
AC_SEARCH_LIBS([jpeg_CreateDecompress], [jpeg],,
AC_MSG_FAILURE([cannot find libjpeg]))
])
PKG_CHECK_MODULES(OPENJPEG2, [libopenjp2 >= 2.1.0], [
AC_DEFINE([HAVE_OPENJPEG2], [1], [Define to 1 if you have OpenJPEG >= 2.1.0.])
OPENJPEG_CFLAGS="$OPENJPEG2_CFLAGS"
OPENJPEG_LIBS="$OPENJPEG2_LIBS"
FEATURE_FLAGS="$FEATURE_FLAGS openjpeg-2"
], [
dnl Fall back to OpenJPEG 1.x
PKG_CHECK_MODULES(OPENJPEG, [libopenjpeg1], [], [
dnl OpenJPEG < 1.4 has no pkg-config file
AC_MSG_CHECKING([for OpenJPEG (fallback)])
dnl AC_CHECK_LIB won't work with the Win32 version of openjpeg
dnl because of the stdcall calling convention which requires
dnl configure to read openjpeg.h.
old_LIBS="$LIBS"
LIBS="-lopenjpeg $LIBS"
AC_LINK_IFELSE(
[AC_LANG_SOURCE(
[[
#include <openjpeg.h>
int
main ()
{
const char *ver = opj_version();
return 0;
}
]])],
openjpeg_ok=yes,
openjpeg_ok=no)
LIBS="$old_LIBS"
if test "$openjpeg_ok" = yes; then
OPENJPEG_LIBS="-lopenjpeg"
AC_MSG_RESULT($openjpeg_ok)
else
AC_MSG_FAILURE([cannot find OpenJPEG])
fi
])
FEATURE_FLAGS="$FEATURE_FLAGS openjpeg-1"
])
PKG_CHECK_MODULES(LIBTIFF, [libtiff-4], [], [
dnl libtiff < 4 has no pkg-config file
old_LIBS="$LIBS"
AC_SEARCH_LIBS([TIFFOpen], [tiff],, AC_MSG_FAILURE([cannot find libtiff]))
LIBS="$old_LIBS"
LIBTIFF_LIBS="-ltiff"
])
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $LIBTIFF_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <tiff.h>
int ver = TIFF_VERSION_BIG;
])], [
FEATURE_FLAGS="$FEATURE_FLAGS libtiff-4"
], [
FEATURE_FLAGS="$FEATURE_FLAGS libtiff-3"
])
CFLAGS="$old_CFLAGS"
PKG_CHECK_MODULES(GLIB2, [glib-2.0 >= 2.16, gthread-2.0, gio-2.0, gobject-2.0])
PKG_CHECK_MODULES(CAIRO, [cairo >= 1.2])
PKG_CHECK_MODULES(LIBPNG, [libpng > 1.2])
PKG_CHECK_MODULES(GDKPIXBUF, [gdk-pixbuf-2.0 >= 2.14])
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0])
PKG_CHECK_MODULES(SQLITE3, [sqlite3 >= 3.6.20])
# optional
PKG_CHECK_MODULES(VALGRIND, [valgrind], [
AC_DEFINE([HAVE_VALGRIND], [1], [Define to 1 if you have the Valgrind headers.])
], [:])
gl_VISIBILITY
# CLOEXEC
AC_MSG_CHECKING([fopen() close-on-exec flag])
AS_CASE([$host_os],
[mingw32], [
# Assume that if we're building for Windows, we want to pass N to fopen().
AC_MSG_RESULT([N])
AC_DEFINE([FOPEN_CLOEXEC_FLAG], ["N"], [Set to the fopen() flag string that sets FD_CLOEXEC, or an empty string if not supported.])
],
[
# Default
AC_RUN_IFELSE([
AC_LANG_PROGRAM([
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
], [
FILE *fp = fopen("/dev/null", "re");
if (fp != NULL) {
int fd = fileno(fp);
if (fd != -1) {
long ret = fcntl(fd, F_GETFD);
if (ret != -1 && (ret & FD_CLOEXEC)) {
return 0;
}
}
}
return 1;
])
], [
# glibc >= 2.7, FreeBSD >= 10.0, NetBSD >= 6.0
AC_MSG_RESULT([e])
AC_DEFINE([FOPEN_CLOEXEC_FLAG], ["e"])
], [
# unknown
AC_MSG_RESULT([unknown])
AC_DEFINE([FOPEN_CLOEXEC_FLAG], [""])
AC_DEFINE([NONATOMIC_CLOEXEC], [1], [Define to 1 if fopen() cannot atomically set FD_CLOEXEC.])
], [
# cross compile
AC_MSG_RESULT([unknown (cross compile)])
AC_DEFINE([FOPEN_CLOEXEC_FLAG], [""])
AC_DEFINE([NONATOMIC_CLOEXEC], [1])
])
]
)
# Fallback: racily use fcntl()
AC_CHECK_FUNCS([fcntl])
# Windows _wfopen()
AC_CHECK_FUNCS([_wfopen])
# Mac OS X proc_pidfdinfo()
AC_MSG_CHECKING([for proc_pidfdinfo])
AC_LINK_IFELSE([
AC_LANG_PROGRAM(
[#include <libproc.h>],
[proc_pidfdinfo(0, 0, PROC_PIDFDKQUEUEINFO, NULL, 0)]
)
], [
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_PROC_PIDFDINFO], [1], [Define to 1 if you have the proc_pidfdinfo function.])
], [
AC_MSG_RESULT([no])
])
# The test driver has special support for testing Windows builds from Cygwin
AC_MSG_CHECKING([whether to cross-test from Cygwin])
if test "$host_os" = "mingw32" -a "$build_os" = "cygwin"; then
AC_MSG_RESULT([yes])
CYGWIN_CROSS_TEST=yes
else
AC_MSG_RESULT([no])
CYGWIN_CROSS_TEST=""
fi
AC_SUBST([CYGWIN_CROSS_TEST])
AM_CONDITIONAL([CYGWIN_CROSS_TEST], [test -n "$CYGWIN_CROSS_TEST"])
# gcc assumes Win32 stack frames are 16-byte-aligned by default, but the
# Win32 ABI only requires 4-byte alignment. If gcc emits aligned SSE
# instructions that access the stack, this can cause GPFs if we're called by
# a program compiled by a different compiler such as MSVC. The user is
# responsible for choosing compiler options appropriate for their desired
# ABI, but this is a sufficiently insidious error that it's worth checking
# in the test suite by default. We do that by compiling the test programs
# with 4-byte stack alignment on Win32. We allow the user to disable that
# behavior, however, in case they don't care about ABI compatibility with
# other compilers.
AC_ARG_ENABLE([checking-windows-abi-compat],
AS_HELP_STRING([--disable-checking-windows-abi-compat],
[don't override default calling convention when testing on Windows]))
AS_CASE([$host],
[i*86-*-mingw32], [
AC_MSG_CHECKING([whether to test with Windows calling convention])
AS_IF([test "$enable_checking_windows_abi_compat" != "no"], [
AC_MSG_RESULT([yes])
gl_COMPILER_OPTION_IF([-mpreferred-stack-boundary=2], [
AC_SUBST([TEST_CFLAGS], [-mpreferred-stack-boundary=2])
])
], [
AC_MSG_RESULT([no])
])
]
)
# Compiler warnings
WARN_CFLAGS="-Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
AC_SUBST([WARN_CFLAGS])
# MinGW only
gl_WARN_ADD([-Wno-pedantic-ms-format])
# The min/max glib version is actually 2.16, but glib doesn't have special
# handling for API changes that old
AC_SUBST(AM_CFLAGS, ['$(WARN_CFLAGS) $(CFLAG_VISIBILITY) -DG_DISABLE_SINGLE_INCLUDES -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_MIN_REQUIRED -fno-common'])
AC_SUBST(FEATURE_FLAGS)
AC_CONFIG_FILES([
Makefile
openslide.pc
src/openslide-dll.manifest
src/openslide-dll.rc
tools/openslide-quickhash1sum.1
tools/openslide-show-properties.1
tools/openslide-write-png.1
])
AC_OUTPUT