Merge branch 'upstream' into tizen
[platform/upstream/lcms2.git] / configure.ac
1 #
2 # LittleCMS 2 configure script
3 #
4
5 AC_PREREQ(2.60)
6
7 #
8 # Set the package name and version
9 #
10 AC_INIT(lcms2,2.16)
11
12 # Specify directory where m4 macros may be found.
13 AC_CONFIG_MACRO_DIR([m4])
14
15 #
16 # Libtool library revision control info
17 #
18 LIBRARY_CURRENT=2
19 LIBRARY_REVISION=16
20 LIBRARY_AGE=0
21
22 AC_SUBST(LIBRARY_CURRENT)dnl
23 AC_SUBST(LIBRARY_REVISION)dnl
24 AC_SUBST(LIBRARY_AGE)dnl
25
26 # Obtain system type by running config.guess
27 AC_CANONICAL_HOST
28
29 AM_INIT_AUTOMAKE([foreign 1.9 tar-ustar no-define dist-zip subdir-objects])
30
31
32 # Check for programs
33 AC_PROG_CC
34 AC_PROG_CPP
35 AC_PROG_CXX
36 LT_INIT
37
38 #AM_PROG_LD
39 #AC_SUBST(LD)
40 #AC_PROG_INSTALL
41 #AC_PROG_MAKE_SET
42 #AC_PROG_LN_S
43
44 #
45 # Tests for Windows
46 #
47 AC_EXEEXT
48 AC_OBJEXT
49
50 # Configure libtool
51 AC_ENABLE_SHARED
52 AC_ENABLE_STATIC
53 AC_LIBTOOL_WIN32_DLL
54 AC_LIBTOOL_SETUP
55 AC_PROG_LIBTOOL
56 AC_SUBST(LIBTOOL_DEPS)
57
58 LIB_PLUGINS=''
59
60 # Add configure option --enable-maintainer-mode which enables dependency
61 # checking and generation useful to package maintainers.  This is made an
62 # option to avoid confusing end users.
63 AM_MAINTAINER_MODE
64
65 # If the C compiler supports the keyword inline, do nothing. Otherwise
66 # define inline to __inline__ or __inline if it accepts one of those,
67 # otherwise define inline to be empty.
68 AC_C_INLINE
69 AC_SUBST(inline)
70
71 # Check if the C compiler supports the "visibility" function attribute
72 # If supported, defines HAVE_FUNC_ATTRIBUTE_VISIBILITY
73 AX_GCC_FUNC_ATTRIBUTE(visibility)
74
75 # Check if the compiler supports "-fvisibility=hidden" and if yes, add it to CFLAGS
76 # This means that symbols that are not marked explicitly for export (CMSAPI)
77 # will not be reachable in the shared library.
78 AX_APPEND_COMPILE_FLAGS(["-fvisibility=hidden"])
79
80 # If words are stored with the most significant byte first (like
81 # Motorola and SPARC CPUs), define `WORDS_BIGENDIAN'.
82 AC_C_BIGENDIAN
83
84 # Check for threadsafe variants of gmtime
85 # Note: check for gmtime_s is a bit more complex as it is implemented as a macro
86 AC_CHECK_FUNCS(gmtime_r, [], [
87                AC_MSG_CHECKING([for gmtime_s])
88                AC_LINK_IFELSE([
89                  AC_LANG_PROGRAM([[#include <time.h>]], [[
90                    time_t t;
91                    struct tm m;
92                    gmtime_s(&m, &t);
93                    return 0;
94                  ]])],
95                  [AC_MSG_RESULT([yes])
96                   AC_DEFINE([HAVE_GMTIME_S], [1], [gmtime_s can be used])], 
97                  [AC_MSG_RESULT([no])]
98                )])
99
100 # Point to JPEG installed in DIR or disable JPEG with --without-jpeg.
101 AC_ARG_WITH(jpeg,
102             AS_HELP_STRING([--with-jpeg=DIR],[use jpeg installed in DIR]),
103             [
104             if [ test "x$withval" = "xno" ]; then
105               [with_jpeg='no']
106             else
107               if [ test "x$withval" != "xyes" ]; then
108                 with_jpeg=$withval
109                 JPEG_DIR=$withval
110                 CPPFLAGS="$CPPFLAGS -I$JPEG_DIR/include"
111                 LDFLAGS="$LDFLAGS -L$JPEG_DIR/lib"
112               fi
113               [with_jpeg='yes']
114             fi
115             ],
116                 [with_jpeg='yes'])
117
118 # Point to TIFF installed in DIR or disable TIFF with --without-tiff.
119 AC_ARG_WITH(tiff,
120             AS_HELP_STRING([--with-tiff=DIR], [use tiff installed in DIR]),
121             [
122             if [ test "x$withval" = "xno" ]; then
123               [with_tiff='no']
124             else
125               if [ test "x$withval" != "xyes" ]; then
126                 with_tiff=$withval
127                 TIFF_DIR=$withval
128                 CPPFLAGS="$CPPFLAGS -I$TIFF_DIR/include"
129                 LDFLAGS="$LDFLAGS -L$TIFF_DIR/lib"
130               fi
131               [with_tiff='yes']  
132             fi
133             ],
134                 [with_tiff='yes'])
135
136 # Disable ZLIB
137 AC_ARG_WITH(zlib,
138               [  --without-zlib          disable ZLIB support],
139               [with_zlib=$withval],
140               [with_zlib='yes'])
141
142 #fast_float plugin:
143 AC_ARG_WITH(fastfloat,
144             AS_HELP_STRING([--with-fastfloat],
145                            [build and install fast_float plugin, use only if GPL 3.0 is acceptable]),
146             [
147                 with_fastfloat=$withval
148             ],
149             [
150                 with_fastfloat='no'
151             ])
152 if test "x$with_fastfloat" = "xyes"
153 then
154             LIB_PLUGINS="$LIB_PLUGINS -llcms2_fast_float"
155 fi
156
157 #multi threaded plugin:
158 AC_ARG_WITH(threaded,
159             AS_HELP_STRING([--with-threaded],
160                            [build and install multi threaded plugin, use only if GPL 3.0 is acceptable]),
161             [
162                 with_threaded=$withval
163             ],
164             [
165                 with_threaded='no'
166             ])
167 if test "x$with_threaded" = "xyes"
168 then
169             LIB_PLUGINS="$LIB_PLUGINS -llcms2_threaded"
170 fi
171
172 #
173 # Determine POSIX threads settings
174 #
175 # Enable support for POSIX thread APIs
176 AC_ARG_WITH(threads,
177               AS_HELP_STRING([--without-pthreads],
178                              [disable POSIX pthreads API support]),
179               [with_threads=$withval],
180               [with_threads='yes'])
181
182 have_threads=no
183 if test "$with_threads" != 'no'
184 then
185
186   AX_PTHREAD()
187  
188   if test "$ax_pthread_ok" = yes
189   then
190     have_threads=yes
191
192     DEF_THREAD="$PTHREAD_CFLAGS"
193     CFLAGS="$CFLAGS $DEF_THREAD"
194     CXXFLAGS="$CXXFLAGS $DEF_THREAD"
195
196     if test "$CC" != "$PTHREAD_CC"
197     then
198       AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
199       CC="$PTHREAD_CC"
200     fi
201     if test "$CXX" != "$PTHREAD_CXX"
202     then
203       AC_MSG_WARN([Replacing compiler $CXX with compiler $PTHREAD_CXX to support pthreads.])
204       CXX="$PTHREAD_CXX"
205     fi
206   fi
207 fi
208
209 # check if compiler supports SSE2 intrinsics
210 AC_LANG_PUSH([C])
211
212 AC_MSG_CHECKING([whether compiler supports SSE2])
213 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
214     #include <emmintrin.h>
215     int main() { __m128i n = _mm_set1_epi8(42); }]])],
216   [ac_compiler_supports_sse2=yes], [ac_compiler_supports_sse2=no])
217 AC_MSG_RESULT([$ac_compiler_supports_sse2])
218 AS_IF([test "x$ac_compiler_supports_sse2" != "xyes"],
219   [AC_DEFINE([CMS_DONT_USE_SSE2], [1], [Define if compiler does not support SSE2 intrinsics])])
220
221 AC_LANG_POP([C])
222
223 #
224 # Find math library
225 #
226 LIB_MATH=''
227 AC_CHECK_LIB(m,sqrt,LIB_MATH="-lm",,)
228 LIBS="$LIB_MATH $LIBS"
229 AC_SUBST(LIB_MATH)
230
231 #
232 # Find Posix threads library
233 #
234 LIB_THREAD=''
235 if test "$with_threads" != 'no' && test "$have_threads" = 'yes'
236 then
237   for lib in pthread pthreads
238   do
239     if test "x$PTHREAD_LIBS" = "x" ; then
240       AC_CHECK_LIB([$lib],pthread_mutex_lock,[PTHREAD_LIBS=-l$lib],,)
241     fi
242   done
243
244   LIB_THREAD="$PTHREAD_LIBS"
245   LIBS="$LIBS $LIB_THREAD"
246   AC_DEFINE(HasTHREADS,1,[Define if you have pthreads library])
247 else
248   AC_DEFINE(HasTHREADS,0,[Define if you don't have pthreads library])
249 fi
250 AC_SUBST(LIB_THREAD)
251
252 #
253 # Check for JPEG
254 #
255 have_jpeg='no'
256 LIB_JPEG=''
257 if test ! "$with_jpeg" = 'no'
258 then
259     AC_MSG_CHECKING([for JPEG support])
260     AC_MSG_RESULT()
261     failed=0;
262     passed=0;
263     AC_CHECK_HEADER(jconfig.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
264     AC_CHECK_HEADER(jerror.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
265     AC_CHECK_HEADER(jmorecfg.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,[#include <jconfig.h>])
266     AC_CHECK_HEADER(jpeglib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
267     AC_CHECK_LIB(jpeg,jpeg_read_header,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
268
269 # Test for compatible JPEG library
270 if test ! "$ac_cv_jpeg_version_ok" = 'yes' ; then
271 AC_CACHE_CHECK(for JPEG library is version 6b or later, ac_cv_jpeg_version_ok,
272 [AC_TRY_COMPILE(
273 #include <stdio.h>
274 #include <stdlib.h>
275 #include <jpeglib.h>
276 ,
277 changequote(<<, >>)dnl
278 <<
279 #if JPEG_LIB_VERSION < 62
280 #error IJG JPEG library must be version 6b or newer!
281 #endif
282 return 0;
283 >>,
284 changequote([, ])dnl
285 ac_cv_jpeg_version_ok='yes',
286 ac_cv_jpeg_version_ok='no')])
287 if test "$ac_cv_jpeg_version_ok" = 'yes' ; then
288  AC_MSG_RESULT(yes)
289  passed=`expr $passed + 1`
290 else
291  AC_MSG_RESULT(no)
292  failed=`expr $failed + 1`
293 fi
294 fi
295     AC_MSG_CHECKING(if JPEG package is complete)
296     if test $passed -gt 0
297     then
298     if test $failed -gt 0
299     then
300         AC_MSG_RESULT(no -- some components failed test)
301         have_jpeg='no (failed tests)'
302     else
303         LIB_JPEG='-ljpeg'
304         LIBS="$LIB_JPEG $LIBS"
305         AC_DEFINE(HasJPEG,1,Define if you have JPEG library)
306         AC_MSG_RESULT(yes)
307         have_jpeg='yes'
308     fi
309     else
310         AC_MSG_RESULT(no)
311     fi
312 fi
313 AM_CONDITIONAL(HasJPEG, test "$have_jpeg" = 'yes')
314 AC_SUBST(LIB_JPEG)
315
316 #
317 # Check for ZLIB
318 #
319 have_zlib='no'
320 dnl TIFF may require zlib so enable zlib check if TIFF is requested
321 if test ! "$with_zlib" = 'no' || test ! "$with_tiff" = 'no'
322 then
323   LIB_ZLIB=''
324   AC_MSG_CHECKING(for ZLIB support )
325   AC_MSG_RESULT()
326   failed=0;
327   passed=0;
328   AC_CHECK_HEADER(zconf.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
329   AC_CHECK_HEADER(zlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
330   AC_CHECK_LIB(z,compress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
331   AC_CHECK_LIB(z,uncompress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
332   AC_CHECK_LIB(z,deflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
333   AC_CHECK_LIB(z,inflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
334   AC_CHECK_LIB(z,gzseek,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
335   AC_CHECK_LIB(z,gztell,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
336   AC_MSG_CHECKING(if ZLIB package is complete)
337   if test $passed -gt 0
338   then
339     if test $failed -gt 0
340     then
341       AC_MSG_RESULT(no -- some components failed test)
342       have_zlib='no (failed tests)'
343     else
344       LIB_ZLIB='-lz'
345       LIBS="$LIB_ZLIB $LIBS"
346       AC_DEFINE(HasZLIB,1,Define if you have zlib compression library)
347       AC_MSG_RESULT(yes)
348       have_zlib='yes'
349     fi
350   else
351     AC_MSG_RESULT(no)
352   fi
353 fi
354 AM_CONDITIONAL(HasZLIB, test "$have_zlib" = 'yes')
355 AC_SUBST(LIB_ZLIB)
356
357 #
358 # Check for TIFF
359 #
360 have_tiff='no'
361 LIB_TIFF=''
362 if test ! "$with_tiff" = 'no'
363 then
364     AC_MSG_CHECKING([for TIFF support])
365     AC_MSG_RESULT()
366     failed=0;
367     passed=0;
368     AC_CHECK_HEADER(tiff.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
369     AC_CHECK_HEADER(tiffio.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
370     AC_CHECK_LIB(tiff,TIFFOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
371     AC_CHECK_LIB(tiff,TIFFClientOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
372     AC_CHECK_LIB(tiff,TIFFIsByteSwapped,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
373     AC_MSG_CHECKING(if TIFF package is complete)
374     if test $passed -gt 0
375     then
376     if test $failed -gt 0
377     then
378         AC_MSG_RESULT(no -- some components failed test)
379         have_tiff='no (failed tests)'
380     else
381         LIB_TIFF='-ltiff'
382         LIBS="$LIB_TIFF $LIBS"
383         AC_DEFINE(HasTIFF,1,Define if you have TIFF library)
384         AC_MSG_RESULT(yes)
385         have_tiff='yes'
386         AC_CHECK_HEADERS(tiffconf.h)
387     fi
388     else
389     AC_MSG_RESULT(no)
390     fi
391 fi
392 AM_CONDITIONAL(HasTIFF, test "$have_tiff" = 'yes')
393 AC_SUBST(LIB_TIFF)
394
395
396 # Libraries that the LCMS library depends on
397 LCMS_LIB_DEPLIBS="$LIB_MATH $LIB_THREAD"
398 LCMS_LIB_DEPLIBS=`echo $LCMS_LIB_DEPLIBS | sed -e 's/  */ /g'`
399 AC_SUBST(LCMS_LIB_DEPLIBS)
400
401 AC_SUBST(LIB_PLUGINS)
402
403 # Libraries that the jpegicc program depends on
404 JPEGICC_DEPLIBS="$LIB_JPEG $LIB_MATH $LIB_THREAD"
405 JPEGICC_DEPLIBS=`echo $JPEGICC_DEPLIBS | sed -e 's/  */ /g'`
406 AC_SUBST(JPEGICC_DEPLIBS)
407
408 # Libraries that the tifficc program depends on
409 TIFFICC_DEPLIBS="$LIB_TIFF $LIB_JPEG $LIB_ZLIB $LIB_MATH $LIB_THREAD"
410 TIFFICC_DEPLIBS=`echo $TIFFICC_DEPLIBS | sed -e 's/  */ /g'`
411 AC_SUBST(TIFFICC_DEPLIBS)
412
413 LIBS=''
414
415 #
416 # Perform substitutions
417 #
418 AC_CONFIG_FILES([Makefile])
419 AC_CONFIG_FILES([lcms2.pc])
420 AC_CONFIG_FILES([include/Makefile])
421 AC_CONFIG_FILES([src/Makefile])
422 AC_CONFIG_FILES([utils/tificc/Makefile])
423 AC_CONFIG_FILES([utils/transicc/Makefile])
424 AC_CONFIG_FILES([utils/linkicc/Makefile])
425 AC_CONFIG_FILES([utils/jpgicc/Makefile])
426 AC_CONFIG_FILES([utils/psicc/Makefile])
427 AC_CONFIG_FILES([testbed/Makefile])
428 AM_CONDITIONAL([COND_FASTFLOAT], [test "x$with_fastfloat" = "xyes" ])
429 AM_CONDITIONAL([COND_THREADED], [test "x$with_threaded" = "xyes" ])
430 AC_CONFIG_FILES([plugins/Makefile])
431 AC_CONFIG_FILES([plugins/fast_float/Makefile])
432 AC_CONFIG_FILES([plugins/fast_float/src/Makefile])
433 AC_CONFIG_FILES([plugins/fast_float/include/Makefile])
434 AC_CONFIG_FILES([plugins/fast_float/testbed/Makefile])
435 AC_CONFIG_FILES([plugins/threaded/Makefile])
436 AC_CONFIG_FILES([plugins/threaded/src/Makefile])
437 AC_CONFIG_FILES([plugins/threaded/include/Makefile])
438 AC_CONFIG_FILES([plugins/threaded/testbed/Makefile])
439 AC_OUTPUT