]> sigrok.org Git - libsigrok.git/blame_incremental - configure.ac
Code drop from DreamSourceLabs first source release.
[libsigrok.git] / configure.ac
... / ...
CommitLineData
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).
22AC_PREREQ([2.63])
23
24# libsigrok package version number (NOT the same as shared lib version!).
25m4_define([sr_package_version_major], [0])
26m4_define([sr_package_version_minor], [2])
27m4_define([sr_package_version_micro], [0])
28m4_define([sr_package_version], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro])
29
30AC_INIT([libsigrok4DSLogic], [sr_package_version], [support@dreamsourcelab.com],
31 [libsigrok4DSLogic], [http://www.dreamsourcelab.com])
32AC_CONFIG_HEADER([config.h])
33AC_CONFIG_MACRO_DIR([autostuff])
34AC_CONFIG_AUX_DIR([autostuff])
35
36# We require at least automake 1.11 (needed for 'silent rules').
37AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news color-tests])
38m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
39m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
40
41AH_TOP([#ifndef SR_CONFIG_H
42#define SR_CONFIG_H /* To stop multiple inclusions. */])
43AH_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.
47CFLAGS="$CFLAGS -Wall -Wextra -fvisibility=hidden"
48
49# Checks for programs.
50AC_PROG_CC
51AC_PROG_CPP
52AC_PROG_INSTALL
53AC_PROG_LN_S
54
55# Required for per-target flags or subdir-objects with C sources.
56AM_PROG_CC_C_O
57
58# Initialize libtool.
59LT_INIT
60
61# Initialize pkg-config.
62# We require at least 0.22, as "Requires.private" behaviour changed there.
63PKG_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
69SR_LIB_VERSION_CURRENT=1
70SR_LIB_VERSION_REVISION=2
71SR_LIB_VERSION_AGE=0
72SR_LIB_VERSION="$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"
73SR_LIB_LDFLAGS="-version-info $SR_LIB_VERSION"
74AC_SUBST(SR_LIB_VERSION_CURRENT)
75AC_SUBST(SR_LIB_VERSION_REVISION)
76AC_SUBST(SR_LIB_VERSION_AGE)
77AC_SUBST(SR_LIB_VERSION)
78AC_SUBST(SR_LIB_LDFLAGS)
79
80AC_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
85AC_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
91case "$host" in
92*mingw*)
93 # We need to link against the Winsock2 library for SCPI over TCP.
94 LIBS="$LIBS -lws2_32";;
95esac
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.
100SR_PKGLIBS=""
101
102# libm (the standard math library) is always needed.
103AC_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().
108AM_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.
112PKG_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.
118PKG_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.
125if test "x$have_libserialport" != "xno"; then
126 AC_DEFINE_UNQUOTED(HAVE_LIBSERIALPORT, [1],
127 [Specifies whether we have libserialport.])
128fi
129
130# Serial port helper code is only compiled in if libserialport was found.
131AM_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.
135case "$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 ;;
156esac
157
158
159
160# The Check unit testing framework is optional. Disable if not found.
161PKG_CHECK_MODULES([check], [check >= 0.9.4],
162 [have_check="yes"; CFLAGS="$CFLAGS $check_CFLAGS";
163 LIBS="$LIBS $check_LIBS"], [have_check="no"])
164AM_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
170AC_SUBST(SR_PKGLIBS)
171
172# Now set AM_CONDITIONALs and AC_DEFINEs for the enabled/disabled drivers.
173
174
175
176AM_CONDITIONAL(HW_DEMO, test x$HW_DEMO = xyes)
177if test "x$HW_DEMO" = "xyes"; then
178 AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
179fi
180
181
182
183# Checks for header files.
184# These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
185AC_CHECK_HEADERS([fcntl.h sys/time.h termios.h])
186
187# Checks for typedefs, structures, and compiler characteristics.
188AC_C_BIGENDIAN
189AC_C_INLINE
190AC_TYPE_INT8_T
191AC_TYPE_INT16_T
192AC_TYPE_INT32_T
193AC_TYPE_INT64_T
194AC_TYPE_UINT8_T
195AC_TYPE_UINT16_T
196AC_TYPE_UINT32_T
197AC_TYPE_UINT64_T
198AC_TYPE_SIZE_T
199
200# Checks for library functions.
201AC_CHECK_FUNCS([gettimeofday memset strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull])
202
203AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
204AC_SUBST(MAKEFLAGS, '--no-print-directory')
205AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
206
207SR_PACKAGE_VERSION_MAJOR=sr_package_version_major
208SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
209SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
210SR_PACKAGE_VERSION=sr_package_version
211
212AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
213AC_SUBST(SR_PACKAGE_VERSION_MINOR)
214AC_SUBST(SR_PACKAGE_VERSION_MICRO)
215AC_SUBST(SR_PACKAGE_VERSION)
216
217AC_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
226AC_OUTPUT
227
228echo
229echo "libsigrok configuration summary:"
230echo
231echo " - Package version (major.minor.micro): $SR_PACKAGE_VERSION"
232echo " - Library version (current:revision:age): $SR_LIB_VERSION"
233echo " - Prefix: $prefix"
234echo " - Building on: $build"
235echo " - Building for: $host"
236echo
237echo "Detected libraries:"
238echo
239
240# Note: This only works for libs with pkg-config integration.
241for 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"
249done
250
251echo -e "\nEnabled hardware drivers:\n"
252echo " - demo............................ $HW_DEMO"
253echo
254