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