]> sigrok.org Git - libsigrokdecode.git/blame - configure.ac
sr/srd: Move some files to their resp. dirs.
[libsigrokdecode.git] / configure.ac
CommitLineData
a190e979
UH
1##
2## This file is part of the sigrok project.
3##
4## Copyright (C) 2010 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
20AC_PREREQ(2.61)
21
22m4_define([sigrok_major_version], [0])
23m4_define([sigrok_minor_version], [2])
24m4_define([sigrok_micro_version], [0])
25m4_define([sigrok_version],
26 [sigrok_major_version.sigrok_minor_version.sigrok_micro_version])
27
28AC_INIT([sigrok], [sigrok_version], [sigrok-devel@lists.sourceforge.net],
29 [sigrok], [http://www.sigrok.org])
30AC_CONFIG_HEADER([config.h])
31AC_CONFIG_MACRO_DIR([m4])
32
33AM_INIT_AUTOMAKE([-Wall -Werror foreign std-options])
34m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
35
36AH_TOP([#ifndef SGIROK_CONFIG_H
37#define SIGROK_CONFIG_H /* To stop multiple inclusions. */])
38AH_BOTTOM([#endif /* SIGROK_CONFIG_H */])
39
40CFLAGS="-g -Wall -Wextra"
41
42# Checks for programs.
43AC_PROG_CXX
44AC_PROG_CC
45AC_PROG_CPP
46AC_PROG_INSTALL
47AC_PROG_LN_S
48
49# Initialize libtool.
50LT_INIT
51
52# Initialize pkg-config.
53# We require at least 0.22, as "Requires.private" behaviour changed there.
54PKG_PROG_PKG_CONFIG([0.22])
55
56# Library version for libsigrok.
57# Carefully read the libtool docs before updating these numbers!
58# The algorithm for determining which number to change (and how) is nontrivial!
59# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
60SIGROK_LT_CURRENT=0
61SIGROK_LT_REVISION=0
62SIGROK_LT_AGE=0
63SIGROK_LT_VERSION="$SIGROK_LT_CURRENT:$SIGROK_LT_REVISION:$SIGROK_LT_AGE"
64SIGROK_LT_LDFLAGS="-version-info $SIGROK_LT_VERSION"
65AC_SUBST(SIGROK_LT_LDFLAGS)
66
67# Library version for libsigrokdecode.
68# Carefully read the libtool docs before updating these numbers!
69# The algorithm for determining which number to change (and how) is nontrivial!
70# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
71SIGROKDECODE_LT_CURRENT=0
72SIGROKDECODE_LT_REVISION=0
73SIGROKDECODE_LT_AGE=0
74SIGROKDECODE_LT_VERSION="$SIGROKDECODE_LT_CURRENT:$SIGROKDECODE_LT_REVISION:$SIGROKDECODE_LT_AGE"
75SIGROKDECODE_LT_LDFLAGS="-version-info $SIGROKDECODE_LT_VERSION"
76AC_SUBST(SIGROKDECODE_LT_LDFLAGS)
77
78# Logic analyzer hardware support '--enable' options.
79
80# Disabled by default, unfinished.
81AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa],
82 [enable ALSA driver support [default=no]]),
83 [LA_ALSA="$enableval"],
84 [LA_ALSA=no])
85AM_CONDITIONAL(LA_ALSA, test x$LA_ALSA = xyes)
86if test "x$LA_ALSA" = "xyes"; then
87 AC_DEFINE(HAVE_LA_ALSA, 1, [ALSA driver support])
88fi
89
90AC_ARG_ENABLE(asix-sigma, AC_HELP_STRING([--enable-asix-sigma],
91 [enable ASIX Sigma support [default=yes]]),
92 [LA_ASIX_SIGMA="$enableval"],
93 [LA_ASIX_SIGMA=yes])
94AM_CONDITIONAL(LA_ASIX_SIGMA, test x$LA_ASIX_SIGMA = xyes)
95if test "x$LA_ASIX_SIGMA" = "xyes"; then
96 AC_DEFINE(HAVE_LA_ASIX_SIGMA, 1, [ASIX Sigma support])
97fi
98
99AC_ARG_ENABLE(chronovu-la8, AC_HELP_STRING([--enable-chronovu-la8],
100 [enable ChronoVu LA8 support [default=yes]]),
101 [LA_CHRONOVU_LA8="$enableval"],
102 [LA_CHRONOVU_LA8=yes])
103AM_CONDITIONAL(LA_CHRONOVU_LA8, test x$LA_CHRONOVU_LA8 = xyes)
104if test "x$LA_CHRONOVU_LA8" = "xyes"; then
105 AC_DEFINE(HAVE_LA_CHRONOVU_LA8, 1, [ChronoVu LA8 support])
106fi
107
108AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
109 [enable demo driver support [default=yes]]),
110 [LA_DEMO="$enableval"],
111 [LA_DEMO=yes])
112AM_CONDITIONAL(LA_DEMO, test x$LA_DEMO = xyes)
113if test "x$LA_DEMO" = "xyes"; then
114 AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
115fi
116
117# Disabled by default, unfinished.
118AC_ARG_ENABLE(link-mso19, AC_HELP_STRING([--enable-link-mso19],
119 [enable Link Instruments MSO-19 support [default=no]]),
120 [LA_LINK_MSO19="$enableval"],
121 [LA_LINK_MSO19=no])
122AM_CONDITIONAL(LA_LINK_MSO19, test x$LA_LINK_MSO19 = xyes)
123if test "x$LA_LINK_MSO19" = "xyes"; then
124 AC_DEFINE(HAVE_LA_LINK_MSO19, 1, [Link Instruments MSO-19 support])
125fi
126
127AC_ARG_ENABLE(ols, AC_HELP_STRING([--enable-ols],
128 [enable OpenBench Logic Sniffer (OLS) support [default=yes]]),
129 [LA_OLS="$enableval"],
130 [LA_OLS=yes])
131AM_CONDITIONAL(LA_OLS, test x$LA_OLS = xyes)
132if test "x$LA_OLS" = "xyes"; then
133 AC_DEFINE(HAVE_LA_OLS, 1, [OpenBench Logic Sniffer (OLS) support])
134fi
135
136AC_ARG_ENABLE(saleae-logic, AC_HELP_STRING([--enable-saleae-logic],
137 [enable Saleae Logic support [default=yes]]),
138 [LA_SALEAE_LOGIC="$enableval"],
139 [LA_SALEAE_LOGIC=yes])
140AM_CONDITIONAL(LA_SALEAE_LOGIC, test x$LA_SALEAE_LOGIC = xyes)
141if test "x$LA_SALEAE_LOGIC" = "xyes"; then
142 AC_DEFINE(HAVE_LA_SALEAE_LOGIC, 1, [Saleae Logic support])
143fi
144
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.
160LIBSIGROK_PKGLIBS=""
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";
170 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS gthread-2.0"])
171
172# libusb is only needed for some hardware drivers.
173if test "x$LA_SALEAE_LOGIC" != xno \
174 -o "x$LA_ASIX_SIGMA" != xno \
175 -o "x$LA_CHRONOVU_LA8" != xno \
176 -o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno; then
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";
187 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libusb-1.0"])
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";
196 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libzip"])
197
198# zlib is only needed for some hardware drivers.
199if test "x$LA_ASIX_SIGMA" != xno; then
200 PKG_CHECK_MODULES([zlib], [zlib >= 1.2.3.1],
201 [CFLAGS="$CFLAGS $zlib_CFLAGS"; LIBS="$LIBS $zlib_LIBS";
202 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS zlib"])
203fi
204
205# libftdi is only needed for some hardware drivers.
206if test "x$LA_ASIX_SIGMA" != xno \
207 -o "x$LA_CHRONOVU_LA8" != xno; then
208 PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
209 [CFLAGS="$CFLAGS $libftdi_CFLAGS";
210 LIBS="$LIBS $libftdi_LIBS";
211 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libftdi"])
212fi
213
214# libudev is only needed for some hardware drivers.
215if test "x$LA_LINK_MSO19" != xno; then
216 PKG_CHECK_MODULES([libudev], [libudev >= 151],
217 [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
218 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libudev"])
219fi
220
221# ALSA is only needed for some hardware drivers.
222if test "x$LA_ALSA" != xno; then
223 PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
224 [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
225 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS alsa"])
226fi
227
228# Python support.
229CPPFLAGS_PYTHON=""
230LDFLAGS_PYTHON=""
231case "$build" in
232*linux*)
233 # We know that Linux has 'python3-config'.
234 CPPFLAGS_PYTHON="$(python3-config --includes)"
235 LDFLAGS_PYTHON="$(python3-config --ldflags)"
236 ;;
237*darwin*)
238 # On Darwin, Macports has python3.x-config, fink has python3-config.
239 # Mac OS X (Snow Leopard) ships with 'python-config' per default, but
240 # that's Python 2.x, so not useful for us.
241 if test -x python3-config; then
242 # python3-config exists, use it.
243 CPPFLAGS_PYTHON="$(python3-config --includes)"
244 LDFLAGS_PYTHON="$(python3-config --ldflags)"
245 else
246 # No python3-config found, so try hardcoded python3.2-config.
247 CPPFLAGS_PYTHON="$(python3.2-config --includes)"
248 LDFLAGS_PYTHON="$(python3.2-config --ldflags)"
249 fi
250 ;;
251*mingw*)
252 # We currently hardcode the paths to the Python 3.2 default install
253 # location as there's no 'python-config' script on Windows, it seems.
254 CPPFLAGS_PYTHON="-I/c/Python32/include"
255 LDFLAGS_PYTHON="-L/c/Python32/libs -lpython32"
256 ;;
257*)
258 # Everything else is untested, we just hope 'python3-config' works.
259 CPPFLAGS_PYTHON="$(python3-config --includes)"
260 LDFLAGS_PYTHON="$(python3-config --ldflags)"
261 ;;
262esac
263AC_SUBST(CPPFLAGS_PYTHON)
264AC_SUBST(LDFLAGS_PYTHON)
265
266AC_SUBST(LIBSIGROK_PKGLIBS)
267
268# Checks for header files.
269# These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
270AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
271
272# Checks for typedefs, structures, and compiler characteristics.
273AC_C_INLINE
274AC_TYPE_INT8_T
275AC_TYPE_INT16_T
276AC_TYPE_INT32_T
277AC_TYPE_INT64_T
278AC_TYPE_UINT8_T
279AC_TYPE_UINT16_T
280AC_TYPE_UINT32_T
281AC_TYPE_UINT64_T
282AC_TYPE_SIZE_T
283
284# Checks for library functions.
285AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
286
287AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok/firmware")
288AC_SUBST(DECODERS_DIR, "$datadir/sigrok/decoders")
289AC_SUBST(MAKEFLAGS, '--no-print-directory')
290AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
291
292SIGROK_MAJOR_VERSION=sigrok_major_version
293SIGROK_MINOR_VERSION=sigrok_minor_version
294SIGROK_MICRO_VERSION=sigrok_micro_version
295SIGROK_VERSION=sigrok_version
296
297AC_SUBST(SIGROK_MAJOR_VERSION)
298AC_SUBST(SIGROK_MINOR_VERSION)
299AC_SUBST(SIGROK_MICRO_VERSION)
300AC_SUBST(SIGROK_VERSION)
301
302AC_DEFINE(SIGROK_MAJOR_VERSION, [sigrok_major_version],
303 [Define to the sigrok major version])
304AC_DEFINE(SIGROK_MINOR_VERSION, [sigrok_minor_version],
305 [Define to the sigrok minor version])
306AC_DEFINE(SIGROK_MICRO_VERSION, [sigrok_micro_version],
307 [Define to the sigrok micro version])
308AC_DEFINE(SIGROK_VERSION, [sigrok_version],
309 [Define to the sigrok version])
310
311AC_CONFIG_FILES([Makefile
312 contrib/Makefile
313 contrib/nsis/Makefile
314 contrib/nsis/sigrok.nsi
315 libsigrok/Makefile
316 libsigrok/sigrok.h
317 libsigrok/firmware/Makefile
318 libsigrok/hardware/Makefile
319 libsigrok/hardware/alsa/Makefile
320 libsigrok/hardware/asix-sigma/Makefile
321 libsigrok/hardware/chronovu-la8/Makefile
322 libsigrok/hardware/common/Makefile
323 libsigrok/hardware/demo/Makefile
324 libsigrok/hardware/link-mso19/Makefile
325 libsigrok/hardware/openbench-logic-sniffer/Makefile
326 libsigrok/hardware/saleae-logic/Makefile
327 libsigrok/hardware/zeroplus-logic-cube/Makefile
328 libsigrok/input/Makefile
329 libsigrok/output/Makefile
330 libsigrok/output/text/Makefile
331 libsigrok/libsigrok.pc
332 libsigrok/contrib/Makefile
333 libsigrokdecode/Makefile
334 libsigrokdecode/libsigrokdecode.pc
335 libsigrokdecode/decoders/Makefile
336 ])
337
338AC_OUTPUT
339
340echo
341echo "Building drivers:"
342echo
343echo "ASIX SIGMA...................... " $LA_ASIX_SIGMA
344echo "ChronoVu LA8.................... " $LA_CHRONOVU_LA8
345echo "Link MSO-19..................... " $LA_LINK_MSO19
346echo "Openbench Logic Sniffer......... " $LA_OLS
347echo "Saleae Logic.................... " $LA_SALEAE_LOGIC
348echo "Zeroplus Logic Cube............. " $LA_ZEROPLUS_LOGIC_CUBE
349echo
350