]> sigrok.org Git - sigrok-test.git/blob - configure.ac
187755930c356d4a00ccc4fbede7b1b373e61403
[sigrok-test.git] / configure.ac
1 ##
2 ## This file is part of the sigrok-test project.
3 ##
4 ## Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
5 ## Copyright (C) 2014 Uwe Hermann <uwe@hermann-uwe.de>
6 ##
7 ## This program is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ## GNU General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 ##
20
21 # We require at least autoconf 2.63 (AC_INIT format changed there).
22 AC_PREREQ([2.63])
23
24 AC_INIT([sigrok-test], [0.1.0], [sigrok-devel@lists.sourceforge.net],
25         [sigrok-test], [http://www.sigrok.org])
26
27 # We require at least automake 1.11 (needed for 'silent rules').
28 AM_INIT_AUTOMAKE([1.11 -Wall -Werror subdir-objects check-news])
29 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
30
31 # Enable more compiler warnings.
32 AM_CFLAGS="$AM_CFLAGS -Wall -Wextra -Wmissing-prototypes"
33
34 # Checks for programs.
35 AC_PROG_CC
36
37 # Required for per-target flags or subdir-objects with C sources.
38 AM_PROG_CC_C_O
39
40 # Initialize pkg-config.
41 # We require at least 0.22, as "Requires.private" behaviour changed there.
42 PKG_PROG_PKG_CONFIG([0.22])
43
44 AC_ARG_WITH(decodersdir,
45         AC_HELP_STRING([--with-decodersdir=path],
46         [specify decodersdir [default=DATAROOTDIR/libsigrokdecode/decoders]]),
47         [DECODERS_DIR=$withval], [DECODERS_DIR=$datadir/libsigrokdecode/decoders])
48
49 # Checks for libraries.
50
51 # libglib-2.0 is always needed.
52 AM_PATH_GLIB_2_0([2.24.0],
53         [AM_CFLAGS="$AM_CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
54
55 # Python 3 is always needed.
56 # Note: We need to try a few different variants, since some systems have a
57 # python3.pc file, others have a python-3.3.pc file, and so on.
58 # See also: http://sigrok.org/wiki/Libsigrokdecode/Python
59 CPPFLAGS_PYTHON=""
60 LDFLAGS_PYTHON=""
61 pyver="none"
62 PKG_CHECK_MODULES([python3], [python3 >= 3.2],
63         [pyver=`$PKG_CONFIG --modversion python3`;
64         CPPFLAGS_PYTHON="$CPPFLAGS_PYTHON $python3_CFLAGS";
65         LDFLAGS_PYTHON="$LDFLAGS_PYTHON $python3_LIBS"],
66 [PKG_CHECK_MODULES([python34], [python-3.4 >= 3.4],
67         [pyver=`$PKG_CONFIG --modversion python-3.4`;
68         CPPFLAGS_PYTHON="$CPPFLAGS_PYTHON $python34_CFLAGS";
69         LDFLAGS_PYTHON="$LDFLAGS_PYTHON $python34_LIBS"],
70 [PKG_CHECK_MODULES([python33], [python-3.3 >= 3.3],
71         [pyver=`$PKG_CONFIG --modversion python-3.3`;
72         CPPFLAGS_PYTHON="$CPPFLAGS_PYTHON $python33_CFLAGS";
73         LDFLAGS_PYTHON="$LDFLAGS_PYTHON $python33_LIBS"],
74 [PKG_CHECK_MODULES([python32], [python-3.2 >= 3.2],
75         [pyver=`$PKG_CONFIG --modversion python-3.2`;
76         CPPFLAGS_PYTHON="$CPPFLAGS_PYTHON $python32_CFLAGS";
77         LDFLAGS_PYTHON="$LDFLAGS_PYTHON $python32_LIBS"],
78 )])])])
79 AM_CFLAGS="$AM_CFLAGS $CPPFLAGS_PYTHON"
80 AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS_PYTHON"
81
82 # libsigrok is always needed.
83 PKG_CHECK_MODULES([libsigrok], [libsigrok >= 0.3.0],
84         [AM_CFLAGS="$AM_CFLAGS $libsigrok_CFLAGS";
85         LIBS="$LIBS $libsigrok_LIBS"])
86
87 # libsigrokdecode is always needed.
88 PKG_CHECK_MODULES([libsigrokdecode], [libsigrokdecode >= 0.3.0],
89         [AM_CFLAGS="$AM_CFLAGS $libsigrokdecode_CFLAGS";
90         LIBS="$LIBS $libsigrokdecode_LIBS"])
91
92 # Checks for header files.
93 AC_CHECK_HEADER([sys/resource.h])
94
95 AC_SUBST(DECODERS_DIR)
96 AC_SUBST(MAKEFLAGS, '--no-print-directory')
97 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
98
99 AC_SUBST(AM_CFLAGS)
100 AC_SUBST(AM_LDFLAGS)
101
102 AC_CONFIG_FILES([Makefile])
103
104 AC_OUTPUT
105
106 echo
107 echo "sigrok-test configuration summary:"
108 echo
109 echo "  - Package version (major.minor.micro): 0.1.0"
110 echo "  - Prefix: $prefix"
111 echo
112 echo "Detected libraries:"
113 echo
114
115 if test "x$pyver" = "xnone"; then
116         echo "  - (REQUIRED) python >= 3.2: no"
117 else
118         echo "  - (REQUIRED) python >= 3.2: yes ($pyver)"
119 fi
120
121 # Note: This only works for libs with pkg-config integration.
122 for lib in "glib-2.0 >= 2.24.0" "libsigrok >= 0.3.0" "libsigrokdecode >= 0.3.0"; do
123         optional="REQUIRED"
124         if `$PKG_CONFIG --exists $lib`; then
125                 ver=`$PKG_CONFIG --modversion $lib`
126                 answer="yes ($ver)"
127         else
128                 answer="no"
129         fi
130         echo "  - ($optional) $lib: $answer"
131 done