]> sigrok.org Git - libsigrok.git/blame - configure.ac
sr/srd/cli: Fix compiling with Homebrew.
[libsigrok.git] / configure.ac
CommitLineData
826938d8
UH
1##
2## This file is part of the sigrok project.
3##
c73d2ea4 4## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
826938d8
UH
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
ef7228ba
UH
20# We require at least autoconf 2.63 (AC_INIT format changed there).
21AC_PREREQ([2.63])
826938d8 22
3af71f0d 23# libsigrok package version number (NOT the same as shared lib version!).
6dddd902
UH
24m4_define([sr_package_version_major], [0])
25m4_define([sr_package_version_minor], [1])
26m4_define([sr_package_version_micro], [0])
27m4_define([sr_package_version], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro])
826938d8 28
6dddd902 29AC_INIT([libsigrok], [sr_package_version], [sigrok-devel@lists.sourceforge.net],
db8ae7b9 30 [libsigrok], [http://www.sigrok.org])
826938d8 31AC_CONFIG_HEADER([config.h])
d8521c93
UH
32AC_CONFIG_MACRO_DIR([autostuff])
33AC_CONFIG_AUX_DIR([autostuff])
826938d8 34
ef7228ba
UH
35# We require at least automake 1.11 (needed for 'silent rules').
36AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign std-options])
826938d8 37m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
432e5e95 38m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
826938d8 39
6dddd902
UH
40AH_TOP([#ifndef SR_CONFIG_H
41#define SR_CONFIG_H /* To stop multiple inclusions. */])
42AH_BOTTOM([#endif /* SR_CONFIG_H */])
826938d8 43
1a081ca6
UH
44# Enable more compiler warnings via -Wall and -Wextra. Add -fvisibility=hidden
45# and enforce use of SR_API to explicitly mark all public API functions.
46CFLAGS="-g -Wall -Wextra -fvisibility=hidden"
826938d8
UH
47
48# Checks for programs.
49AC_PROG_CXX
50AC_PROG_CC
51AC_PROG_CPP
52AC_PROG_INSTALL
53AC_PROG_LN_S
54
55# Initialize libtool.
56LT_INIT
57
58# Initialize pkg-config.
59# We require at least 0.22, as "Requires.private" behaviour changed there.
60PKG_PROG_PKG_CONFIG([0.22])
61
3af71f0d 62# Library version for libsigrok (NOT the same as the package version).
826938d8
UH
63# Carefully read the libtool docs before updating these numbers!
64# The algorithm for determining which number to change (and how) is nontrivial!
65# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
6dddd902
UH
66SR_LIB_VERSION_CURRENT=0
67SR_LIB_VERSION_REVISION=0
68SR_LIB_VERSION_AGE=0
69SR_LIB_VERSION="$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"
70SR_LIB_LDFLAGS="-version-info $SR_LIB_VERSION"
71AC_SUBST(SR_LIB_VERSION_CURRENT)
72AC_SUBST(SR_LIB_VERSION_REVISION)
73AC_SUBST(SR_LIB_VERSION_AGE)
74AC_SUBST(SR_LIB_VERSION)
75AC_SUBST(SR_LIB_LDFLAGS)
826938d8 76
826938d8
UH
77# Logic analyzer hardware support '--enable' options.
78
79# Disabled by default, unfinished.
80AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa],
81 [enable ALSA driver support [default=no]]),
82 [LA_ALSA="$enableval"],
83 [LA_ALSA=no])
84AM_CONDITIONAL(LA_ALSA, test x$LA_ALSA = xyes)
85if test "x$LA_ALSA" = "xyes"; then
86 AC_DEFINE(HAVE_LA_ALSA, 1, [ALSA driver support])
87fi
88
89AC_ARG_ENABLE(asix-sigma, AC_HELP_STRING([--enable-asix-sigma],
6352d030 90 [enable ASIX SIGMA/SIGMA2 support [default=yes]]),
826938d8
UH
91 [LA_ASIX_SIGMA="$enableval"],
92 [LA_ASIX_SIGMA=yes])
93AM_CONDITIONAL(LA_ASIX_SIGMA, test x$LA_ASIX_SIGMA = xyes)
94if test "x$LA_ASIX_SIGMA" = "xyes"; then
6352d030 95 AC_DEFINE(HAVE_LA_ASIX_SIGMA, 1, [ASIX SIGMA/SIGMA2 support])
826938d8
UH
96fi
97
98AC_ARG_ENABLE(chronovu-la8, AC_HELP_STRING([--enable-chronovu-la8],
99 [enable ChronoVu LA8 support [default=yes]]),
100 [LA_CHRONOVU_LA8="$enableval"],
101 [LA_CHRONOVU_LA8=yes])
102AM_CONDITIONAL(LA_CHRONOVU_LA8, test x$LA_CHRONOVU_LA8 = xyes)
103if test "x$LA_CHRONOVU_LA8" = "xyes"; then
104 AC_DEFINE(HAVE_LA_CHRONOVU_LA8, 1, [ChronoVu LA8 support])
105fi
106
2e26e0aa 107# Disabled per default for now, will be enabled when it's tested some more.
f302a082 108AC_ARG_ENABLE(fx2lafw, AC_HELP_STRING([--enable-fx2lafw],
2e26e0aa 109 [enable fx2lafw support (for FX2 LAs). [default=no]]),
f302a082 110 [LA_FX2LAFW="$enableval"],
d56ee265 111 [LA_FX2LAFW=yes])
f302a082
JH
112AM_CONDITIONAL(LA_FX2LAFW, test x$LA_FX2LAFW = xyes)
113if test "x$LA_FX2LAFW" = "xyes"; then
114 AC_DEFINE(HAVE_LA_FX2LAFW, 1, [fx2lafw support])
115fi
116
826938d8
UH
117AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
118 [enable demo driver support [default=yes]]),
119 [LA_DEMO="$enableval"],
120 [LA_DEMO=yes])
121AM_CONDITIONAL(LA_DEMO, test x$LA_DEMO = xyes)
122if test "x$LA_DEMO" = "xyes"; then
123 AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
124fi
125
126# Disabled by default, unfinished.
127AC_ARG_ENABLE(link-mso19, AC_HELP_STRING([--enable-link-mso19],
128 [enable Link Instruments MSO-19 support [default=no]]),
129 [LA_LINK_MSO19="$enableval"],
130 [LA_LINK_MSO19=no])
131AM_CONDITIONAL(LA_LINK_MSO19, test x$LA_LINK_MSO19 = xyes)
132if test "x$LA_LINK_MSO19" = "xyes"; then
133 AC_DEFINE(HAVE_LA_LINK_MSO19, 1, [Link Instruments MSO-19 support])
134fi
135
136AC_ARG_ENABLE(ols, AC_HELP_STRING([--enable-ols],
137 [enable OpenBench Logic Sniffer (OLS) support [default=yes]]),
138 [LA_OLS="$enableval"],
139 [LA_OLS=yes])
140AM_CONDITIONAL(LA_OLS, test x$LA_OLS = xyes)
141if test "x$LA_OLS" = "xyes"; then
142 AC_DEFINE(HAVE_LA_OLS, 1, [OpenBench Logic Sniffer (OLS) support])
143fi
144
826938d8
UH
145AC_ARG_ENABLE(zeroplus-logic-cube,
146 AC_HELP_STRING([--enable-zeroplus-logic-cube],
147 [enable Zeroplus Logic Cube support [default=yes]]),
148 [LA_ZEROPLUS_LOGIC_CUBE="$enableval"],
149 [LA_ZEROPLUS_LOGIC_CUBE=yes])
150AM_CONDITIONAL(LA_ZEROPLUS_LOGIC_CUBE, test x$LA_ZEROPLUS_LOGIC_CUBE = xyes)
151if test "x$LA_ZEROPLUS_LOGIC_CUBE" = "xyes"; then
152 AC_DEFINE(HAVE_LA_ZEROPLUS_LOGIC_CUBE, 1, [Zeroplus Logic Cube support])
153fi
154
155# Checks for libraries.
156
157# This variable collects the pkg-config names of all detected libs.
158# It is then used to construct the "Requires.private:" field in the
159# libsigrok.pc file.
6dddd902 160SR_PKGLIBS=""
826938d8
UH
161
162# libglib-2.0 is always needed.
163# Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
164AM_PATH_GLIB_2_0([2.22.0],
165 [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
166
167# libgthread-2.0 is always needed (e.g. for the demo hardware driver).
168PKG_CHECK_MODULES([gthread], [gthread-2.0 >= 2.22.0],
169 [CFLAGS="$CFLAGS $gthread_CFLAGS"; LIBS="$LIBS $gthread_LIBS";
6dddd902 170 SR_PKGLIBS="$SR_PKGLIBS gthread-2.0"])
826938d8
UH
171
172# libusb is only needed for some hardware drivers.
824b1a8f 173if test "x$LA_ASIX_SIGMA" != xno \
826938d8 174 -o "x$LA_CHRONOVU_LA8" != xno \
f302a082
JH
175 -o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno \
176 -o "x$LA_FX2LAFW" != xno; then
826938d8
UH
177 case "$build" in
178 *freebsd*)
179 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
180 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
181 [Specifies whether we have a libusb.h header.])
182 ;;
183 *)
184 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.5],
185 [CFLAGS="$CFLAGS $libusb_CFLAGS";
186 LIBS="$LIBS $libusb_LIBS";
6dddd902 187 SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"])
826938d8
UH
188 AC_CHECK_LIB(usb-1.0, libusb_init)
189 ;;
190 esac
191fi
192
193# libzip is always needed.
194PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
195 [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
6dddd902 196 SR_PKGLIBS="$SR_PKGLIBS libzip"])
826938d8 197
826938d8
UH
198# libftdi is only needed for some hardware drivers.
199if test "x$LA_ASIX_SIGMA" != xno \
200 -o "x$LA_CHRONOVU_LA8" != xno; then
201 PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
202 [CFLAGS="$CFLAGS $libftdi_CFLAGS";
203 LIBS="$LIBS $libftdi_LIBS";
6dddd902 204 SR_PKGLIBS="$SR_PKGLIBS libftdi"])
826938d8
UH
205fi
206
207# libudev is only needed for some hardware drivers.
208if test "x$LA_LINK_MSO19" != xno; then
209 PKG_CHECK_MODULES([libudev], [libudev >= 151],
210 [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
6dddd902 211 SR_PKGLIBS="$SR_PKGLIBS libudev"])
826938d8
UH
212fi
213
214# ALSA is only needed for some hardware drivers.
215if test "x$LA_ALSA" != xno; then
216 PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
217 [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
6dddd902 218 SR_PKGLIBS="$SR_PKGLIBS alsa"])
826938d8
UH
219fi
220
6dddd902 221AC_SUBST(SR_PKGLIBS)
826938d8
UH
222
223# Checks for header files.
224# These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
225AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
226
227# Checks for typedefs, structures, and compiler characteristics.
228AC_C_INLINE
229AC_TYPE_INT8_T
230AC_TYPE_INT16_T
231AC_TYPE_INT32_T
232AC_TYPE_INT64_T
233AC_TYPE_UINT8_T
234AC_TYPE_UINT16_T
235AC_TYPE_UINT32_T
236AC_TYPE_UINT64_T
237AC_TYPE_SIZE_T
238
239# Checks for library functions.
240AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
241
8e190238 242AC_SUBST(FIRMWARE_DIR, "$datadir/libsigrok/firmware")
826938d8
UH
243AC_SUBST(MAKEFLAGS, '--no-print-directory')
244AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
245
6dddd902
UH
246SR_PACKAGE_VERSION_MAJOR=sr_package_version_major
247SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
248SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
249SR_PACKAGE_VERSION=sr_package_version
3af71f0d 250
6dddd902
UH
251AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
252AC_SUBST(SR_PACKAGE_VERSION_MINOR)
253AC_SUBST(SR_PACKAGE_VERSION_MICRO)
254AC_SUBST(SR_PACKAGE_VERSION)
3af71f0d 255
826938d8 256AC_CONFIG_FILES([Makefile
4937b235 257 sigrok.h
db8ae7b9
UH
258 firmware/Makefile
259 hardware/Makefile
260 hardware/alsa/Makefile
261 hardware/asix-sigma/Makefile
262 hardware/chronovu-la8/Makefile
263 hardware/common/Makefile
264 hardware/demo/Makefile
f302a082 265 hardware/fx2lafw/Makefile
db8ae7b9
UH
266 hardware/link-mso19/Makefile
267 hardware/openbench-logic-sniffer/Makefile
db8ae7b9
UH
268 hardware/zeroplus-logic-cube/Makefile
269 input/Makefile
270 output/Makefile
271 output/text/Makefile
272 libsigrok.pc
826938d8 273 contrib/Makefile
826938d8
UH
274 ])
275
276AC_OUTPUT
277
278echo
45aed072 279echo "libsigrok configuration summary:"
826938d8 280echo
6dddd902
UH
281echo " - Package version (major.minor.micro): $SR_PACKAGE_VERSION"
282echo " - Library version (current:revision:age): $SR_LIB_VERSION"
45aed072
UH
283echo " - Prefix: $prefix"
284echo
285echo "Detected libraries:"
286echo
287
288# Note: This only works for libs with pkg-config integration.
e210c6c0 289for lib in "glib-2.0" "gthread-2.0" "libusb-1.0" "libzip" "libftdi" "libudev" "alsa"; do
45aed072
UH
290 if `$PKG_CONFIG --exists $lib`; then
291 ver=`$PKG_CONFIG --modversion $lib`
292 answer="yes ($ver)"
293 else
294 answer="no"
295 fi
296 echo " - $lib: $answer"
297done
298
299echo
300echo "Enabled hardware drivers:"
301echo
6352d030 302echo " - ASIX SIGMA/SIGMA2............... $LA_ASIX_SIGMA"
45aed072
UH
303echo " - ChronoVu LA8.................... $LA_CHRONOVU_LA8"
304echo " - Demo driver..................... $LA_DEMO"
b5750520 305echo " - fx2lafw (for FX2 LAs)........... $LA_FX2LAFW"
45aed072
UH
306echo " - Link MSO-19..................... $LA_LINK_MSO19"
307echo " - Openbench Logic Sniffer......... $LA_OLS"
45aed072 308echo " - Zeroplus Logic Cube............. $LA_ZEROPLUS_LOGIC_CUBE"
826938d8
UH
309echo
310