File: configure.ac

package info (click to toggle)
leptonlib 1.76.0-1~bpo9+1
  • links: PTS
  • area: main
  • in suites: stretch-backports
  • size: 26,468 kB
  • sloc: ansic: 186,278; sh: 4,454; makefile: 204; cpp: 61
file content (229 lines) | stat: -rw-r--r-- 7,566 bytes parent folder | download | duplicates (2)
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
AC_PREREQ([2.50])
AC_INIT([leptonica], [1.76.0])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_HEADERS([config_auto.h:config/config.h.in])
AC_CONFIG_SRCDIR([src/adaptmap.c])

AC_CONFIG_MACRO_DIR([m4])
LT_INIT

AM_INIT_AUTOMAKE
AC_LANG(C)
AC_CANONICAL_HOST

# Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_MAKE_SET

# Checks for arguments.
AC_ARG_WITH([zlib], AS_HELP_STRING([--without-zlib], [do not include zlib support]))
AC_ARG_WITH([libpng], AS_HELP_STRING([--without-libpng], [do not include libpng support]))
AC_ARG_WITH([jpeg], AS_HELP_STRING([--without-jpeg], [do not include jpeg support]))
AC_ARG_WITH([giflib], AS_HELP_STRING([--without-giflib], [do not include giflib support]))
AC_ARG_WITH([libtiff], AS_HELP_STRING([--without-libtiff], [do not include libtiff support]))
AC_ARG_WITH([libwebp], AS_HELP_STRING([--without-libwebp], [do not include libwebp support]))
AC_ARG_WITH([libopenjpeg], AS_HELP_STRING([--without-libopenjpeg], [do not include libopenjpeg support]))

AC_ARG_ENABLE([programs], AS_HELP_STRING([--disable-programs], [do not build additional programs]))
AM_CONDITIONAL([ENABLE_PROGRAMS], [test "x$enable_programs" != xno])

# Checks for libraries.
LT_LIB_M

AS_IF([test "x$with_zlib" = xno], [
  zlib_missing=untried
], [
  zlib_missing=

  PKG_CHECK_MODULES([ZLIB], [zlib], [
    AC_DEFINE([HAVE_LIBZ], 1, [Define to 1 if you have zlib.])
  ], [
    AC_CHECK_LIB([z], [deflate], [:], [zlib_missing=library])
    AC_CHECK_HEADER([zlib.h], [:], [zlib_missing=header])

    AS_IF([test "x$zlib_missing" = x], [
      AC_DEFINE([HAVE_LIBZ], 1, [Define to 1 if you have zlib.]) AC_SUBST([ZLIB_LIBS], [-lz])
    ], [
      AS_IF([test "x$with_zlib" = xyes], AC_MSG_ERROR([zlib support requested but $zlib_missing not found]))
    ])
  ])
])

AS_IF([test "x$with_libpng" = xno], [
  libpng_missing=untried
], [
  libpng_missing=

  PKG_CHECK_MODULES([LIBPNG], [libpng], [
    AC_DEFINE([HAVE_LIBPNG], 1, [Define to 1 if you have libpng.])
  ], [
    AC_CHECK_LIB([png], [png_read_png], [:], [libpng_missing=library], [$LIBM $ZLIB_LIBS])
    AC_CHECK_HEADER([png.h], [:], [libpng_missing=headers])

    AS_IF([test "x$libpng_missing" = x], [
      AC_DEFINE([HAVE_LIBPNG], 1, [Define to 1 if you have libpng.]) AC_SUBST([LIBPNG_LIBS], [-lpng])
    ], [
      AS_IF([test "x$with_libpng" = xyes], AC_MSG_ERROR([libpng support requested but $libpng_missing not found]))
    ])
  ])
])

AS_IF([test "x$with_jpeg" = xno], [
  jpeg_missing=untried
], [
  jpeg_missing=

  PKG_CHECK_MODULES([JPEG], [libjpeg], [
    AC_DEFINE([HAVE_LIBJPEG], 1, [Define to 1 if you have jpeg.])
  ], [
    AC_CHECK_LIB([jpeg], [jpeg_read_scanlines], [:], [jpeg_missing=library])
    AC_CHECK_HEADER([jpeglib.h], [:], [jpeg_missing=headers])

    AS_IF([test "x$jpeg_missing" = x], [
      AC_DEFINE([HAVE_LIBJPEG], 1, [Define to 1 if you have jpeg.]) AC_SUBST([JPEG_LIBS], [-ljpeg])
    ], [
      AS_IF([test "x$with_jpeg" = xyes], AC_MSG_ERROR([jpeg support requested but $jpeg_missing not found]))
    ])
  ])
])

AS_IF([test "x$with_giflib" = xno], [
  giflib_missing=untried
], [
  giflib_missing=

  AC_CHECK_LIB([gif], [DGifOpenFileHandle], [:], [giflib_missing=library])
  AC_CHECK_HEADER([gif_lib.h], [:], [giflib_missing=header])

  AS_IF([test "x$giflib_missing" = x], [
    AC_MSG_CHECKING([giflib is at least version 5.1 (but not 5.1.2)])
    AC_PREPROC_IFELSE([
      AC_LANG_SOURCE([[
#include <gif_lib.h>
#if !defined GIFLIB_MAJOR || GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
#error giflib version too old
#elif GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 1 && GIFLIB_RELEASE == 2
#error giflib 5.1.2 is broken
#endif
      ]])
    ], [
      AC_MSG_RESULT([yes])
      AC_DEFINE([HAVE_LIBGIF], 1, [Define to 1 if you have giflib.]) AC_SUBST([GIFLIB_LIBS], [-lgif])
    ], [
      AC_MSG_RESULT([no])
      AS_IF([test "x$with_giflib" = xyes], AC_MSG_ERROR([giflib version too old or broken]))
      giflib_missing=old
    ])
  ], [
    AS_IF([test "x$with_giflib" = xyes], AC_MSG_ERROR([giflib support requested but $giflib_missing not found]))
  ])
])

