2 ## This file is part of the libsigrok project.
4 ## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
5 ## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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.
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.
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/>.
21 # We require at least autoconf 2.63 (AC_INIT format changed there).
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])
30 AC_INIT([libsigrok4DSLogic], [sr_package_version], [support@dreamsourcelab.com],
31 [libsigrok4DSLogic], [http://www.dreamsourcelab.com])
32 AC_CONFIG_HEADER([config.h])
33 AC_CONFIG_MACRO_DIR([autostuff])
34 AC_CONFIG_AUX_DIR([autostuff])
36 # We require at least automake 1.11 (needed for 'silent rules').
37 AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news color-tests])
38 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
39 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
41 AH_TOP([#ifndef SR_CONFIG_H
42 #define SR_CONFIG_H /* To stop multiple inclusions. */])
43 AH_BOTTOM([#endif /* SR_CONFIG_H */])
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="$CFLAGS -Wall -Wextra -fvisibility=hidden"
49 # Checks for programs.
55 # Required for per-target flags or subdir-objects with C sources.
61 # Initialize pkg-config.
62 # We require at least 0.22, as "Requires.private" behaviour changed there.
63 PKG_PROG_PKG_CONFIG([0.22])
65 # Library version for libsigrok (NOT the same as the package version).
66 # Carefully read the libtool docs before updating these numbers!
67 # The algorithm for determining which number to change (and how) is nontrivial!
68 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
69 SR_LIB_VERSION_CURRENT=1
70 SR_LIB_VERSION_REVISION=2
72 SR_LIB_VERSION="$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"
73 SR_LIB_LDFLAGS="-version-info $SR_LIB_VERSION"
74 AC_SUBST(SR_LIB_VERSION_CURRENT)
75 AC_SUBST(SR_LIB_VERSION_REVISION)
76 AC_SUBST(SR_LIB_VERSION_AGE)
77 AC_SUBST(SR_LIB_VERSION)
78 AC_SUBST(SR_LIB_LDFLAGS)
80 AC_ARG_ENABLE(all-drivers, AC_HELP_STRING([--enable-all-drivers],
81 [enable all drivers by default [default=yes]]),
82 [HW_ENABLED_DEFAULT="$enableval"],
83 [HW_ENABLED_DEFAULT="yes"])
85 AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
86 [enable demo driver support [default=yes]]),
87 [HW_DEMO="$enableval"],
88 [HW_DEMO=$HW_ENABLED_DEFAULT])
89 # Checks for libraries.
93 # We need to link against the Winsock2 library for SCPI over TCP.
94 LIBS="$LIBS -lws2_32";;
97 # This variable collects the pkg-config names of all detected libs.
98 # It is then used to construct the "Requires.private:" field in the
99 # libsigrok4DSLogic.pc file.
102 # libm (the standard math library) is always needed.
103 AC_SEARCH_LIBS([pow], [m])
105 # libglib-2.0 is always needed. Abort if it's not found.
106 # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
107 # We require at least 2.32.0 due to e.g. g_variant_new_fixed_array().
108 AM_PATH_GLIB_2_0([2.32.0],
109 [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
111 # libzip is always needed. Abort if it's not found.
112 PKG_CHECK_MODULES([libzip], [libzip >= 0.10],
113 [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
114 SR_PKGLIBS="$SR_PKGLIBS libzip"])
116 # libserialport is only needed for some hardware drivers. Disable the
117 # respective drivers if it is not found.
118 PKG_CHECK_MODULES([libserialport], [libserialport >= 0.1.0],
119 [have_libserialport="yes"; CFLAGS="$CFLAGS $libserialport_CFLAGS";
120 LIBS="$LIBS $libserialport_LIBS";
121 SR_PKGLIBS="$SR_PKGLIBS libserialport"],
122 [have_libserialport="no"])
124 # Define HAVE_LIBSERIALPORT in config.h if we found libserialport.
125 if test "x$have_libserialport" != "xno"; then
126 AC_DEFINE_UNQUOTED(HAVE_LIBSERIALPORT, [1],
127 [Specifies whether we have libserialport.])
130 # Serial port helper code is only compiled in if libserialport was found.
131 AM_CONDITIONAL(NEED_SERIAL, test "x$have_libserialport" != xno)
133 # libusb-1.0 is only needed for some hardware drivers. Disable the respective
134 # drivers if it is not found.
137 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
138 # This means libusb-1.0 is always available, no need to check for it,
139 # and no need to (potentially) disable any drivers if it's not found.
140 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
141 [Specifies whether we have a libusb.h header.])
144 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9],
145 [have_libusb1_0="yes"; CFLAGS="$CFLAGS $libusb_CFLAGS";
146 LIBS="$LIBS $libusb_LIBS";
147 SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"],
148 [have_libusb1_0="no"])
150 # Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
151 if test "x$have_libusb1_0" != "xno"; then
152 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
153 [Specifies whether we have a libusb.h header.])
160 # The Check unit testing framework is optional. Disable if not found.
161 PKG_CHECK_MODULES([check], [check >= 0.9.4],
162 [have_check="yes"; CFLAGS="$CFLAGS $check_CFLAGS";
163 LIBS="$LIBS $check_LIBS"], [have_check="no"])
164 AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
166 # The OLS driver uses serial port file descriptors directly, and therefore
167 # will not currently work on Windows.
172 # Now set AM_CONDITIONALs and AC_DEFINEs for the enabled/disabled drivers.
176 AM_CONDITIONAL(HW_DEMO, test x$HW_DEMO = xyes)
177 if test "x$HW_DEMO" = "xyes"; then
178 AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
183 # Checks for header files.
184 # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
185 AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
187 # Checks for typedefs, structures, and compiler characteristics.
200 # Checks for library functions.
201 AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
203 AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
204 AC_SUBST(MAKEFLAGS, '--no-print-directory')
205 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
207 SR_PACKAGE_VERSION_MAJOR=sr_package_version_major
208 SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
209 SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
210 SR_PACKAGE_VERSION=sr_package_version
212 AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
213 AC_SUBST(SR_PACKAGE_VERSION_MINOR)
214 AC_SUBST(SR_PACKAGE_VERSION_MICRO)
215 AC_SUBST(SR_PACKAGE_VERSION)
217 AC_CONFIG_FILES([Makefile version.h hardware/Makefile
218 hardware/demo/Makefile
229 echo "libsigrok configuration summary:"
231 echo " - Package version (major.minor.micro): $SR_PACKAGE_VERSION"
232 echo " - Library version (current:revision:age): $SR_LIB_VERSION"
233 echo " - Prefix: $prefix"
234 echo " - Building on: $build"
235 echo " - Building for: $host"
237 echo "Detected libraries:"
240 # Note: This only works for libs with pkg-config integration.
241 for lib in "glib-2.0 >= 2.32.0" "libzip >= 0.10" "libserialport >= 0.1.0" "libusb-1.0 >= 1.0.9" "libftdi >= 0.16" "libudev >= 151" "alsa >= 1.0" "check >= 0.9.4"; do
242 if `$PKG_CONFIG --exists $lib`; then
243 ver=`$PKG_CONFIG --modversion $lib`
248 echo " - $lib: $answer"
251 echo -e "\nEnabled hardware drivers:\n"
252 echo " - demo............................ $HW_DEMO"