Move tests
[lttoolbox.git] / configure.ac
blob8bc04d3c7d2d272781d05ee958af871ebafb65d1
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.52)
6 m4_define([required_libxml_version], [2.6.17])
8 AC_INIT([lttoolbox/lttoolbox.h], [3.0.3], [sortiz@users.sourceforge.net])
9 AC_CONFIG_HEADER([lttoolbox/lttools_config.h])
11 GENERIC_LIBRARY_NAME=lttoolbox
13 # Release versioning
14 GENERIC_MAJOR_VERSION=3
15 GENERIC_MINOR_VERSION=0
16 GENERIC_MICRO_VERSION=3
18 # API version (often = GENERIC_MAJOR_VERSION.GENERIC_MINOR_VERSION)
19 GENERIC_API_VERSION=$GENERIC_MAJOR_VERSION
20 AC_SUBST(GENERIC_API_VERSION)
22 # Shared library versioning
23 GENERIC_LIBRARY_VERSION=0:0:0
24 #                       | | |
25 #                +------+ | +---+
26 #                |        |     |
27 #             current:revision:age
28 #                |        |     |
29 #                |        |     +- increment if interfaces have been added
30 #                |        |        set to zero if interfaces have been removed
31 #                                  or changed
32 #                |        +- increment if source code has changed
33 #                |           set to zero if current is incremented
34 #                +- increment if interfaces have been added, removed or changed
36 AC_SUBST(GENERIC_LIBRARY_VERSION)
37 PACKAGE=$GENERIC_LIBRARY_NAME
38 AC_SUBST(GENERIC_LIBRARY_NAME)
40 GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION
41 GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
42 AC_SUBST(GENERIC_RELEASE)
43 AC_SUBST(GENERIC_VERSION)
45 VERSION=$GENERIC_VERSION
47 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
49 # Checks for programs.
51 AC_MSG_CHECKING([Compilation architecture: PPC, i686, x86_64, Other])
52 if test x$(which arch) = x
53 then ARCH=$($(which uname) -m)
54 else ARCH=$($(which arch))
57 if test x$ARCH = xppc
58 then
59   AC_MSG_RESULT([PowerPC])
60   CFLAGS="-Wall -ansi -mpowerpc -maltivec -fno-pic -fomit-frame-pointer $CFLAGS"
61   CXXFLAGS="-Wall -ansi -mpowerpc -maltivec -fno-pic -fomit-frame-pointer $CXXFLAGS"
62 else
63   if test x$ARCH = xi686
64   then
65     AC_MSG_RESULT([i686])
66     CFLAGS="-Wall -ansi -march=i686 -O3 -fomit-frame-pointer -funroll-loops $CFLAGS"
67     CXXFLAGS="-Wall -ansi -march=i686 -O3 \
68               -fomit-frame-pointer -funroll-loops $CXXFLAGS"
69   
70   else
71     if test x$ARCH = xx86_64
72     then
73       AC_MSG_RESULT([x86_64])
74       CFLAGS="-Wall -ansi -O3 -mtune=nocona -fomit-frame-pointer -funroll-loops $CFLAGS"
75       CXXFLAGS="-Wall -ansi -O3 -mtune=nocona \
76               -fomit-frame-pointer -funroll-loops $CXXFLAGS"
77     else
78       AC_MSG_RESULT([Other])
79       CFLAGS="-Wall -ansi -O3 $CFLAGS"
80       CXXFLAGS="-Wall -ansi -O3 $CXXFLAGS"
81     fi
82   fi
85 AC_PROG_CXX
86 AM_PROG_LIBTOOL
87 AM_SANITY_CHECK
88 AC_LANG_CPLUSPLUS
90 AC_ARG_ENABLE(debug,
91               [  --enable-debug  Enable "-g -Wall" compiler options],
92               [CXXFLAGS="-g -Wall";CFLAGS="-g -Wall"])
94 AC_ARG_ENABLE(profile,
95               [  --enable-profile  Enable "-pg -g -Wall" compiler options],
96               [CXXFLAGS="-pg -g -Wall"; CFLAGS="-pg -g -Wall"; LDFLAGS="-pg"])
97                             
99 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
100 if test x$ac_cv_path_PKG_CONFIG = x
101 then
102   AC_MSG_ERROR([You don't have pkg-config installed])
104 if test x$ac_cv_path_PKG_CONFIG = xno
105 then
106   AC_MSG_ERROR([You don't have pkg-config installed])
109 PKG_CHECK_MODULES(LTTOOLBOX, [dnl
110   libxml-2.0 >= required_libxml_version])
112 # Check for wide strings
113 AC_DEFUN([AC_CXX_WSTRING],[
114   AC_CACHE_CHECK(whether the compiler supports wide strings,
115   ac_cv_cxx_wstring,
116   [AC_LANG_SAVE
117    AC_LANG_CPLUSPLUS
118    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string>]],[[
119 std::wstring test = L"test";
120    ]])],
121    [ac_cv_cxx_wstring=yes], [ac_cv_cxx_wstring=no])
122    AC_LANG_RESTORE
123   ])
126 AC_CXX_WSTRING
128 if test "$ac_cv_cxx_wstring" = no 
129 then
130   AC_MSG_ERROR([Missing wide string support])
134 # Checks for libraries.
135 AC_CHECK_LIB(xml2, xmlReaderForFile)
137 # Checks for header files.
138 AC_HEADER_STDC
139 AC_CHECK_HEADERS([stdlib.h string.h unistd.h stddef.h])
141 # Checks for typedefs, structures, and compiler characteristics.
142 AC_HEADER_STDBOOL
143 AC_C_CONST
144 AC_TYPE_SIZE_T
146 # Checks for library functions.
147 AC_FUNC_ERROR_AT_LINE
148 AC_FUNC_MALLOC
149 AC_FUNC_REALLOC
151 AC_CHECK_DECLS([fread_unlocked, fwrite_unlocked, fgetc_unlocked, \ 
152                 fputc_unlocked, fputs_unlocked, \
153                 fgetwc_unlocked, fputwc_unlocked, fputws_unlocked])
154                 
155 AC_CHECK_FUNCS([setlocale strdup getopt_long])
157 AC_OUTPUT([Makefile lttoolbox-3.0.pc lttoolbox/Makefile])