AM_CONDITIONAL([HAVE_LIBGIF], [test "x$giflib_missing" = x])

AS_IF([test "x$with_libtiff" = xno], [
  libtiff_missing=untried
], [
  libtiff_missing=

  PKG_CHECK_MODULES([LIBTIFF], [libtiff-4], [
    AC_DEFINE([HAVE_LIBTIFF], 1, [Define to 1 if you have libtiff.])
  ], [
    AC_CHECK_LIB([tiff], [TIFFOpen], [:], [libtiff_missing=library], [$LIBM $ZLIB_LIBS $JPEG_LIBS])
    AC_CHECK_HEADER([tiff.h], [:], [libtiff_missing=headers])

    AS_IF([test "x$libtiff_missing" = x], [
      AC_DEFINE([HAVE_LIBTIFF], 1, [Define to 1 if you have libtiff.]) AC_SUBST([LIBTIFF_LIBS], [-ltiff])
    ], [
      AS_IF([test "x$with_libtiff" = xyes], AC_MSG_ERROR([libtiff support requested but $libtiff_missing not found]))
    ])
  ])
])

AS_IF([test "x$with_libwebp" = xno], [
  libwebp_missing=untried
], [
  libwebp_missing=

  PKG_CHECK_MODULES([LIBWEBP], [libwebp], [
    AC_DEFINE([HAVE_LIBWEBP], 1, [Define to 1 if you have libwebp.])
  ], [
    AC_CHECK_LIB([webp], [WebPGetInfo], [:], [libwebp_missing=library], [$LIBM])
    AC_CHECK_HEADER([webp/encode.h], [:], [libwebp_missing=headers])

    AS_IF([test "x$libwebp_missing" = x], [
      AC_DEFINE([HAVE_LIBWEBP], 1, [Define to 1 if you have libwebp.]) AC_SUBST([LIBWEBP_LIBS], [-lwebp])
    ], [
      AS_IF([test "x$with_libwebp" = xyes], AC_MSG_ERROR([libwebp support requested but $libwebp_missing not found]))
    ])
  ])
])

AM_CONDITIONAL([HAVE_LIBWEBP], [test "x$libwebp_missing" = x])

AS_IF([test "x$with_libopenjpeg" = xno], [
  libopenjpeg_missing=untried
], [
  libopenjpeg_missing=

  PKG_CHECK_MODULES([LIBJP2K], [libopenjp2 >= 2.0.0], [
    AC_DEFINE([HAVE_LIBJP2K], 1, [Define to 1 if you have libopenjp2.])
  ], [
    AC_CHECK_LIB([openjp2], [opj_create_decompress], [:], [libopenjpeg_missing=library])
    AC_CHECK_HEADERS([openjpeg-2.3/openjpeg.h openjpeg-2.2/openjpeg.h openjpeg-2.1/openjpeg.h openjpeg-2.0/openjpeg.h],
      [AC_DEFINE_UNQUOTED([LIBJP2K_HEADER], [<$ac_header>], [Path to <openjpeg.h> header file.]) break],
      [libopenjpeg_missing=headers]
    )

    AS_IF([test "x$libopenjpeg_missing" = x], [
      AC_DEFINE([HAVE_LIBJP2K], 1, [Define to 1 if you have libopenjp2.]) AC_SUBST([LIBJP2K_LIBS], [-lopenjp2])
    ], [
      AS_IF([test "x$with_libopenjpeg" = xyes], AC_MSG_ERROR([libopenjp2 support requested but $libopenjpeg_missing not found]))
    ])
  ])
])

AM_CONDITIONAL([HAVE_LIBJP2K], [test "x$libopenjpeg_missing" = x])

case "$host_os" in
  mingw32*)
  AC_SUBST([GDI_LIBS], [-lgdi32])
  CPPFLAGS="${CPPFLAGS} -D__USE_MINGW_ANSI_STDIO" ;;
esac

# Enable less verbose output when building.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_C_BIGENDIAN

AC_SUBST([APPLE_UNIVERSAL_BUILD], [0])
AC_SUBST([ENDIANNESS], [L_LITTLE_ENDIAN])

case "$ac_cv_c_bigendian" in
  yes) AC_SUBST([ENDIANNESS], [L_BIG_ENDIAN]) ;;
  universal) AC_SUBST([APPLE_UNIVERSAL_BUILD], [1]) ;;
esac

# Add the -Wl and --as-needed flags to gcc compiler
AC_MSG_CHECKING([whether compiler supports -Wl,--as-needed])
OLD_LDFLAGS="${LDFLAGS}"
LDFLAGS="-Wl,--as-needed ${LDFLAGS}"

AC_LINK_IFELSE([AC_LANG_PROGRAM()],
  AC_MSG_RESULT([yes]),
  LDFLAGS="${OLD_LDFLAGS}"; AC_MSG_RESULT([no])
)

# Checks for library functions.
AC_CHECK_FUNCS([fmemopen])
AC_CHECK_FUNC([fstatat])

AC_CONFIG_FILES([Makefile src/endianness.h src/Makefile prog/Makefile lept.pc])
AC_OUTPUT