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