configure.ac: Only check for things we actually use.
[sigrok-cli.git] / configure.ac
1 ##
2 ## This file is part of the sigrok-cli project.
3 ##
4 ## Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
5 ##
6 ## This program is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 3 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 ##
19
20 # We require at least autoconf 2.63 (AC_INIT format changed there).
21 AC_PREREQ([2.63])
22
23 AC_INIT([sigrok-cli], [0.4.0], [sigrok-devel@lists.sourceforge.net],
24         [sigrok-cli], [http://www.sigrok.org])
25
26 AC_CONFIG_SRCDIR([sigrok-cli.h])
27
28 AC_CONFIG_HEADERS([config.h])
29 AC_CONFIG_MACRO_DIR([autostuff])
30 AC_CONFIG_AUX_DIR([autostuff])
31
32 # We require at least automake 1.11 (needed for 'silent rules').
33 AM_INIT_AUTOMAKE([1.11 -Wall -Werror std-options check-news])
34 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
35 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
36
37 AH_TOP([#ifndef SIGROK_CLI_CONFIG_H
38 #define SIGROK_CLI_CONFIG_H    /* To stop multiple inclusions. */])
39 AH_BOTTOM([#endif /* SIGROK_CLI_CONFIG_H */])
40
41 # Enable more compiler warnings via -Wall and -Wextra.
42 CFLAGS="$CFLAGS -Wall -Wextra"
43
44 # Checks for programs.
45 AC_PROG_CC
46 AC_PROG_CPP
47 AC_PROG_INSTALL
48 AC_PROG_LN_S
49
50 # Initialize libtool.
51 LT_INIT
52
53 # Initialize pkg-config.
54 # We require at least 0.22, as "Requires.private" behaviour changed there.
55 PKG_PROG_PKG_CONFIG([0.22])
56
57 # Checks for libraries.
58 AC_ARG_WITH([libsigrokdecode],
59         AS_HELP_STRING([--with-libsigrokdecode],
60                         [compile with libsigrokdecode support]),
61         [WITH_SRD=$enableval],[WITH_SRD=yes])
62 AM_CONDITIONAL(WITH_SRD, test x$WITH_SRD = xyes)
63
64 AM_PATH_GLIB_2_0([2.28.0],
65         [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
66
67 PKG_CHECK_MODULES([libsigrok], [libsigrok >= 0.2.0],
68         [CFLAGS="$CFLAGS $libsigrok_CFLAGS";
69         LIBS="$LIBS $libsigrok_LIBS"])
70
71 if test "x$WITH_SRD" = "xyes"; then
72         PKG_CHECK_MODULES([libsigrokdecode], [libsigrokdecode >= 0.2.0],
73                 [CFLAGS="$CFLAGS $libsigrokdecode_CFLAGS";
74                         LIBS="$LIBS $libsigrokdecode_LIBS";
75                         AC_DEFINE(HAVE_SRD, [1], [libsigrokdecode is available.])]
76         )
77 fi
78
79 # Checks for header files.
80 # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
81
82 AC_SUBST(MAKEFLAGS, '--no-print-directory')
83 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
84
85 AC_CONFIG_FILES([Makefile
86                  contrib/Makefile
87                  contrib/sigrok-cli_cross.nsi
88                  doc/Makefile])
89
90 AC_OUTPUT
91
92 echo
93 echo "sigrok-cli configuration summary:"
94 echo
95 echo "  - Package version: $VERSION"
96 echo "  - Prefix: $prefix"
97 echo "  - Building on: $build"
98 echo "  - Building for: $host"
99 echo
100 echo "Detected libraries:"
101 echo
102
103 # Note: This only works for libs with pkg-config integration.
104 for lib in "glib-2.0 >= 2.28.0" "libsigrok >= 0.2.0" "libsigrokdecode >= 0.2.0"; do
105         if test "$lib" = "libsigrokdecode" -a "$WITH_SRD" != "yes" ; then
106                 answer="no"
107         else
108                 if `$PKG_CONFIG --exists $lib`; then
109                         ver=`$PKG_CONFIG --modversion $lib`
110                         answer="yes ($ver)"
111                 else
112                         answer="no"
113                 fi
114         fi
115         echo "  - $lib: $answer"
116 done
117
118 echo
119