]> sigrok.org Git - libsigrokdecode.git/blob - configure.ac
09bfd56802356600c495fd1b456ace7b844fa0ba
[libsigrokdecode.git] / configure.ac
1 ##
2 ## This file is part of the libsigrokdecode 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 # libsigrokdecode package version number (NOT the same as shared lib version!).
24 AC_INIT([libsigrokdecode], [0.4.0],
25         [sigrok-devel@lists.sourceforge.net], [libsigrokdecode],
26         [http://www.sigrok.org])
27 AC_CONFIG_MACRO_DIR([m4])
28 AC_CONFIG_AUX_DIR([autostuff])
29 AC_CONFIG_HEADERS([config.h version.h])
30
31 # We require at least automake 1.11 (needed for 'silent rules').
32 AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define subdir-objects check-news color-tests])
33 AM_SILENT_RULES([yes])
34 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
35
36 AC_CANONICAL_HOST
37
38 # Checks for programs.
39 AC_PROG_CC
40 AC_PROG_INSTALL
41 AC_PROG_LN_S
42
43 # Required for per-target flags or subdir-objects with C sources.
44 AM_PROG_CC_C_O
45
46 # Set the standard the C library headers should conform to.
47 AH_VERBATIM([_POSIX_C_SOURCE], [/* The targeted POSIX standard. */
48 #ifndef _POSIX_C_SOURCE
49 # define _POSIX_C_SOURCE 200112L
50 #endif])
51
52 # Get compiler versions.
53 SR_PROG_VERSION([$CC], [srd_cc_version])
54
55 # Initialize libtool.
56 LT_INIT
57
58 # Set up the libsigrokdecode version defines.
59 SR_PKG_VERSION_SET([SRD_PACKAGE_VERSION], [AC_PACKAGE_VERSION])
60
61 # Library version for libsigrokdecode (NOT the same as the package version).
62 # Carefully read the libtool docs before updating these numbers!
63 # The algorithm for determining which number to change (and how) is nontrivial!
64 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
65 SR_LIB_VERSION_SET([SRD_LIB_VERSION], [2:0:0])
66
67 AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"])
68
69 ############################
70 ##  Package dependencies  ##
71 ############################
72
73 # Initialize pkg-config.
74 # We require at least 0.22, as "Requires.private" behaviour changed there.
75 PKG_PROG_PKG_CONFIG([0.22])
76
77 # Collect the pkg-config module names of all dependencies in SRD_PKGLIBS.
78 # These are used to derive the compiler flags and for the "Requires.private"
79 # field in the generated libsigrokdecode.pc file.
80 SRD_PKGLIBS=
81 SRD_PKGLIBS_TESTS=
82
83 # Keep track of all checked modules so we can list them at the end.
84 SR_PKG_CHECK_SUMMARY([srd_pkglibs_summary])
85
86 # Python 3 is always needed.
87 SR_PKG_CHECK([python3], [SRD_PKGLIBS],
88         [python3 >= 3.2], [python-3.4 >= 3.4], [python-3.3 >= 3.3], [python-3.2 >= 3.2])
89 AS_IF([test "x$sr_have_python3" = xno],
90         [AC_MSG_ERROR([Cannot find Python 3 development headers.])])
91
92 # We also need to find the name of the python3 executable (for 'make install').
93 # Some OSes call this python3, some call it python3.2, etc. etc.
94 AC_ARG_VAR([PYTHON3], [Python 3 interpreter])
95 AC_CHECK_PROGS([PYTHON3], [python3.4 python3.3 python3.2 python3])
96 AS_IF([test "x$PYTHON3" = x],
97         [AC_MSG_ERROR([Cannot find Python 3 interpreter.])])
98
99 ######################
100 ##  Feature checks  ##
101 ######################
102
103 # Keep track of all checked modules so we can list them at the end.
104 SR_PKG_CHECK_SUMMARY([srd_pkglibs_opt_summary])
105
106 # The Check unit testing framework is optional. Disable if not found.
107 SR_PKG_CHECK([check], [SRD_PKGLIBS_TESTS], [check >= 0.9.4])
108 AM_CONDITIONAL([HAVE_CHECK], [test "x$sr_have_check" = xyes])
109
110 # Enable the C99 standard if possible, and enforce the use
111 # of SRD_API to explicitly mark all public API functions.
112 SRD_EXTRA_CFLAGS=
113 SR_CHECK_COMPILE_FLAGS([SRD_EXTRA_CFLAGS], [C99], [-std=c99 -c99 -AC99 -qlanglvl=extc99])
114 SR_CHECK_COMPILE_FLAGS([SRD_EXTRA_CFLAGS], [visibility], [-fvisibility=hidden])
115
116 # Select suitable compiler warning flags.
117 SR_ARG_ENABLE_WARNINGS([SRD_WFLAGS], [-Wall], [-Wall -Wextra -Wmissing-prototypes])
118
119 # Link against libm, this is required (among other things) by Python.
120 SRD_EXTRA_LIBS=
121 SR_SEARCH_LIBS([SRD_EXTRA_LIBS], [pow], [m])
122
123 AC_SYS_LARGEFILE
124
125 ##############################
126 ##  Finalize configuration  ##
127 ##############################
128
129 AC_SUBST([SRD_PKGLIBS])
130
131 # Retrieve the compile and link flags for all modules combined.
132 # Also, bail out at this point if any module dependency is not met.
133 PKG_CHECK_MODULES([LIBSIGROKDECODE], [glib-2.0 >= 2.24.0 $SRD_PKGLIBS])
134 PKG_CHECK_MODULES([TESTS], [$SRD_PKGLIBS_TESTS glib-2.0 $SRD_PKGLIBS])
135
136 srd_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
137
138 AC_CONFIG_FILES([Makefile libsigrokdecode.pc])
139
140 AC_OUTPUT
141
142 cat >&AS_MESSAGE_FD <<_EOF
143
144 libsigrokdecode configuration summary:
145  - Package version................. $SRD_PACKAGE_VERSION
146  - Library ABI version............. $SRD_LIB_VERSION
147  - Prefix.......................... $prefix
148  - Building on..................... $build
149  - Building for.................... $host
150
151 Compile configuration:
152  - C compiler...................... $CC
153  - C compiler version.............. $srd_cc_version
154  - C compiler flags................ $CFLAGS
155  - Additional C compiler flags..... $SRD_EXTRA_CFLAGS
156  - C compiler warnings............. $SRD_WFLAGS
157
158 Detected libraries (required):
159  - glib-2.0 >= 2.24.0.............. $srd_glib_version
160 $srd_pkglibs_summary
161 Detected libraries (optional):
162 $srd_pkglibs_opt_summary
163 _EOF