blob: f177c87f56f900cb0e642a24338515e7b28a87c4 [file] [log] [blame]
Uwe Hermann826938d2011-12-30 10:42:39 +01001##
2## This file is part of the sigrok project.
3##
Bert Vermeulenc73d2ea2012-02-13 14:31:51 +01004## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
Uwe Hermann826938d2011-12-30 10:42:39 +01005##
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
Uwe Hermannef7228b2012-01-28 21:26:56 +010020# We require at least autoconf 2.63 (AC_INIT format changed there).
21AC_PREREQ([2.63])
Uwe Hermann826938d2011-12-30 10:42:39 +010022
Uwe Hermann3af71f02012-01-04 00:05:43 +010023# libsigrok package version number (NOT the same as shared lib version!).
Uwe Hermann6dddd902012-03-31 11:28:24 +020024m4_define([sr_package_version_major], [0])
Uwe Hermann63298402012-06-01 00:16:42 +020025m4_define([sr_package_version_minor], [2])
26m4_define([sr_package_version_micro], [0])
Uwe Hermann6dddd902012-03-31 11:28:24 +020027m4_define([sr_package_version], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro])
Uwe Hermann826938d2011-12-30 10:42:39 +010028
Uwe Hermann6dddd902012-03-31 11:28:24 +020029AC_INIT([libsigrok], [sr_package_version], [sigrok-devel@lists.sourceforge.net],
Uwe Hermanndb8ae7b2011-12-30 10:50:00 +010030 [libsigrok], [http://www.sigrok.org])
Uwe Hermann826938d2011-12-30 10:42:39 +010031AC_CONFIG_HEADER([config.h])
Uwe Hermannd8521c92012-01-03 21:55:48 +010032AC_CONFIG_MACRO_DIR([autostuff])
33AC_CONFIG_AUX_DIR([autostuff])
Uwe Hermann826938d2011-12-30 10:42:39 +010034
Uwe Hermannef7228b2012-01-28 21:26:56 +010035# We require at least automake 1.11 (needed for 'silent rules').
36AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign std-options])
Uwe Hermann826938d2011-12-30 10:42:39 +010037m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
Pekka Nikander432e5e92012-05-11 19:23:21 +030038m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
Uwe Hermann826938d2011-12-30 10:42:39 +010039
Uwe Hermann6dddd902012-03-31 11:28:24 +020040AH_TOP([#ifndef SR_CONFIG_H
41#define SR_CONFIG_H /* To stop multiple inclusions. */])
42AH_BOTTOM([#endif /* SR_CONFIG_H */])
Uwe Hermann826938d2011-12-30 10:42:39 +010043
Uwe Hermann1a081ca2012-02-01 23:40:35 +010044# 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"
Uwe Hermann826938d2011-12-30 10:42:39 +010047
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
Uwe Hermann3af71f02012-01-04 00:05:43 +010062# Library version for libsigrok (NOT the same as the package version).
Uwe Hermann826938d2011-12-30 10:42:39 +010063# 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
Uwe Hermann63298402012-06-01 00:16:42 +020066SR_LIB_VERSION_CURRENT=1
Uwe Hermann6dddd902012-03-31 11:28:24 +020067SR_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)
Uwe Hermann826938d2011-12-30 10:42:39 +010076
Uwe Hermann826938d2011-12-30 10:42:39 +010077# 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],
Uwe Hermann6352d032012-05-02 19:02:03 +020090 [enable ASIX SIGMA/SIGMA2 support [default=yes]]),
Uwe Hermann826938d2011-12-30 10:42:39 +010091 [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
Uwe Hermann6352d032012-05-02 19:02:03 +020095 AC_DEFINE(HAVE_LA_ASIX_SIGMA, 1, [ASIX SIGMA/SIGMA2 support])
Uwe Hermann826938d2011-12-30 10:42:39 +010096fi
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
Joel Holdsworthf302a082012-02-11 12:08:49 +0000107AC_ARG_ENABLE(fx2lafw, AC_HELP_STRING([--enable-fx2lafw],
Bert Vermeulen5d4fb4f2012-07-01 15:29:57 +0200108 [enable fx2lafw support (for FX2 LAs). [default=yes]]),
Joel Holdsworthf302a082012-02-11 12:08:49 +0000109 [LA_FX2LAFW="$enableval"],
Joel Holdsworthd56ee262012-04-18 19:10:15 +0100110 [LA_FX2LAFW=yes])
Joel Holdsworthf302a082012-02-11 12:08:49 +0000111AM_CONDITIONAL(LA_FX2LAFW, test x$LA_FX2LAFW = xyes)
112if test "x$LA_FX2LAFW" = "xyes"; then
113 AC_DEFINE(HAVE_LA_FX2LAFW, 1, [fx2lafw support])
114fi
115
Bert Vermeulenca3d84c2012-07-01 22:37:15 +0200116# Disabled by default for now
117AC_ARG_ENABLE(genericdmm, AC_HELP_STRING([--enable-genericdmm],
118 [enable genericdmm support (for most DMMs). [default=no]]),
119 [HW_GENERICDMM="$enableval"],
120 [HW_GENERICDMM=no])
121AM_CONDITIONAL(HW_GENERICDMM, test x$HW_GENERICDMM = xyes)
122if test "x$HW_GENERICDMM" = "xyes"; then
123 AC_DEFINE(HAVE_HW_GENERICDMM, 1, [Generic DMM support])
124fi
125
Uwe Hermann826938d2011-12-30 10:42:39 +0100126AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
127 [enable demo driver support [default=yes]]),
128 [LA_DEMO="$enableval"],
129 [LA_DEMO=yes])
130AM_CONDITIONAL(LA_DEMO, test x$LA_DEMO = xyes)
131if test "x$LA_DEMO" = "xyes"; then
132 AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
133fi
134
135# Disabled by default, unfinished.
136AC_ARG_ENABLE(link-mso19, AC_HELP_STRING([--enable-link-mso19],
137 [enable Link Instruments MSO-19 support [default=no]]),
138 [LA_LINK_MSO19="$enableval"],
139 [LA_LINK_MSO19=no])
140AM_CONDITIONAL(LA_LINK_MSO19, test x$LA_LINK_MSO19 = xyes)
141if test "x$LA_LINK_MSO19" = "xyes"; then
142 AC_DEFINE(HAVE_LA_LINK_MSO19, 1, [Link Instruments MSO-19 support])
143fi
144
145AC_ARG_ENABLE(ols, AC_HELP_STRING([--enable-ols],
146 [enable OpenBench Logic Sniffer (OLS) support [default=yes]]),
147 [LA_OLS="$enableval"],
148 [LA_OLS=yes])
149AM_CONDITIONAL(LA_OLS, test x$LA_OLS = xyes)
150if test "x$LA_OLS" = "xyes"; then
151 AC_DEFINE(HAVE_LA_OLS, 1, [OpenBench Logic Sniffer (OLS) support])
152fi
153
Uwe Hermann826938d2011-12-30 10:42:39 +0100154AC_ARG_ENABLE(zeroplus-logic-cube,
155 AC_HELP_STRING([--enable-zeroplus-logic-cube],
Uwe Hermann8fdecce2012-05-30 22:55:03 +0200156 [enable ZEROPLUS Logic Cube support [default=yes]]),
Uwe Hermann826938d2011-12-30 10:42:39 +0100157 [LA_ZEROPLUS_LOGIC_CUBE="$enableval"],
158 [LA_ZEROPLUS_LOGIC_CUBE=yes])
159AM_CONDITIONAL(LA_ZEROPLUS_LOGIC_CUBE, test x$LA_ZEROPLUS_LOGIC_CUBE = xyes)
160if test "x$LA_ZEROPLUS_LOGIC_CUBE" = "xyes"; then
Uwe Hermann8fdecce2012-05-30 22:55:03 +0200161 AC_DEFINE(HAVE_LA_ZEROPLUS_LOGIC_CUBE, 1, [ZEROPLUS Logic Cube support])
Uwe Hermann826938d2011-12-30 10:42:39 +0100162fi
163
Bert Vermeulen3b533202012-04-23 01:05:58 +0200164AC_ARG_ENABLE(hantek-dso,
165 AC_HELP_STRING([--enable-hantek-dso],
166 [enable Hantek DSO support [default=yes]]),
167 [HW_HANTEK_DSO="$enableval"],
168 [HW_HANTEK_DSO=yes])
169AM_CONDITIONAL(HW_HANTEK_DSO, test x$HW_HANTEK_DSO = xyes)
170if test "x$HW_HANTEK_DSO" = "xyes"; then
171 AC_DEFINE(HAVE_HW_HANTEK_DSO, 1, [Hantek DSO support])
172fi
173
Uwe Hermann826938d2011-12-30 10:42:39 +0100174# Checks for libraries.
175
176# This variable collects the pkg-config names of all detected libs.
177# It is then used to construct the "Requires.private:" field in the
178# libsigrok.pc file.
Uwe Hermann6dddd902012-03-31 11:28:24 +0200179SR_PKGLIBS=""
Uwe Hermann826938d2011-12-30 10:42:39 +0100180
181# libglib-2.0 is always needed.
182# Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
Bert Vermeulene21e8462012-06-23 01:17:36 +0200183AM_PATH_GLIB_2_0([2.28.0],
Uwe Hermann826938d2011-12-30 10:42:39 +0100184 [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
185
186# libgthread-2.0 is always needed (e.g. for the demo hardware driver).
187PKG_CHECK_MODULES([gthread], [gthread-2.0 >= 2.22.0],
188 [CFLAGS="$CFLAGS $gthread_CFLAGS"; LIBS="$LIBS $gthread_LIBS";
Uwe Hermann6dddd902012-03-31 11:28:24 +0200189 SR_PKGLIBS="$SR_PKGLIBS gthread-2.0"])
Uwe Hermann826938d2011-12-30 10:42:39 +0100190
191# libusb is only needed for some hardware drivers.
Joel Holdsworth824b1a82012-04-18 19:17:25 +0100192if test "x$LA_ASIX_SIGMA" != xno \
Uwe Hermann826938d2011-12-30 10:42:39 +0100193 -o "x$LA_CHRONOVU_LA8" != xno \
Bert Vermeulenef2345b2012-07-29 15:21:08 +0200194 -o "x$LA_FX2LAFW" != xno \
195 -o "x$HW_HANTEK_DSO" != xno \
196 -o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno; then
Uwe Hermann826938d2011-12-30 10:42:39 +0100197 case "$build" in
198 *freebsd*)
199 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
200 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
201 [Specifies whether we have a libusb.h header.])
202 ;;
203 *)
204 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.5],
205 [CFLAGS="$CFLAGS $libusb_CFLAGS";
206 LIBS="$LIBS $libusb_LIBS";
Uwe Hermann6dddd902012-03-31 11:28:24 +0200207 SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"])
Uwe Hermann826938d2011-12-30 10:42:39 +0100208 AC_CHECK_LIB(usb-1.0, libusb_init)
209 ;;
210 esac
211fi
212
213# libzip is always needed.
214PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
215 [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
Uwe Hermann6dddd902012-03-31 11:28:24 +0200216 SR_PKGLIBS="$SR_PKGLIBS libzip"])
Uwe Hermann826938d2011-12-30 10:42:39 +0100217
Uwe Hermann826938d2011-12-30 10:42:39 +0100218# libftdi is only needed for some hardware drivers.
219if test "x$LA_ASIX_SIGMA" != xno \
220 -o "x$LA_CHRONOVU_LA8" != xno; then
221 PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
222 [CFLAGS="$CFLAGS $libftdi_CFLAGS";
223 LIBS="$LIBS $libftdi_LIBS";
Uwe Hermann6dddd902012-03-31 11:28:24 +0200224 SR_PKGLIBS="$SR_PKGLIBS libftdi"])
Uwe Hermann826938d2011-12-30 10:42:39 +0100225fi
226
227# libudev is only needed for some hardware drivers.
228if test "x$LA_LINK_MSO19" != xno; then
229 PKG_CHECK_MODULES([libudev], [libudev >= 151],
230 [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
Uwe Hermann6dddd902012-03-31 11:28:24 +0200231 SR_PKGLIBS="$SR_PKGLIBS libudev"])
Uwe Hermann826938d2011-12-30 10:42:39 +0100232fi
233
234# ALSA is only needed for some hardware drivers.
235if test "x$LA_ALSA" != xno; then
236 PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
237 [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
Uwe Hermann6dddd902012-03-31 11:28:24 +0200238 SR_PKGLIBS="$SR_PKGLIBS alsa"])
Uwe Hermann826938d2011-12-30 10:42:39 +0100239fi
240
Bert Vermeulen28b9dd12012-07-11 12:36:13 +0200241# EZUSB FX2 firmware helpers only needed for some hardware drivers
242AM_CONDITIONAL(NEED_EZUSB, \
243 test "x$LA_FX2LAFW" != xno \
244 -o "x$HW_HANTEK_DSO" != xno \
245)
246
247# Serial port helpers only needed for some hardware drivers
248AM_CONDITIONAL(NEED_SERIAL, \
249 test "x$LA_OLS" != xno \
250 -o "x$HW_GENERICDMM" != xno \
251)
252
Uwe Hermann6dddd902012-03-31 11:28:24 +0200253AC_SUBST(SR_PKGLIBS)
Uwe Hermann826938d2011-12-30 10:42:39 +0100254
255# Checks for header files.
256# These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
257AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
258
259# Checks for typedefs, structures, and compiler characteristics.
260AC_C_INLINE
261AC_TYPE_INT8_T
262AC_TYPE_INT16_T
263AC_TYPE_INT32_T
264AC_TYPE_INT64_T
265AC_TYPE_UINT8_T
266AC_TYPE_UINT16_T
267AC_TYPE_UINT32_T
268AC_TYPE_UINT64_T
269AC_TYPE_SIZE_T
270
271# Checks for library functions.
272AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
273
Uwe Hermannfb6f1972012-05-30 00:00:33 +0200274AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
Uwe Hermann826938d2011-12-30 10:42:39 +0100275AC_SUBST(MAKEFLAGS, '--no-print-directory')
276AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
277
Uwe Hermann6dddd902012-03-31 11:28:24 +0200278SR_PACKAGE_VERSION_MAJOR=sr_package_version_major
279SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
280SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
281SR_PACKAGE_VERSION=sr_package_version
Uwe Hermann826938d2011-12-30 10:42:39 +0100282
Uwe Hermann6dddd902012-03-31 11:28:24 +0200283AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
284AC_SUBST(SR_PACKAGE_VERSION_MINOR)
285AC_SUBST(SR_PACKAGE_VERSION_MICRO)
286AC_SUBST(SR_PACKAGE_VERSION)
Uwe Hermann826938d2011-12-30 10:42:39 +0100287
Uwe Hermann826938d2011-12-30 10:42:39 +0100288AC_CONFIG_FILES([Makefile
Bert Vermeulen45c59c82012-07-05 00:55:07 +0200289 version.h
Uwe Hermanndb8ae7b2011-12-30 10:50:00 +0100290 hardware/Makefile
291 hardware/alsa/Makefile
292 hardware/asix-sigma/Makefile
293 hardware/chronovu-la8/Makefile
294 hardware/common/Makefile
295 hardware/demo/Makefile
Joel Holdsworthf302a082012-02-11 12:08:49 +0000296 hardware/fx2lafw/Makefile
Bert Vermeulenca3d84c2012-07-01 22:37:15 +0200297 hardware/genericdmm/Makefile
Uwe Hermanndb8ae7b2011-12-30 10:50:00 +0100298 hardware/link-mso19/Makefile
299 hardware/openbench-logic-sniffer/Makefile
Uwe Hermanndb8ae7b2011-12-30 10:50:00 +0100300 hardware/zeroplus-logic-cube/Makefile
Bert Vermeulen3b533202012-04-23 01:05:58 +0200301 hardware/hantek-dso/Makefile
Uwe Hermanndb8ae7b2011-12-30 10:50:00 +0100302 input/Makefile
303 output/Makefile
304 output/text/Makefile
305 libsigrok.pc
Uwe Hermann826938d2011-12-30 10:42:39 +0100306 contrib/Makefile
Uwe Hermann826938d2011-12-30 10:42:39 +0100307 ])
308
309AC_OUTPUT
310
311echo
Uwe Hermann45aed072012-01-04 00:49:21 +0100312echo "libsigrok configuration summary:"
Uwe Hermann826938d2011-12-30 10:42:39 +0100313echo
Uwe Hermann6dddd902012-03-31 11:28:24 +0200314echo " - Package version (major.minor.micro): $SR_PACKAGE_VERSION"
315echo " - Library version (current:revision:age): $SR_LIB_VERSION"
Uwe Hermann45aed072012-01-04 00:49:21 +0100316echo " - Prefix: $prefix"
317echo
318echo "Detected libraries:"
319echo
320
321# Note: This only works for libs with pkg-config integration.
HÃ¥vard Espelande210c6c2012-04-22 14:31:40 +0200322for lib in "glib-2.0" "gthread-2.0" "libusb-1.0" "libzip" "libftdi" "libudev" "alsa"; do
Uwe Hermann45aed072012-01-04 00:49:21 +0100323 if `$PKG_CONFIG --exists $lib`; then
324 ver=`$PKG_CONFIG --modversion $lib`
325 answer="yes ($ver)"
326 else
327 answer="no"
328 fi
329 echo " - $lib: $answer"
330done
331
332echo
333echo "Enabled hardware drivers:"
334echo
Uwe Hermann6352d032012-05-02 19:02:03 +0200335echo " - ASIX SIGMA/SIGMA2............... $LA_ASIX_SIGMA"
Uwe Hermann45aed072012-01-04 00:49:21 +0100336echo " - ChronoVu LA8.................... $LA_CHRONOVU_LA8"
337echo " - Demo driver..................... $LA_DEMO"
Uwe Hermannb5750522012-03-21 19:45:46 +0100338echo " - fx2lafw (for FX2 LAs)........... $LA_FX2LAFW"
Bert Vermeulenca3d84c2012-07-01 22:37:15 +0200339echo " - Generic DMM..................... $HW_GENERICDMM"
Uwe Hermann45aed072012-01-04 00:49:21 +0100340echo " - Link MSO-19..................... $LA_LINK_MSO19"
341echo " - Openbench Logic Sniffer......... $LA_OLS"
Uwe Hermann8fdecce2012-05-30 22:55:03 +0200342echo " - ZEROPLUS Logic Cube............. $LA_ZEROPLUS_LOGIC_CUBE"
Bert Vermeulen3b533202012-04-23 01:05:58 +0200343echo " - Hantek DSO...................... $HW_HANTEK_DSO"
Uwe Hermann826938d2011-12-30 10:42:39 +0100344echo
345