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