Use GIT commit ids instead of SVN revision numbers.
[gpgol.git] / configure.ac
1 # configure.ac - for GpgOL
2 # Copyright (C) 2005, 2006, 2007, 2008 g10 Code GmbH
3 #
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12 # Process this file with autoconf to produce a configure script.
13 AC_PREREQ(2.59)
14 min_automake_version="1.9.4"
15
16 # Remember to change the version number immediately *after* a release.
17 # Set my_issvn to "yes" for non-released code.  Remember to run an
18 # "svn up" and "autogen.sh" right before creating a distribution.
19 m4_define([my_version], [1.1.3])
20 m4_define([my_isgit], [yes])
21
22 m4_define([git_commit], m4_esyscmd([git branch -v 2>/dev/null \
23           | awk '/^\* / {printf "%s",$3}']))
24 m4_define([my_full_version],
25           [my_version[]m4_if(my_isgit,[yes],[-git[]git_commit])])
26
27 AC_INIT([gpgol],[my_full_version],[bug-gpgol@g10code.com])
28
29 # Bump up this value if you changed any form.
30 GPGOL_FORMS_REVISION=335
31
32 NEED_GPG_ERROR_VERSION=1.9
33 NEED_GPGME_API=1
34 NEED_GPGME_VERSION=1.1.0
35 NEED_LIBASSUAN_API=2
36 NEED_LIBASSUAN_VERSION=2.0.0
37
38
39 GIT_COMMIT=0x[]git_commit
40 GIT_COMMIT_DECIMAL="$((0x$(echo git_commit | head -c 4)))"
41 PACKAGE=$PACKAGE_NAME
42 PACKAGE_GT=${PACKAGE_NAME}
43 VERSION=$PACKAGE_VERSION
44
45 AC_CONFIG_SRCDIR(src/gpgol.def)
46 AM_CONFIG_HEADER(config.h)
47 AC_CANONICAL_TARGET()
48 AM_INIT_AUTOMAKE
49
50 AC_GNU_SOURCE
51
52 have_gpg_error=no
53 have_libassuan=no
54
55 AC_SUBST(PACKAGE)
56 AC_SUBST(PACKAGE_GT)
57 AC_SUBST(VERSION)
58 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
59 AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT",
60                                 [Name of this package for gettext])
61 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
62 AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
63                                         [Bug report address])
64 AC_DEFINE_UNQUOTED(NEED_GPGME_VERSION, "$NEED_GPGME_VERSION",
65                                        [Required version of GPGME])
66 AC_DEFINE_UNQUOTED(GIT_COMMIT, ${GIT_COMMIT}, [Current GIT commit])
67 AC_DEFINE_UNQUOTED(GPGOL_FORMS_REVISION, ${GPGOL_FORMS_REVISION},
68                                           [Current Forms revision])
69
70
71 BUILD_TIMESTAMP=`date --iso-8601=minutes`
72 AC_SUBST(BUILD_TIMESTAMP)
73 changequote(,)dnl
74 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
75 changequote([,])dnl
76 BUILD_FILEVERSION="${BUILD_FILEVERSION}${GIT_COMMIT_DECIMAL}"
77 AC_SUBST(BUILD_FILEVERSION)
78
79
80 AH_BOTTOM([
81 /* Some global constants. */
82
83 /* Force using of NLS for W32 even if no libintl has been found.  This is
84    okay because we have our own gettext implementation for W32.  */
85 #if defined(HAVE_W32_SYSTEM) && !defined(ENABLE_NLS)
86 #define ENABLE_NLS 1
87 #endif
88 ])
89
90 AM_MAINTAINER_MODE
91
92 # Checks for programs.
93 AC_PROG_MAKE_SET
94 AM_SANITY_CHECK
95 missing_dir=`cd $ac_aux_dir && pwd`
96 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
97 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
98 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
99 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
100 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
101 AC_PROG_AWK
102 AC_PROG_CC
103 AC_PROG_CPP
104 AC_PROG_CXX
105 AC_PROG_INSTALL
106 AC_PROG_LN_S
107 AC_PROG_MAKE_SET
108 AC_PROG_RANLIB
109 AC_CHECK_TOOL(AR, ar, :)
110 AC_CHECK_TOOL(DLLTOOL, dlltool, :)
111 AC_CHECK_TOOL(WINDRES, windres, :)
112
113
114 have_dosish_system=no
115 have_w32_system=no
116 case "${host}" in
117     *-mingw32*)
118         # special stuff for Windoze NT
119         ac_cv_have_dev_random=no
120         AC_DEFINE(USE_ONLY_8DOT3,1,
121                   [set this to limit filenames to the 8.3 format])
122         AC_DEFINE(HAVE_DRIVE_LETTERS,1,
123                   [defined if we must run on a stupid file system])
124         have_dosish_system=yes
125         have_w32_system=yes
126         ;;
127     *)
128     AC_MSG_ERROR([[
129 ***
130 *** This software my only be build for W32 systems.  Use
131 ***     ./autogen.sh --build-w32
132 *** to prepare it for such a build.
133 ***]])
134        ;;
135 esac
136
137 if test "$have_dosish_system" = yes; then
138    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
139              [Defined if we run on some of the PCDOS like systems
140               (DOS, Windoze. OS/2) with special properties like
141               no file modes])
142 fi
143 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
144
145 if test "$have_w32_system" = yes; then
146    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
147 fi
148 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
149
150
151
152 #
153 # Checks for libraries.
154 #
155
156
157 AM_PATH_GPGME("$NEED_GPGME_API:$NEED_GPGME_VERSION",
158                have_gpgme=yes,have_gpgme=no)
159 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
160                   have_gpg_error=yes,have_gpg_error=no)
161 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_USER_2,
162           [The default error source for GpgOL.])
163 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
164                   have_libassuan=yes,have_libassuan=no)
165
166
167 # Note, that autogen.sh greps for the next line.
168 AM_GNU_GETTEXT_VERSION(0.12.1)
169 AM_GNU_GETTEXT([external])
170 # We always want NLs, despite what the above macro figures out.
171 USE_NLS=yes
172
173 # Checks for header files.
174 AC_HEADER_STDC
175 AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h)
176
177 AC_CHECK_FUNCS(stpcpy)
178
179 # Checks for typedefs, structures, and compiler characteristics.
180 AC_C_CONST
181 AC_C_INLINE
182 AC_TYPE_SIZE_T
183 AC_TYPE_SIGNAL
184
185 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
186
187 # Add some extra libs here so that previous tests don't fail for
188 # mysterious reasons - the final link step should bail out.
189 if test "$have_w32_system" = yes; then
190    W32LIBS="-lwsock32"
191 fi
192
193 if test "$GCC" = yes; then
194     CFLAGS="$CFLAGS -Wall -mms-bitfields -fno-strict-aliasing"
195     CXXFLAGS="$CXXFLAGS -Wall -mms-bitfields -fno-strict-aliasing"
196     if test "$USE_MAINTAINER_MODE" = "yes"; then
197         CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
198         CFLAGS="$CFLAGS -Wno-format-y2k -Wformat-security"
199         CFLAGS="$CFLAGS -W -Wno-sign-compare"
200         CXXFLAGS="$CXXFLAGS -Wcast-align -Wshadow"
201         CXXFLAGS="$CXXFLAGS -Wno-format-y2k -Wformat-security"
202         CXXFLAGS="$CXXFLAGS -W -Wno-sign-compare"
203         AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
204         _gcc_cflags_save=$CFLAGS
205         CFLAGS="-Wno-missing-field-initializers"
206         AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_mfi=yes,_gcc_mfi=no)
207         AC_MSG_RESULT($_gcc_mfi)
208         CFLAGS=$_gcc_cflags_save;
209         if test x"$_gcc_mfi" = xyes ; then
210           CFLAGS="$CFLAGS -Wno-missing-field-initializers"
211           CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers"
212         fi
213     fi
214
215     AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
216     _gcc_cflags_save=$CFLAGS
217     CFLAGS="-Wno-pointer-sign"
218     AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no)
219     AC_MSG_RESULT($_gcc_psign)
220     CFLAGS=$_gcc_cflags_save;
221     if test x"$_gcc_psign" = xyes ; then
222        CFLAGS="$CFLAGS -Wno-pointer-sign"
223     fi
224
225
226 fi
227
228 AC_SUBST(W32LIBS)
229
230
231
232 #
233 # Print errors here so that they are visible all
234 # together and the user can acquire them all together.
235 #
236 die=no
237 if test "$have_gpg_error" = "no"; then
238    die=yes
239    AC_MSG_NOTICE([[
240 ***
241 *** You need libgpg-error to build this program.
242 **  This library is for example available at
243 ***   ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
244 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
245 ***]])
246 fi
247 if test "$have_gpgme" = "no"; then
248    die=yes
249    AC_MSG_NOTICE([[
250 ***
251 *** You need gpgme to build this program.
252 **  This library is for example available at
253 ***   ftp://ftp.gnupg.org/gcrypt/gpgme/
254 *** (at least version $NEED_GPGME_VERSION is required.)
255 ***]])
256 fi
257 if test "$have_libassuan" = "no"; then
258    die=yes
259    AC_MSG_NOTICE([[
260 ***
261 *** You need libassuan to build this program.
262 *** This library is for example available at
263 ***   ftp://ftp.gnupg.org/pub/gcrypt/libassuan/
264 *** (at least version $NEED_LIBASSUAN_VERSION is required).
265 ***]])
266 fi
267 if test "$die" = "yes"; then
268     AC_MSG_ERROR([[
269 ***
270 *** Required libraries not found. Please consult the above messages
271 *** and install them before running configure again.
272 ***]])
273 fi
274
275
276 AC_CONFIG_FILES([ Makefile
277 src/Makefile
278 src/versioninfo.rc
279 forms/Makefile
280 doc/Makefile
281 po/Makefile.in
282 m4/Makefile
283 ])
284 AC_OUTPUT