1#
2# LittleCMS 2 configure script
3#
4
5AC_PREREQ(2.60)
6
7#
8# Set the package name and version
9#
10AC_INIT(lcms2mt,2.9)
11
12# Specify directory where m4 macros may be found.
13AC_CONFIG_MACRO_DIR([m4])
14
15#
16# Libtool library revision control info
17# See the libtool documentation under the heading "Libtool's versioning
18# system" in order to understand the meaning of these fields
19#
20# Here are a set of rules to help you update your library version
21# information:
22#
23#  1. Start with version information of `0:0:0' for each libtool library.
24#  2. Update the version information only immediately before a public
25#     release of your software. More frequent updates are unnecessary, and
26#     only guarantee that the current interface number gets larger faster.
27#  3. If the library source code has changed at all since the last update,
28#     then increment revision (`c:r:a' becomes `c:r+1:a').
29#  4. If any interfaces have been added, removed, or changed since the last
30#     update, increment current, and set revision to 0.
31#  5. If any interfaces have been added since the last public release, then
32#     increment age.
33#  6. If any interfaces have been removed since the last public release,
34#     then set age to 0.
35#
36LIBRARY_CURRENT=2
37LIBRARY_REVISION=8
38LIBRARY_AGE=0
39
40AC_SUBST(LIBRARY_CURRENT)dnl
41AC_SUBST(LIBRARY_REVISION)dnl
42AC_SUBST(LIBRARY_AGE)dnl
43
44# Obtain system type by running config.guess
45AC_CANONICAL_HOST
46
47AM_INIT_AUTOMAKE([foreign 1.7.2 no-define dist-zip subdir-objects])
48
49
50# Check for programs
51AC_PROG_CC_STDC
52AC_PROG_CPP
53AC_PROG_CXX
54
55#AM_PROG_LD
56#AC_SUBST(LD)
57#AC_PROG_INSTALL
58#AC_PROG_MAKE_SET
59#AC_PROG_LN_S
60
61#
62# Tests for Windows
63#
64AC_EXEEXT
65AC_OBJEXT
66
67# Configure libtool
68AC_ENABLE_SHARED
69AC_ENABLE_STATIC
70AC_LIBTOOL_WIN32_DLL
71AC_LIBTOOL_SETUP
72AC_PROG_LIBTOOL
73AC_SUBST(LIBTOOL_DEPS)
74
75# Add configure option --enable-maintainer-mode which enables dependency
76# checking and generation useful to package maintainers.  This is made an
77# option to avoid confusing end users.
78AM_MAINTAINER_MODE
79
80# If the C compiler supports the keyword inline, do nothing. Otherwise
81# define inline to __inline__ or __inline if it accepts one of those,
82# otherwise define inline to be empty.
83AC_C_INLINE
84AC_SUBST(inline)
85
86# Check if the C compiler supports the "visibility" function attribute
87# If supported, defines HAVE_FUNC_ATTRIBUTE_VISIBILITY
88AX_GCC_FUNC_ATTRIBUTE(visibility)
89
90# Check if the compiler supports "-fvisibility=hidden" and if yes, add it to CFLAGS
91# This means that symbols that are not marked explicitly for export (CMSAPI)
92# will not be reachable in the shared library.
93AX_APPEND_COMPILE_FLAGS(["-fvisibility=hidden"])
94
95# If words are stored with the most significant byte first (like
96# Motorola and SPARC CPUs), define `WORDS_BIGENDIAN'.
97AC_C_BIGENDIAN
98
99# Point to JPEG installed in DIR or disable JPEG with --without-jpeg.
100AC_ARG_WITH(jpeg,
101            [  --with-jpeg=DIR         use jpeg installed in DIR],
102            [
103            if [ test "x$withval" = "xno" ]; then
104              [with_jpeg='no']
105            else
106              if [ test "x$withval" != "xyes" ]; then
107                with_jpeg=$withval
108                JPEG_DIR=$withval
109                CPPFLAGS="$CPPFLAGS -I$JPEG_DIR/include"
110                LDFLAGS="$LDFLAGS -L$JPEG_DIR/lib"
111              fi
112              [with_jpeg='yes']
113            fi
114            ],
115	        [with_jpeg='yes'])
116
117# Point to TIFF installed in DIR or disable TIFF with --without-tiff.
118AC_ARG_WITH(tiff,
119            [  --with-tiff=DIR         use tiff installed in DIR],
120            [
121            if [ test "x$withval" = "xno" ]; then
122              [with_tiff='no']
123            else
124              if [ test "x$withval" != "xyes" ]; then
125                with_tiff=$withval
126                TIFF_DIR=$withval
127                CPPFLAGS="$CPPFLAGS -I$TIFF_DIR/include"
128                LDFLAGS="$LDFLAGS -L$TIFF_DIR/lib"
129              fi
130              [with_tiff='yes']
131            fi
132            ],
133	        [with_tiff='yes'])
134
135# Disable ZLIB
136AC_ARG_WITH(zlib,
137	      [  --without-zlib          disable ZLIB support],
138	      [with_zlib=$withval],
139	      [with_zlib='yes'])
140
141#
142# Determine POSIX threads settings
143#
144# Enable support for POSIX thread APIs
145AC_ARG_WITH(threads,
146	      AS_HELP_STRING([--without-threads],
147                             [disable POSIX threads API support]),
148	      [with_threads=$withval],
149	      [with_threads='yes'])
150
151have_threads=no
152if test "$with_threads" != 'no'
153then
154
155  ACX_PTHREAD()
156
157  if test "$acx_pthread_ok" = yes
158  then
159    have_threads=yes
160
161    DEF_THREAD="$PTHREAD_CFLAGS"
162    CFLAGS="$CFLAGS $DEF_THREAD"
163    CXXFLAGS="$CXXFLAGS $DEF_THREAD"
164
165    if test "$CC" != "$PTHREAD_CC"
166    then
167      AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
168      CC="$PTHREAD_CC"
169    fi
170    if test "$CXX" != "$PTHREAD_CXX"
171    then
172      AC_MSG_WARN([Replacing compiler $CXX with compiler $PTHREAD_CXX to support pthreads.])
173      CXX="$PTHREAD_CXX"
174    fi
175  fi
176fi
177
178
179#
180# Find math library
181#
182LIB_MATH=''
183AC_CHECK_LIB(m,sqrt,LIB_MATH="-lm",,)
184LIBS="$LIB_MATH $LIBS"
185AC_SUBST(LIB_MATH)
186
187#
188# Find Posix threads library
189#
190LIB_THREAD=''
191if test "$with_threads" != 'no' && test "$have_threads" = 'yes'
192then
193  for lib in pthread pthreads
194  do
195    if test "x$PTHREAD_LIBS" = "x" ; then
196      AC_CHECK_LIB([$lib],pthread_mutex_lock,[PTHREAD_LIBS=-l$lib],,)
197    fi
198  done
199
200  LIB_THREAD="$PTHREAD_LIBS"
201  LIBS="$LIBS $LIB_THREAD"
202  AC_DEFINE(HasTHREADS,1,[Define if you have pthreads library])
203else
204  AC_DEFINE(HasTHREADS,0,[Define if you don't have pthreads library])
205fi
206AC_SUBST(LIB_THREAD)
207
208#
209# Check for JPEG
210#
211have_jpeg='no'
212LIB_JPEG=''
213if test ! "$with_jpeg" = 'no'
214then
215    AC_MSG_CHECKING([for JPEG support])
216    AC_MSG_RESULT()
217    failed=0;
218    passed=0;
219    AC_CHECK_HEADER(jconfig.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
220    AC_CHECK_HEADER(jerror.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
221    AC_CHECK_HEADER(jmorecfg.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
222    AC_CHECK_HEADER(jpeglib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
223    AC_CHECK_LIB(jpeg,jpeg_read_header,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
224
225# Test for compatible JPEG library
226if test ! "$ac_cv_jpeg_version_ok" = 'yes' ; then
227AC_CACHE_CHECK(for JPEG library is version 6b or later, ac_cv_jpeg_version_ok,
228[AC_TRY_COMPILE(
229#include <stdio.h>
230#include <stdlib.h>
231#include <jpeglib.h>
232,
233changequote(<<, >>)dnl
234<<
235#if JPEG_LIB_VERSION < 62
236#error IJG JPEG library must be version 6b or newer!
237#endif
238return 0;
239>>,
240changequote([, ])dnl
241ac_cv_jpeg_version_ok='yes',
242ac_cv_jpeg_version_ok='no')])
243if test "$ac_cv_jpeg_version_ok" = 'yes' ; then
244 AC_MSG_RESULT(yes)
245 passed=`expr $passed + 1`
246else
247 AC_MSG_RESULT(no)
248 failed=`expr $failed + 1`
249fi
250fi
251    AC_MSG_CHECKING(if JPEG package is complete)
252    if test $passed -gt 0
253    then
254    if test $failed -gt 0
255    then
256	AC_MSG_RESULT(no -- some components failed test)
257        have_jpeg='no (failed tests)'
258    else
259	LIB_JPEG='-ljpeg'
260	LIBS="$LIB_JPEG $LIBS"
261	AC_DEFINE(HasJPEG,1,Define if you have JPEG library)
262	AC_MSG_RESULT(yes)
263        have_jpeg='yes'
264    fi
265    else
266        AC_MSG_RESULT(no)
267    fi
268fi
269AM_CONDITIONAL(HasJPEG, test "$have_jpeg" = 'yes')
270AC_SUBST(LIB_JPEG)
271
272#
273# Check for ZLIB
274#
275have_zlib='no'
276dnl PNG requires zlib so enable zlib check if PNG is requested
277if test ! "$with_zlib" = 'no' || test ! "$with_png" = 'no'
278then
279  LIB_ZLIB=''
280  AC_MSG_CHECKING(for ZLIB support )
281  AC_MSG_RESULT()
282  failed=0;
283  passed=0;
284  AC_CHECK_HEADER(zconf.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
285  AC_CHECK_HEADER(zlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
286  AC_CHECK_LIB(z,compress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
287  AC_CHECK_LIB(z,uncompress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
288  AC_CHECK_LIB(z,deflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
289  AC_CHECK_LIB(z,inflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
290  AC_CHECK_LIB(z,gzseek,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
291  AC_CHECK_LIB(z,gztell,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
292  AC_MSG_CHECKING(if ZLIB package is complete)
293  if test $passed -gt 0
294  then
295    if test $failed -gt 0
296    then
297      AC_MSG_RESULT(no -- some components failed test)
298      have_zlib='no (failed tests)'
299    else
300      LIB_ZLIB='-lz'
301      LIBS="$LIB_ZLIB $LIBS"
302      AC_DEFINE(HasZLIB,1,Define if you have zlib compression library)
303      AC_MSG_RESULT(yes)
304      have_zlib='yes'
305    fi
306  else
307    AC_MSG_RESULT(no)
308  fi
309fi
310AM_CONDITIONAL(HasZLIB, test "$have_zlib" = 'yes')
311AC_SUBST(LIB_ZLIB)
312
313#
314# Check for TIFF
315#
316have_tiff='no'
317LIB_TIFF=''
318if test ! "$with_tiff" = 'no'
319then
320    AC_MSG_CHECKING([for TIFF support])
321    AC_MSG_RESULT()
322    failed=0;
323    passed=0;
324    AC_CHECK_HEADER(tiff.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
325    AC_CHECK_HEADER(tiffio.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
326    AC_CHECK_LIB(tiff,TIFFOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
327    AC_CHECK_LIB(tiff,TIFFClientOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
328    AC_CHECK_LIB(tiff,TIFFIsByteSwapped,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
329    AC_MSG_CHECKING(if TIFF package is complete)
330    if test $passed -gt 0
331    then
332    if test $failed -gt 0
333    then
334	AC_MSG_RESULT(no -- some components failed test)
335	have_tiff='no (failed tests)'
336    else
337	LIB_TIFF='-ltiff'
338	LIBS="$LIB_TIFF $LIBS"
339	AC_DEFINE(HasTIFF,1,Define if you have TIFF library)
340	AC_MSG_RESULT(yes)
341	have_tiff='yes'
342	AC_CHECK_HEADERS(tiffconf.h)
343    fi
344    else
345    AC_MSG_RESULT(no)
346    fi
347fi
348AM_CONDITIONAL(HasTIFF, test "$have_tiff" = 'yes')
349AC_SUBST(LIB_TIFF)
350
351
352# Libraries that the LCMS2MT library depends on
353LCMS2MT_LIB_DEPLIBS="$LIB_MATH $LIB_THREAD"
354LCMS2MT_LIB_DEPLIBS=`echo $LCMS2MT_LIB_DEPLIBS | sed -e 's/  */ /g'`
355AC_SUBST(LCMS2MT_LIB_DEPLIBS)
356
357# Libraries that the jpegicc program depends on
358JPEGICC_DEPLIBS="$LIB_JPEG $LIB_MATH $LIB_THREAD"
359JPEGICC_DEPLIBS=`echo $JPEGICC_DEPLIBS | sed -e 's/  */ /g'`
360AC_SUBST(JPEGICC_DEPLIBS)
361
362# Libraries that the tifficc program depends on
363TIFFICC_DEPLIBS="$LIB_TIFF $LIB_JPEG $LIB_ZLIB $LIB_MATH $LIB_THREAD"
364TIFFICC_DEPLIBS=`echo $TIFFICC_DEPLIBS | sed -e 's/  */ /g'`
365AC_SUBST(TIFFICC_DEPLIBS)
366
367LIBS=''
368
369#
370# Perform substitutions
371#
372AC_CONFIG_FILES([Makefile])
373AC_CONFIG_FILES([lcms2mt.pc])
374AC_CONFIG_FILES([include/Makefile])
375AC_CONFIG_FILES([src/Makefile])
376AC_CONFIG_FILES([utils/tificc/Makefile])
377AC_CONFIG_FILES([utils/transicc/Makefile])
378AC_CONFIG_FILES([utils/linkicc/Makefile])
379AC_CONFIG_FILES([utils/jpgicc/Makefile])
380AC_CONFIG_FILES([utils/psicc/Makefile])
381AC_CONFIG_FILES([testbed/Makefile])
382AC_OUTPUT
383