]> sigrok.org Git - libsigrok.git/blob - configure.ac
sr: Various fixes in the udev file.
[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([libsigrok_major_version], [0])
25 m4_define([libsigrok_minor_version], [1])
26 m4_define([libsigrok_micro_version], [0])
27 m4_define([libsigrok_version], [libsigrok_major_version.libsigrok_minor_version.libsigrok_micro_version])
28
29 AC_INIT([libsigrok], [libsigrok_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
39 AH_TOP([#ifndef LIBSIGROK_CONFIG_H
40 #define LIBSIGROK_CONFIG_H    /* To stop multiple inclusions. */])
41 AH_BOTTOM([#endif /* LIBSIGROK_CONFIG_H */])
42
43 # Enable more compiler warnings via -Wall and -Wextra. Add -fvisibility=hidden
44 # and enforce use of SR_API to explicitly mark all public API functions.
45 CFLAGS="-g -Wall -Wextra -fvisibility=hidden"
46
47 # Checks for programs.
48 AC_PROG_CXX
49 AC_PROG_CC
50 AC_PROG_CPP
51 AC_PROG_INSTALL
52 AC_PROG_LN_S
53
54 # Initialize libtool.
55 LT_INIT
56
57 # Initialize pkg-config.
58 # We require at least 0.22, as "Requires.private" behaviour changed there.
59 PKG_PROG_PKG_CONFIG([0.22])
60
61 # Library version for libsigrok (NOT the same as the package version).
62 # Carefully read the libtool docs before updating these numbers!
63 # The algorithm for determining which number to change (and how) is nontrivial!
64 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
65 LIBSIGROK_LT_CURRENT=0
66 LIBSIGROK_LT_REVISION=0
67 LIBSIGROK_LT_AGE=0
68 LIBSIGROK_LT_VERSION="$LIBSIGROK_LT_CURRENT:$LIBSIGROK_LT_REVISION:$LIBSIGROK_LT_AGE"
69 LIBSIGROK_LT_LDFLAGS="-version-info $LIBSIGROK_LT_VERSION"
70 AC_SUBST(LIBSIGROK_LT_LDFLAGS)
71
72 # Logic analyzer hardware support '--enable' options.
73
74 # Disabled by default, unfinished.
75 AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa],
76               [enable ALSA driver support [default=no]]),
77               [LA_ALSA="$enableval"],
78               [LA_ALSA=no])
79 AM_CONDITIONAL(LA_ALSA, test x$LA_ALSA = xyes)
80 if test "x$LA_ALSA" = "xyes"; then
81         AC_DEFINE(HAVE_LA_ALSA, 1, [ALSA driver support])
82 fi
83
84 AC_ARG_ENABLE(asix-sigma, AC_HELP_STRING([--enable-asix-sigma],
85               [enable ASIX Sigma support [default=yes]]),
86               [LA_ASIX_SIGMA="$enableval"],
87               [LA_ASIX_SIGMA=yes])
88 AM_CONDITIONAL(LA_ASIX_SIGMA, test x$LA_ASIX_SIGMA = xyes)
89 if test "x$LA_ASIX_SIGMA" = "xyes"; then
90         AC_DEFINE(HAVE_LA_ASIX_SIGMA, 1, [ASIX Sigma support])
91 fi
92
93 AC_ARG_ENABLE(chronovu-la8, AC_HELP_STRING([--enable-chronovu-la8],
94               [enable ChronoVu LA8 support [default=yes]]),
95               [LA_CHRONOVU_LA8="$enableval"],
96               [LA_CHRONOVU_LA8=yes])
97 AM_CONDITIONAL(LA_CHRONOVU_LA8, test x$LA_CHRONOVU_LA8 = xyes)
98 if test "x$LA_CHRONOVU_LA8" = "xyes"; then
99         AC_DEFINE(HAVE_LA_CHRONOVU_LA8, 1, [ChronoVu LA8 support])
100 fi
101
102 AC_ARG_ENABLE(fx2lafw, AC_HELP_STRING([--enable-fx2lafw],
103               [enable fx2lafw support (for FX2 LAs). [default=yes]]),
104               [LA_FX2LAFW="$enableval"],
105               [LA_FX2LAFW=yes])
106 AM_CONDITIONAL(LA_FX2LAFW, test x$LA_FX2LAFW = xyes)
107 if test "x$LA_FX2LAFW" = "xyes"; then
108         AC_DEFINE(HAVE_LA_FX2LAFW, 1, [fx2lafw support])
109 fi
110
111 AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
112               [enable demo driver support [default=yes]]),
113               [LA_DEMO="$enableval"],
114               [LA_DEMO=yes])
115 AM_CONDITIONAL(LA_DEMO, test x$LA_DEMO = xyes)
116 if test "x$LA_DEMO" = "xyes"; then
117         AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
118 fi
119
120 # Disabled by default, unfinished.
121 AC_ARG_ENABLE(link-mso19, AC_HELP_STRING([--enable-link-mso19],
122               [enable Link Instruments MSO-19 support [default=no]]),
123               [LA_LINK_MSO19="$enableval"],
124               [LA_LINK_MSO19=no])
125 AM_CONDITIONAL(LA_LINK_MSO19, test x$LA_LINK_MSO19 = xyes)
126 if test "x$LA_LINK_MSO19" = "xyes"; then
127         AC_DEFINE(HAVE_LA_LINK_MSO19, 1, [Link Instruments MSO-19 support])
128 fi
129
130 AC_ARG_ENABLE(ols, AC_HELP_STRING([--enable-ols],
131               [enable OpenBench Logic Sniffer (OLS) support [default=yes]]),
132               [LA_OLS="$enableval"],
133               [LA_OLS=yes])
134 AM_CONDITIONAL(LA_OLS, test x$LA_OLS = xyes)
135 if test "x$LA_OLS" = "xyes"; then
136         AC_DEFINE(HAVE_LA_OLS, 1, [OpenBench Logic Sniffer (OLS) support])
137 fi
138
139 AC_ARG_ENABLE(saleae-logic, AC_HELP_STRING([--enable-saleae-logic],
140               [enable Saleae Logic support [default=yes]]),
141               [LA_SALEAE_LOGIC="$enableval"],
142               [LA_SALEAE_LOGIC=yes])
143 AM_CONDITIONAL(LA_SALEAE_LOGIC, test x$LA_SALEAE_LOGIC = xyes)
144 if test "x$LA_SALEAE_LOGIC" = "xyes"; then
145         AC_DEFINE(HAVE_LA_SALEAE_LOGIC, 1, [Saleae Logic support])
146 fi
147
148 AC_ARG_ENABLE(zeroplus-logic-cube,
149               AC_HELP_STRING([--enable-zeroplus-logic-cube],
150               [enable Zeroplus Logic Cube support [default=yes]]),
151               [LA_ZEROPLUS_LOGIC_CUBE="$enableval"],
152               [LA_ZEROPLUS_LOGIC_CUBE=yes])
153 AM_CONDITIONAL(LA_ZEROPLUS_LOGIC_CUBE, test x$LA_ZEROPLUS_LOGIC_CUBE = xyes)
154 if test "x$LA_ZEROPLUS_LOGIC_CUBE" = "xyes"; then
155         AC_DEFINE(HAVE_LA_ZEROPLUS_LOGIC_CUBE, 1, [Zeroplus Logic Cube support])
156 fi
157
158 # Checks for libraries.
159
160 # This variable collects the pkg-config names of all detected libs.
161 # It is then used to construct the "Requires.private:" field in the
162 # libsigrok.pc file.
163 LIBSIGROK_PKGLIBS=""
164
165 # libglib-2.0 is always needed.
166 # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
167 AM_PATH_GLIB_2_0([2.22.0],
168         [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
169
170 # libgthread-2.0 is always needed (e.g. for the demo hardware driver).
171 PKG_CHECK_MODULES([gthread], [gthread-2.0 >= 2.22.0],
172         [CFLAGS="$CFLAGS $gthread_CFLAGS"; LIBS="$LIBS $gthread_LIBS";
173         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS gthread-2.0"])
174
175 # libusb is only needed for some hardware drivers.
176 if test "x$LA_SALEAE_LOGIC" != xno \
177    -o "x$LA_ASIX_SIGMA" != xno \
178    -o "x$LA_CHRONOVU_LA8" != xno \
179    -o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno \
180    -o "x$LA_FX2LAFW" != xno; then
181         case "$build" in
182         *freebsd*)
183                 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
184                 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
185                         [Specifies whether we have a libusb.h header.])
186                 ;;
187         *)
188                 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.5],
189                         [CFLAGS="$CFLAGS $libusb_CFLAGS";
190                         LIBS="$LIBS $libusb_LIBS";
191                         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libusb-1.0"])
192                 AC_CHECK_LIB(usb-1.0, libusb_init)
193                 ;;
194         esac
195 fi
196
197 # libzip is always needed.
198 PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
199         [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
200         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libzip"])
201
202 # zlib is only needed for some hardware drivers.
203 if test "x$LA_ASIX_SIGMA" != xno; then
204         case "$build" in
205         *freebsd*)
206                 # FreeBSD has zlib, but no pkg-config file for it.
207                 # Check manually, and do NOT add it to LIBSIGROK_PKGLIBS.
208                 AC_CHECK_LIB(z, uncompress)
209                 ;;
210         *)
211                 PKG_CHECK_MODULES([zlib], [zlib >= 1.2.3.1],
212                         [CFLAGS="$CFLAGS $zlib_CFLAGS"; LIBS="$LIBS $zlib_LIBS";
213                         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS zlib"])
214                 ;;
215         esac
216 fi
217
218 # libftdi is only needed for some hardware drivers.
219 if 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";
224                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libftdi"])
225 fi
226
227 # libudev is only needed for some hardware drivers.
228 if test "x$LA_LINK_MSO19" != xno; then
229         PKG_CHECK_MODULES([libudev], [libudev >= 151],
230                 [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
231                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libudev"])
232 fi
233
234 # ALSA is only needed for some hardware drivers.
235 if test "x$LA_ALSA" != xno; then
236         PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
237                 [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
238                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS alsa"])
239 fi
240
241 AC_SUBST(LIBSIGROK_PKGLIBS)
242
243 # Checks for header files.
244 # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
245 AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
246
247 # Checks for typedefs, structures, and compiler characteristics.
248 AC_C_INLINE
249 AC_TYPE_INT8_T
250 AC_TYPE_INT16_T
251 AC_TYPE_INT32_T
252 AC_TYPE_INT64_T
253 AC_TYPE_UINT8_T
254 AC_TYPE_UINT16_T
255 AC_TYPE_UINT32_T
256 AC_TYPE_UINT64_T
257 AC_TYPE_SIZE_T
258
259 # Checks for library functions.
260 AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
261
262 AC_SUBST(FIRMWARE_DIR, "$datadir/libsigrok/firmware")
263 AC_SUBST(MAKEFLAGS, '--no-print-directory')
264 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
265
266 LIBSIGROK_MAJOR_VERSION=libsigrok_major_version
267 LIBSIGROK_MINOR_VERSION=libsigrok_minor_version
268 LIBSIGROK_MICRO_VERSION=libsigrok_micro_version
269 LIBSIGROK_VERSION=libsigrok_version
270
271 AC_SUBST(LIBSIGROK_MAJOR_VERSION)
272 AC_SUBST(LIBSIGROK_MINOR_VERSION)
273 AC_SUBST(LIBSIGROK_MICRO_VERSION)
274 AC_SUBST(LIBSIGROK_VERSION)
275
276 AC_DEFINE(LIBSIGROK_MAJOR_VERSION, [libsigrok_major_version],
277           [Define to the libsigrok major package version])
278 AC_DEFINE(LIBSIGROK_MINOR_VERSION, [libsigrok_minor_version],
279           [Define to the libsigrok minor package version])
280 AC_DEFINE(LIBSIGROK_MICRO_VERSION, [libsigrok_micro_version],
281           [Define to the libsigrok micro package version])
282 AC_DEFINE(LIBSIGROK_VERSION, [libsigrok_version],
283           [Define to the libsigrok package version])
284
285 AC_CONFIG_FILES([Makefile
286                  firmware/Makefile
287                  hardware/Makefile
288                  hardware/alsa/Makefile
289                  hardware/asix-sigma/Makefile
290                  hardware/chronovu-la8/Makefile
291                  hardware/common/Makefile
292                  hardware/demo/Makefile
293                  hardware/fx2lafw/Makefile
294                  hardware/link-mso19/Makefile
295                  hardware/openbench-logic-sniffer/Makefile
296                  hardware/saleae-logic/Makefile
297                  hardware/zeroplus-logic-cube/Makefile
298                  input/Makefile
299                  output/Makefile
300                  output/text/Makefile
301                  libsigrok.pc
302                  contrib/Makefile
303                 ])
304
305 AC_OUTPUT
306
307 echo
308 echo "libsigrok configuration summary:"
309 echo
310 echo "  - Package version (major.minor.micro):    $LIBSIGROK_VERSION"
311 echo "  - Library version (current:revision:age): $LIBSIGROK_LT_VERSION"
312 echo "  - Prefix: $prefix"
313 echo
314 echo "Detected libraries:"
315 echo
316
317 # Note: This only works for libs with pkg-config integration.
318 for lib in "glib-2.0" "gthread-2.0" "libusb-1.0" "libzip" "zlib" "libftdi" "libudev" "alsa"; do
319         if `$PKG_CONFIG --exists $lib`; then
320                 ver=`$PKG_CONFIG --modversion $lib`
321                 answer="yes ($ver)"
322         else
323                 answer="no"
324         fi
325         echo "  - $lib: $answer"
326 done
327
328 echo
329 echo "Enabled hardware drivers:"
330 echo
331 echo "  - ASIX SIGMA...................... $LA_ASIX_SIGMA"
332 echo "  - ChronoVu LA8.................... $LA_CHRONOVU_LA8"
333 echo "  - Demo driver..................... $LA_DEMO"
334 echo "  - fx2lafw (for FX2 LAs)........... $LA_FX2LAFW"
335 echo "  - Link MSO-19..................... $LA_LINK_MSO19"
336 echo "  - Openbench Logic Sniffer......... $LA_OLS"
337 echo "  - Saleae Logic.................... $LA_SALEAE_LOGIC"
338 echo "  - Zeroplus Logic Cube............. $LA_ZEROPLUS_LOGIC_CUBE"
339 echo
340