]> sigrok.org Git - libsigrok.git/blob - configure.ac
fluke-dmm: initial driver skeleton
[libsigrok.git] / configure.ac
1 ##
2 ## This file is part of the sigrok project.
3 ##
4 ## Copyright (C) 2010-2012 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 # libsigrok package version number (NOT the same as shared lib version!).
24 m4_define([sr_package_version_major], [0])
25 m4_define([sr_package_version_minor], [2])
26 m4_define([sr_package_version_micro], [0])
27 m4_define([sr_package_version], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro])
28
29 AC_INIT([libsigrok], [sr_package_version], [sigrok-devel@lists.sourceforge.net],
30         [libsigrok], [http://www.sigrok.org])
31 AC_CONFIG_HEADER([config.h])
32 AC_CONFIG_MACRO_DIR([autostuff])
33 AC_CONFIG_AUX_DIR([autostuff])
34
35 # We require at least automake 1.11 (needed for 'silent rules').
36 AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign std-options])
37 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
38 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
39
40 AH_TOP([#ifndef SR_CONFIG_H
41 #define SR_CONFIG_H    /* To stop multiple inclusions. */])
42 AH_BOTTOM([#endif /* SR_CONFIG_H */])
43
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.
46 CFLAGS="-g -Wall -Wextra -fvisibility=hidden"
47
48 # Checks for programs.
49 AC_PROG_CXX
50 AC_PROG_CC
51 AC_PROG_CPP
52 AC_PROG_INSTALL
53 AC_PROG_LN_S
54
55 # Initialize libtool.
56 LT_INIT
57
58 # Initialize pkg-config.
59 # We require at least 0.22, as "Requires.private" behaviour changed there.
60 PKG_PROG_PKG_CONFIG([0.22])
61
62 # Library version for libsigrok (NOT the same as the package version).
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
66 SR_LIB_VERSION_CURRENT=1
67 SR_LIB_VERSION_REVISION=0
68 SR_LIB_VERSION_AGE=0
69 SR_LIB_VERSION="$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"
70 SR_LIB_LDFLAGS="-version-info $SR_LIB_VERSION"
71 AC_SUBST(SR_LIB_VERSION_CURRENT)
72 AC_SUBST(SR_LIB_VERSION_REVISION)
73 AC_SUBST(SR_LIB_VERSION_AGE)
74 AC_SUBST(SR_LIB_VERSION)
75 AC_SUBST(SR_LIB_LDFLAGS)
76
77 # Hardware support '--enable' options.
78
79 AC_ARG_ENABLE(agilent-dmm, AC_HELP_STRING([--enable-agilent-dmm],
80               [enable Agilent DMM driver support [default=yes]]),
81               [HW_AGILENT_DMM="$enableval"],
82               [HW_AGILENT_DMM=yes])
83 AM_CONDITIONAL(HW_AGILENT_DMM, test x$HW_AGILENT_DMM = xyes)
84 if test "x$HW_AGILENT_DMM" = "xyes"; then
85         AC_DEFINE(HAVE_HW_AGILENT_DMM, 1, [Agilent DMM driver support])
86 fi
87
88 # Disabled by default, unfinished.
89 AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa],
90               [enable ALSA driver support [default=no]]),
91               [LA_ALSA="$enableval"],
92               [LA_ALSA=no])
93 AM_CONDITIONAL(LA_ALSA, test x$LA_ALSA = xyes)
94 if test "x$LA_ALSA" = "xyes"; then
95         AC_DEFINE(HAVE_LA_ALSA, 1, [ALSA driver support])
96 fi
97
98 AC_ARG_ENABLE(asix-sigma, AC_HELP_STRING([--enable-asix-sigma],
99               [enable ASIX SIGMA/SIGMA2 support [default=yes]]),
100               [LA_ASIX_SIGMA="$enableval"],
101               [LA_ASIX_SIGMA=yes])
102 AM_CONDITIONAL(LA_ASIX_SIGMA, test x$LA_ASIX_SIGMA = xyes)
103 if test "x$LA_ASIX_SIGMA" = "xyes"; then
104         AC_DEFINE(HAVE_LA_ASIX_SIGMA, 1, [ASIX SIGMA/SIGMA2 support])
105 fi
106
107 AC_ARG_ENABLE(chronovu-la8, AC_HELP_STRING([--enable-chronovu-la8],
108               [enable ChronoVu LA8 support [default=yes]]),
109               [LA_CHRONOVU_LA8="$enableval"],
110               [LA_CHRONOVU_LA8=yes])
111 AM_CONDITIONAL(LA_CHRONOVU_LA8, test x$LA_CHRONOVU_LA8 = xyes)
112 if test "x$LA_CHRONOVU_LA8" = "xyes"; then
113         AC_DEFINE(HAVE_LA_CHRONOVU_LA8, 1, [ChronoVu LA8 support])
114 fi
115
116 AC_ARG_ENABLE(fluke-dmm, AC_HELP_STRING([--enable-fluke-dmm],
117               [Enable Fluke DMM support. [default=yes]]),
118               [HW_FLUKE_DMM="$enableval"],
119               [HW_FLUKE_DMM=yes])
120 AM_CONDITIONAL(HW_FLUKE_DMM, test x$HW_FLUKE_DMM = xyes)
121 if test "x$HW_FLUKE_DMM" = "xyes"; then
122         AC_DEFINE(HAVE_HW_FLUKE_DMM, 1, [Fluke DMM support])
123 fi
124
125 AC_ARG_ENABLE(fx2lafw, AC_HELP_STRING([--enable-fx2lafw],
126               [enable fx2lafw support (for FX2 LAs). [default=yes]]),
127               [LA_FX2LAFW="$enableval"],
128               [LA_FX2LAFW=yes])
129 AM_CONDITIONAL(LA_FX2LAFW, test x$LA_FX2LAFW = xyes)
130 if test "x$LA_FX2LAFW" = "xyes"; then
131         AC_DEFINE(HAVE_LA_FX2LAFW, 1, [fx2lafw support])
132 fi
133
134 AC_ARG_ENABLE(genericdmm, AC_HELP_STRING([--enable-genericdmm],
135               [enable genericdmm support (for most DMMs). [default=yes]]),
136               [HW_GENERICDMM="$enableval"],
137               [HW_GENERICDMM=yes])
138 AM_CONDITIONAL(HW_GENERICDMM, test x$HW_GENERICDMM = xyes)
139 if test "x$HW_GENERICDMM" = "xyes"; then
140         AC_DEFINE(HAVE_HW_GENERICDMM, 1, [Generic DMM support])
141 fi
142
143 AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
144               [enable demo driver support [default=yes]]),
145               [LA_DEMO="$enableval"],
146               [LA_DEMO=yes])
147 AM_CONDITIONAL(LA_DEMO, test x$LA_DEMO = xyes)
148 if test "x$LA_DEMO" = "xyes"; then
149         AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
150 fi
151
152 # Disabled by default, unfinished.
153 AC_ARG_ENABLE(link-mso19, AC_HELP_STRING([--enable-link-mso19],
154               [enable Link Instruments MSO-19 support [default=no]]),
155               [LA_LINK_MSO19="$enableval"],
156               [LA_LINK_MSO19=no])
157 AM_CONDITIONAL(LA_LINK_MSO19, test x$LA_LINK_MSO19 = xyes)
158 if test "x$LA_LINK_MSO19" = "xyes"; then
159         AC_DEFINE(HAVE_LA_LINK_MSO19, 1, [Link Instruments MSO-19 support])
160 fi
161
162 AC_ARG_ENABLE(ols, AC_HELP_STRING([--enable-ols],
163               [enable OpenBench Logic Sniffer (OLS) support [default=yes]]),
164               [LA_OLS="$enableval"],
165               [LA_OLS=yes])
166 AM_CONDITIONAL(LA_OLS, test x$LA_OLS = xyes)
167 if test "x$LA_OLS" = "xyes"; then
168         AC_DEFINE(HAVE_LA_OLS, 1, [OpenBench Logic Sniffer (OLS) support])
169 fi
170
171 AC_ARG_ENABLE(zeroplus-logic-cube,
172               AC_HELP_STRING([--enable-zeroplus-logic-cube],
173               [enable ZEROPLUS Logic Cube support [default=yes]]),
174               [LA_ZEROPLUS_LOGIC_CUBE="$enableval"],
175               [LA_ZEROPLUS_LOGIC_CUBE=yes])
176 AM_CONDITIONAL(LA_ZEROPLUS_LOGIC_CUBE, test x$LA_ZEROPLUS_LOGIC_CUBE = xyes)
177 if test "x$LA_ZEROPLUS_LOGIC_CUBE" = "xyes"; then
178         AC_DEFINE(HAVE_LA_ZEROPLUS_LOGIC_CUBE, 1, [ZEROPLUS Logic Cube support])
179 fi
180
181 AC_ARG_ENABLE(hantek-dso,
182               AC_HELP_STRING([--enable-hantek-dso],
183               [enable Hantek DSO support [default=yes]]),
184               [HW_HANTEK_DSO="$enableval"],
185               [HW_HANTEK_DSO=yes])
186 AM_CONDITIONAL(HW_HANTEK_DSO, test x$HW_HANTEK_DSO = xyes)
187 if test "x$HW_HANTEK_DSO" = "xyes"; then
188         AC_DEFINE(HAVE_HW_HANTEK_DSO, 1, [Hantek DSO support])
189 fi
190
191 # Checks for libraries.
192
193 # This variable collects the pkg-config names of all detected libs.
194 # It is then used to construct the "Requires.private:" field in the
195 # libsigrok.pc file.
196 SR_PKGLIBS=""
197
198 # libglib-2.0 is always needed.
199 # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
200 AM_PATH_GLIB_2_0([2.28.0],
201         [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
202
203 # libgthread-2.0 is always needed (e.g. for the demo hardware driver).
204 PKG_CHECK_MODULES([gthread], [gthread-2.0 >= 2.22.0],
205         [CFLAGS="$CFLAGS $gthread_CFLAGS"; LIBS="$LIBS $gthread_LIBS";
206         SR_PKGLIBS="$SR_PKGLIBS gthread-2.0"])
207
208 # libusb is only needed for some hardware drivers.
209 if test "x$LA_ASIX_SIGMA" != xno \
210    -o "x$LA_CHRONOVU_LA8" != xno \
211    -o "x$LA_FX2LAFW" != xno \
212    -o "x$HW_HANTEK_DSO" != xno \
213    -o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno; then
214         case "$build" in
215         *freebsd*)
216                 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
217                 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
218                         [Specifies whether we have a libusb.h header.])
219                 ;;
220         *)
221                 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.5],
222                         [CFLAGS="$CFLAGS $libusb_CFLAGS";
223                         LIBS="$LIBS $libusb_LIBS";
224                         SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"])
225                 AC_CHECK_LIB(usb-1.0, libusb_init)
226                 ;;
227         esac
228 fi
229
230 # libzip is always needed.
231 PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
232         [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
233         SR_PKGLIBS="$SR_PKGLIBS libzip"])
234
235 # libftdi is only needed for some hardware drivers.
236 if test "x$LA_ASIX_SIGMA" != xno \
237      -o "x$LA_CHRONOVU_LA8" != xno; then
238         PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
239                 [CFLAGS="$CFLAGS $libftdi_CFLAGS";
240                 LIBS="$LIBS $libftdi_LIBS";
241                 SR_PKGLIBS="$SR_PKGLIBS libftdi"])
242 fi
243
244 # libudev is only needed for some hardware drivers.
245 if test "x$LA_LINK_MSO19" != xno; then
246         PKG_CHECK_MODULES([libudev], [libudev >= 151],
247                 [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
248                 SR_PKGLIBS="$SR_PKGLIBS libudev"])
249 fi
250
251 # ALSA is only needed for some hardware drivers.
252 if test "x$LA_ALSA" != xno; then
253         PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
254                 [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
255                 SR_PKGLIBS="$SR_PKGLIBS alsa"])
256 fi
257
258 # EZUSB FX2 firmware helpers only needed for some hardware drivers
259 AM_CONDITIONAL(NEED_EZUSB, \
260         test "x$LA_FX2LAFW" != xno \
261         -o "x$HW_HANTEK_DSO" != xno \
262 )
263
264 # Serial port helpers only needed for some hardware drivers
265 AM_CONDITIONAL(NEED_SERIAL, \
266         test "x$LA_OLS" != xno \
267         -o "x$HW_AGILENT_DMM" != xno \
268         -o "x$HW_GENERICDMM" != xno \
269 )
270
271 AC_SUBST(SR_PKGLIBS)
272
273 # Checks for header files.
274 # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
275 AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
276
277 # Checks for typedefs, structures, and compiler characteristics.
278 AC_C_INLINE
279 AC_TYPE_INT8_T
280 AC_TYPE_INT16_T
281 AC_TYPE_INT32_T
282 AC_TYPE_INT64_T
283 AC_TYPE_UINT8_T
284 AC_TYPE_UINT16_T
285 AC_TYPE_UINT32_T
286 AC_TYPE_UINT64_T
287 AC_TYPE_SIZE_T
288
289 # Checks for library functions.
290 AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
291
292 AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
293 AC_SUBST(MAKEFLAGS, '--no-print-directory')
294 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
295
296 SR_PACKAGE_VERSION_MAJOR=sr_package_version_major
297 SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
298 SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
299 SR_PACKAGE_VERSION=sr_package_version
300
301 AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
302 AC_SUBST(SR_PACKAGE_VERSION_MINOR)
303 AC_SUBST(SR_PACKAGE_VERSION_MICRO)
304 AC_SUBST(SR_PACKAGE_VERSION)
305
306 AC_CONFIG_FILES([Makefile
307                  version.h
308                  hardware/Makefile
309                  hardware/agilent-dmm/Makefile
310                  hardware/alsa/Makefile
311                  hardware/asix-sigma/Makefile
312                  hardware/chronovu-la8/Makefile
313                  hardware/common/Makefile
314                  hardware/demo/Makefile
315                  hardware/fluke-dmm/Makefile
316                  hardware/fx2lafw/Makefile
317                  hardware/genericdmm/Makefile
318                  hardware/link-mso19/Makefile
319                  hardware/openbench-logic-sniffer/Makefile
320                  hardware/zeroplus-logic-cube/Makefile
321                  hardware/hantek-dso/Makefile
322                  input/Makefile
323                  output/Makefile
324                  output/text/Makefile
325                  libsigrok.pc
326                  contrib/Makefile
327                 ])
328
329 AC_OUTPUT
330
331 echo
332 echo "libsigrok configuration summary:"
333 echo
334 echo "  - Package version (major.minor.micro):    $SR_PACKAGE_VERSION"
335 echo "  - Library version (current:revision:age): $SR_LIB_VERSION"
336 echo "  - Prefix: $prefix"
337 echo
338 echo "Detected libraries:"
339 echo
340
341 # Note: This only works for libs with pkg-config integration.
342 for lib in "glib-2.0" "gthread-2.0" "libusb-1.0" "libzip" "libftdi" "libudev" "alsa"; do
343         if `$PKG_CONFIG --exists $lib`; then
344                 ver=`$PKG_CONFIG --modversion $lib`
345                 answer="yes ($ver)"
346         else
347                 answer="no"
348         fi
349         echo "  - $lib: $answer"
350 done
351
352 echo
353 echo "Enabled hardware drivers:"
354 echo
355 echo "  - Agilent DMM..................... $HW_AGILENT_DMM"
356 echo "  - ASIX SIGMA/SIGMA2............... $LA_ASIX_SIGMA"
357 echo "  - ChronoVu LA8.................... $LA_CHRONOVU_LA8"
358 echo "  - Demo driver..................... $LA_DEMO"
359 echo "  - Fluke DMM....................... $HW_FLUKE_DMM"
360 echo "  - fx2lafw (for FX2 LAs)........... $LA_FX2LAFW"
361 echo "  - Generic DMM..................... $HW_GENERICDMM"
362 echo "  - Link MSO-19..................... $LA_LINK_MSO19"
363 echo "  - Openbench Logic Sniffer......... $LA_OLS"
364 echo "  - ZEROPLUS Logic Cube............. $LA_ZEROPLUS_LOGIC_CUBE"
365 echo "  - Hantek DSO...................... $HW_HANTEK_DSO"
366 echo
367