]> sigrok.org Git - libsigrok.git/blob - configure.ac
Put most autotools files into autostuff/.
[libsigrok.git] / configure.ac
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
20 AC_PREREQ(2.61)
21
22 # TODO: Should be libsigrok, no sigrok.
23 m4_define([sigrok_major_version], [0])
24 m4_define([sigrok_minor_version], [2])
25 m4_define([sigrok_micro_version], [0])
26 m4_define([sigrok_version],
27           [sigrok_major_version.sigrok_minor_version.sigrok_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 AM_INIT_AUTOMAKE([-Wall -Werror foreign std-options])
36 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
37
38 AH_TOP([#ifndef LIBSIGROK_CONFIG_H
39 #define LIBSIGROK_CONFIG_H    /* To stop multiple inclusions. */])
40 AH_BOTTOM([#endif /* LIBSIGROK_CONFIG_H */])
41
42 CFLAGS="-g -Wall -Wextra"
43
44 # Checks for programs.
45 AC_PROG_CXX
46 AC_PROG_CC
47 AC_PROG_CPP
48 AC_PROG_INSTALL
49 AC_PROG_LN_S
50
51 # Initialize libtool.
52 LT_INIT
53
54 # Initialize pkg-config.
55 # We require at least 0.22, as "Requires.private" behaviour changed there.
56 PKG_PROG_PKG_CONFIG([0.22])
57
58 # Library version for libsigrok.
59 # Carefully read the libtool docs before updating these numbers!
60 # The algorithm for determining which number to change (and how) is nontrivial!
61 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
62 SIGROK_LT_CURRENT=0
63 SIGROK_LT_REVISION=0
64 SIGROK_LT_AGE=0
65 SIGROK_LT_VERSION="$SIGROK_LT_CURRENT:$SIGROK_LT_REVISION:$SIGROK_LT_AGE"
66 SIGROK_LT_LDFLAGS="-version-info $SIGROK_LT_VERSION"
67 AC_SUBST(SIGROK_LT_LDFLAGS)
68
69 # Logic analyzer hardware support '--enable' options.
70
71 # Disabled by default, unfinished.
72 AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa],
73               [enable ALSA driver support [default=no]]),
74               [LA_ALSA="$enableval"],
75               [LA_ALSA=no])
76 AM_CONDITIONAL(LA_ALSA, test x$LA_ALSA = xyes)
77 if test "x$LA_ALSA" = "xyes"; then
78         AC_DEFINE(HAVE_LA_ALSA, 1, [ALSA driver support])
79 fi
80
81 AC_ARG_ENABLE(asix-sigma, AC_HELP_STRING([--enable-asix-sigma],
82               [enable ASIX Sigma support [default=yes]]),
83               [LA_ASIX_SIGMA="$enableval"],
84               [LA_ASIX_SIGMA=yes])
85 AM_CONDITIONAL(LA_ASIX_SIGMA, test x$LA_ASIX_SIGMA = xyes)
86 if test "x$LA_ASIX_SIGMA" = "xyes"; then
87         AC_DEFINE(HAVE_LA_ASIX_SIGMA, 1, [ASIX Sigma support])
88 fi
89
90 AC_ARG_ENABLE(chronovu-la8, AC_HELP_STRING([--enable-chronovu-la8],
91               [enable ChronoVu LA8 support [default=yes]]),
92               [LA_CHRONOVU_LA8="$enableval"],
93               [LA_CHRONOVU_LA8=yes])
94 AM_CONDITIONAL(LA_CHRONOVU_LA8, test x$LA_CHRONOVU_LA8 = xyes)
95 if test "x$LA_CHRONOVU_LA8" = "xyes"; then
96         AC_DEFINE(HAVE_LA_CHRONOVU_LA8, 1, [ChronoVu LA8 support])
97 fi
98
99 AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
100               [enable demo driver support [default=yes]]),
101               [LA_DEMO="$enableval"],
102               [LA_DEMO=yes])
103 AM_CONDITIONAL(LA_DEMO, test x$LA_DEMO = xyes)
104 if test "x$LA_DEMO" = "xyes"; then
105         AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
106 fi
107
108 # Disabled by default, unfinished.
109 AC_ARG_ENABLE(link-mso19, AC_HELP_STRING([--enable-link-mso19],
110               [enable Link Instruments MSO-19 support [default=no]]),
111               [LA_LINK_MSO19="$enableval"],
112               [LA_LINK_MSO19=no])
113 AM_CONDITIONAL(LA_LINK_MSO19, test x$LA_LINK_MSO19 = xyes)
114 if test "x$LA_LINK_MSO19" = "xyes"; then
115         AC_DEFINE(HAVE_LA_LINK_MSO19, 1, [Link Instruments MSO-19 support])
116 fi
117
118 AC_ARG_ENABLE(ols, AC_HELP_STRING([--enable-ols],
119               [enable OpenBench Logic Sniffer (OLS) support [default=yes]]),
120               [LA_OLS="$enableval"],
121               [LA_OLS=yes])
122 AM_CONDITIONAL(LA_OLS, test x$LA_OLS = xyes)
123 if test "x$LA_OLS" = "xyes"; then
124         AC_DEFINE(HAVE_LA_OLS, 1, [OpenBench Logic Sniffer (OLS) support])
125 fi
126
127 AC_ARG_ENABLE(saleae-logic, AC_HELP_STRING([--enable-saleae-logic],
128               [enable Saleae Logic support [default=yes]]),
129               [LA_SALEAE_LOGIC="$enableval"],
130               [LA_SALEAE_LOGIC=yes])
131 AM_CONDITIONAL(LA_SALEAE_LOGIC, test x$LA_SALEAE_LOGIC = xyes)
132 if test "x$LA_SALEAE_LOGIC" = "xyes"; then
133         AC_DEFINE(HAVE_LA_SALEAE_LOGIC, 1, [Saleae Logic support])
134 fi
135
136 AC_ARG_ENABLE(zeroplus-logic-cube,
137               AC_HELP_STRING([--enable-zeroplus-logic-cube],
138               [enable Zeroplus Logic Cube support [default=yes]]),
139               [LA_ZEROPLUS_LOGIC_CUBE="$enableval"],
140               [LA_ZEROPLUS_LOGIC_CUBE=yes])
141 AM_CONDITIONAL(LA_ZEROPLUS_LOGIC_CUBE, test x$LA_ZEROPLUS_LOGIC_CUBE = xyes)
142 if test "x$LA_ZEROPLUS_LOGIC_CUBE" = "xyes"; then
143         AC_DEFINE(HAVE_LA_ZEROPLUS_LOGIC_CUBE, 1, [Zeroplus Logic Cube support])
144 fi
145
146 # Checks for libraries.
147
148 # This variable collects the pkg-config names of all detected libs.
149 # It is then used to construct the "Requires.private:" field in the
150 # libsigrok.pc file.
151 LIBSIGROK_PKGLIBS=""
152
153 # libglib-2.0 is always needed.
154 # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
155 AM_PATH_GLIB_2_0([2.22.0],
156         [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
157
158 # libgthread-2.0 is always needed (e.g. for the demo hardware driver).
159 PKG_CHECK_MODULES([gthread], [gthread-2.0 >= 2.22.0],
160         [CFLAGS="$CFLAGS $gthread_CFLAGS"; LIBS="$LIBS $gthread_LIBS";
161         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS gthread-2.0"])
162
163 # libusb is only needed for some hardware drivers.
164 if test "x$LA_SALEAE_LOGIC" != xno \
165    -o "x$LA_ASIX_SIGMA" != xno \
166    -o "x$LA_CHRONOVU_LA8" != xno \
167    -o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno; then
168         case "$build" in
169         *freebsd*)
170                 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
171                 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
172                         [Specifies whether we have a libusb.h header.])
173                 ;;
174         *)
175                 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.5],
176                         [CFLAGS="$CFLAGS $libusb_CFLAGS";
177                         LIBS="$LIBS $libusb_LIBS";
178                         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libusb-1.0"])
179                 AC_CHECK_LIB(usb-1.0, libusb_init)
180                 ;;
181         esac
182 fi
183
184 # libzip is always needed.
185 PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
186         [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
187         LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libzip"])
188
189 # zlib is only needed for some hardware drivers.
190 if test "x$LA_ASIX_SIGMA" != xno; then
191         PKG_CHECK_MODULES([zlib], [zlib >= 1.2.3.1],
192                 [CFLAGS="$CFLAGS $zlib_CFLAGS"; LIBS="$LIBS $zlib_LIBS";
193                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS zlib"])
194 fi
195
196 # libftdi is only needed for some hardware drivers.
197 if test "x$LA_ASIX_SIGMA" != xno \
198      -o "x$LA_CHRONOVU_LA8" != xno; then
199         PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
200                 [CFLAGS="$CFLAGS $libftdi_CFLAGS";
201                 LIBS="$LIBS $libftdi_LIBS";
202                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libftdi"])
203 fi
204
205 # libudev is only needed for some hardware drivers.
206 if test "x$LA_LINK_MSO19" != xno; then
207         PKG_CHECK_MODULES([libudev], [libudev >= 151],
208                 [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
209                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS libudev"])
210 fi
211
212 # ALSA is only needed for some hardware drivers.
213 if test "x$LA_ALSA" != xno; then
214         PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
215                 [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
216                 LIBSIGROK_PKGLIBS="$LIBSIGROK_PKGLIBS alsa"])
217 fi
218
219 AC_SUBST(LIBSIGROK_PKGLIBS)
220
221 # Checks for header files.
222 # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
223 AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
224
225 # Checks for typedefs, structures, and compiler characteristics.
226 AC_C_INLINE
227 AC_TYPE_INT8_T
228 AC_TYPE_INT16_T
229 AC_TYPE_INT32_T
230 AC_TYPE_INT64_T
231 AC_TYPE_UINT8_T
232 AC_TYPE_UINT16_T
233 AC_TYPE_UINT32_T
234 AC_TYPE_UINT64_T
235 AC_TYPE_SIZE_T
236
237 # Checks for library functions.
238 AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
239
240 AC_SUBST(FIRMWARE_DIR, "$datadir/libsigrok/firmware")
241 AC_SUBST(MAKEFLAGS, '--no-print-directory')
242 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
243
244 SIGROK_MAJOR_VERSION=sigrok_major_version
245 SIGROK_MINOR_VERSION=sigrok_minor_version
246 SIGROK_MICRO_VERSION=sigrok_micro_version
247 SIGROK_VERSION=sigrok_version
248
249 AC_SUBST(SIGROK_MAJOR_VERSION)
250 AC_SUBST(SIGROK_MINOR_VERSION)
251 AC_SUBST(SIGROK_MICRO_VERSION)
252 AC_SUBST(SIGROK_VERSION)
253
254 AC_DEFINE(SIGROK_MAJOR_VERSION, [sigrok_major_version],
255           [Define to the sigrok major version])
256 AC_DEFINE(SIGROK_MINOR_VERSION, [sigrok_minor_version],
257           [Define to the sigrok minor version])
258 AC_DEFINE(SIGROK_MICRO_VERSION, [sigrok_micro_version],
259           [Define to the sigrok micro version])
260 AC_DEFINE(SIGROK_VERSION, [sigrok_version],
261           [Define to the sigrok version])
262
263 AC_CONFIG_FILES([Makefile
264                  sigrok.h
265                  firmware/Makefile
266                  hardware/Makefile
267                  hardware/alsa/Makefile
268                  hardware/asix-sigma/Makefile
269                  hardware/chronovu-la8/Makefile
270                  hardware/common/Makefile
271                  hardware/demo/Makefile
272                  hardware/link-mso19/Makefile
273                  hardware/openbench-logic-sniffer/Makefile
274                  hardware/saleae-logic/Makefile
275                  hardware/zeroplus-logic-cube/Makefile
276                  input/Makefile
277                  output/Makefile
278                  output/text/Makefile
279                  libsigrok.pc
280                  contrib/Makefile
281                 ])
282
283 AC_OUTPUT
284
285 echo
286 echo "Building drivers:"
287 echo
288 echo "ASIX SIGMA...................... " $LA_ASIX_SIGMA
289 echo "ChronoVu LA8.................... " $LA_CHRONOVU_LA8
290 echo "Link MSO-19..................... " $LA_LINK_MSO19
291 echo "Openbench Logic Sniffer......... " $LA_OLS
292 echo "Saleae Logic.................... " $LA_SALEAE_LOGIC
293 echo "Zeroplus Logic Cube............. " $LA_ZEROPLUS_LOGIC_CUBE
294 echo
295