]> sigrok.org Git - libsigrok.git/blob - configure.ac
Code drop from DreamSourceLabs first source release.
[libsigrok.git] / configure.ac
1 ##
2 ## This file is part of the libsigrok 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([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])
35
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])
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="$CFLAGS -Wall -Wextra -fvisibility=hidden"
48
49 # Checks for programs.
50 AC_PROG_CC
51 AC_PROG_CPP
52 AC_PROG_INSTALL
53 AC_PROG_LN_S
54
55 # Required for per-target flags or subdir-objects with C sources.
56 AM_PROG_CC_C_O
57
58 # Initialize libtool.
59 LT_INIT
60
61 # Initialize pkg-config.
62 # We require at least 0.22, as "Requires.private" behaviour changed there.
63 PKG_PROG_PKG_CONFIG([0.22])
64
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
71 SR_LIB_VERSION_AGE=0
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)
79
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"])
84
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.
90
91 case "$host" in
92 *mingw*)
93         # We need to link against the Winsock2 library for SCPI over TCP.
94         LIBS="$LIBS -lws2_32";;
95 esac
96
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.
100 SR_PKGLIBS=""
101
102 # libm (the standard math library) is always needed.
103 AC_SEARCH_LIBS([pow], [m])
104
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"])
110
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"])
115
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"])
123
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.])
128 fi
129
130 # Serial port helper code is only compiled in if libserialport was found.
131 AM_CONDITIONAL(NEED_SERIAL, test "x$have_libserialport" != xno)
132
133 # libusb-1.0 is only needed for some hardware drivers. Disable the respective
134 # drivers if it is not found.
135 case "$host" in
136 *freebsd*)
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.])
142         ;;
143 *)
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"])
149
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.])
154         fi
155         ;;
156 esac
157
158
159
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")
165
166 # The OLS driver uses serial port file descriptors directly, and therefore
167 # will not currently work on Windows.
168
169
170 AC_SUBST(SR_PKGLIBS)
171
172 # Now set AM_CONDITIONALs and AC_DEFINEs for the enabled/disabled drivers.
173
174
175
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])
179 fi
180
181
182
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])
186
187 # Checks for typedefs, structures, and compiler characteristics.
188 AC_C_BIGENDIAN
189 AC_C_INLINE
190 AC_TYPE_INT8_T
191 AC_TYPE_INT16_T
192 AC_TYPE_INT32_T
193 AC_TYPE_INT64_T
194 AC_TYPE_UINT8_T
195 AC_TYPE_UINT16_T
196 AC_TYPE_UINT32_T
197 AC_TYPE_UINT64_T
198 AC_TYPE_SIZE_T
199
200 # Checks for library functions.
201 AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
202
203 AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
204 AC_SUBST(MAKEFLAGS, '--no-print-directory')
205 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
206
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
211
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)
216
217 AC_CONFIG_FILES([Makefile version.h hardware/Makefile
218                  hardware/demo/Makefile
219                  input/Makefile
220                  output/Makefile
221                  output/text/Makefile
222                  libsigrok4DSLogic.pc
223                  tests/Makefile
224                 ])
225
226 AC_OUTPUT
227
228 echo
229 echo "libsigrok configuration summary:"
230 echo
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"
236 echo
237 echo "Detected libraries:"
238 echo
239
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`
244                 answer="yes ($ver)"
245         else
246                 answer="no"
247         fi
248         echo "  - $lib: $answer"
249 done
250
251 echo -e "\nEnabled hardware drivers:\n"
252 echo "  - demo............................ $HW_DEMO"
253 echo
254