]> sigrok.org Git - libsigrok.git/blame - configure.ac
Code drop from DreamSourceLabs first source release.
[libsigrok.git] / configure.ac
CommitLineData
826938d8 1##
50985c20 2## This file is part of the libsigrok project.
826938d8 3##
c73d2ea4 4## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
d375b3c3 5## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
826938d8
UH
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
ef7228ba
UH
21# We require at least autoconf 2.63 (AC_INIT format changed there).
22AC_PREREQ([2.63])
826938d8 23
3af71f0d 24# libsigrok package version number (NOT the same as shared lib version!).
6dddd902 25m4_define([sr_package_version_major], [0])
63298404
UH
26m4_define([sr_package_version_minor], [2])
27m4_define([sr_package_version_micro], [0])
6dddd902 28m4_define([sr_package_version], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro])
826938d8 29
f1b296fc
BV
30AC_INIT([libsigrok4DSLogic], [sr_package_version], [support@dreamsourcelab.com],
31 [libsigrok4DSLogic], [http://www.dreamsourcelab.com])
826938d8 32AC_CONFIG_HEADER([config.h])
d8521c93
UH
33AC_CONFIG_MACRO_DIR([autostuff])
34AC_CONFIG_AUX_DIR([autostuff])
826938d8 35
ef7228ba 36# We require at least automake 1.11 (needed for 'silent rules').
22ca5aa6 37AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news color-tests])
826938d8 38m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
432e5e95 39m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
826938d8 40
6dddd902
UH
41AH_TOP([#ifndef SR_CONFIG_H
42#define SR_CONFIG_H /* To stop multiple inclusions. */])
43AH_BOTTOM([#endif /* SR_CONFIG_H */])
826938d8 44
1a081ca6
UH
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.
bdd7618c 47CFLAGS="$CFLAGS -Wall -Wextra -fvisibility=hidden"
826938d8
UH
48
49# Checks for programs.
826938d8
UH
50AC_PROG_CC
51AC_PROG_CPP
52AC_PROG_INSTALL
53AC_PROG_LN_S
54
bb203cde
UH
55# Required for per-target flags or subdir-objects with C sources.
56AM_PROG_CC_C_O
57
826938d8
UH
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
3af71f0d 65# Library version for libsigrok (NOT the same as the package version).
826938d8
UH
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
6941f845 69SR_LIB_VERSION_CURRENT=1
f1b296fc 70SR_LIB_VERSION_REVISION=2
6dddd902
UH
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)
826938d8 79
dbf2482e 80AC_ARG_ENABLE(all-drivers, AC_HELP_STRING([--enable-all-drivers],
f1b296fc
BV
81 [enable all drivers by default [default=yes]]),
82 [HW_ENABLED_DEFAULT="$enableval"],
83 [HW_ENABLED_DEFAULT="yes"])
4d729ddc 84
589a1013 85AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
8a22e8c0 86 [enable demo driver support [default=yes]]),
f1b296fc
BV
87 [HW_DEMO="$enableval"],
88 [HW_DEMO=$HW_ENABLED_DEFAULT])
826938d8
UH
89# Checks for libraries.
90
f1b296fc
BV
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
826938d8
UH
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
f1b296fc 99# libsigrok4DSLogic.pc file.
6dddd902 100SR_PKGLIBS=""
826938d8 101
f1b296fc
BV
102# libm (the standard math library) is always needed.
103AC_SEARCH_LIBS([pow], [m])
104
aba69262 105# libglib-2.0 is always needed. Abort if it's not found.
826938d8 106# Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
406569dd
UH
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],
826938d8
UH
109 [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
110
aba69262 111# libzip is always needed. Abort if it's not found.
f1b296fc 112PKG_CHECK_MODULES([libzip], [libzip >= 0.10],
826938d8 113 [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
6dddd902 114 SR_PKGLIBS="$SR_PKGLIBS libzip"])
826938d8 115
f1b296fc
BV
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
aba69262
UH
133# libusb-1.0 is only needed for some hardware drivers. Disable the respective
134# drivers if it is not found.
2e542814 135case "$host" in
aba69262
UH
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"],
f1b296fc 148 [have_libusb1_0="no"])
aba69262
UH
149
150 # Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
ccf35720 151 if test "x$have_libusb1_0" != "xno"; then
aba69262
UH
152 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
153 [Specifies whether we have a libusb.h header.])
154 fi
155 ;;
156esac
157
aba69262 158
aba69262
UH
159
160# The Check unit testing framework is optional. Disable if not found.
79bb0e97
UH
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
f1b296fc
BV
166# The OLS driver uses serial port file descriptors directly, and therefore
167# will not currently work on Windows.
168
63cbeaeb 169
6dddd902 170AC_SUBST(SR_PKGLIBS)
826938d8 171
ae4c3d04
UH
172# Now set AM_CONDITIONALs and AC_DEFINEs for the enabled/disabled drivers.
173
ae4c3d04 174
ae4c3d04 175
f1b296fc
BV
176AM_CONDITIONAL(HW_DEMO, test x$HW_DEMO = xyes)
177if test "x$HW_DEMO" = "xyes"; then
ae4c3d04
UH
178 AC_DEFINE(HAVE_LA_DEMO, 1, [Demo driver support])
179fi
180
695f32d8 181
ae4c3d04 182
826938d8
UH
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.
f1b296fc 188AC_C_BIGENDIAN
826938d8
UH
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
fb6f1978 203AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
826938d8
UH
204AC_SUBST(MAKEFLAGS, '--no-print-directory')
205AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
206
6dddd902
UH
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
3af71f0d 211
6dddd902
UH
212AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
213AC_SUBST(SR_PACKAGE_VERSION_MINOR)
214AC_SUBST(SR_PACKAGE_VERSION_MICRO)
215AC_SUBST(SR_PACKAGE_VERSION)
3af71f0d 216
589a1013 217AC_CONFIG_FILES([Makefile version.h hardware/Makefile
db8ae7b9 218 hardware/demo/Makefile
db8ae7b9
UH
219 input/Makefile
220 output/Makefile
221 output/text/Makefile
f1b296fc 222 libsigrok4DSLogic.pc
79bb0e97 223 tests/Makefile
826938d8
UH
224 ])
225
226AC_OUTPUT
227
228echo
45aed072 229echo "libsigrok configuration summary:"
826938d8 230echo
6dddd902
UH
231echo " - Package version (major.minor.micro): $SR_PACKAGE_VERSION"
232echo " - Library version (current:revision:age): $SR_LIB_VERSION"
45aed072 233echo " - Prefix: $prefix"
6bad8487
UH
234echo " - Building on: $build"
235echo " - Building for: $host"
45aed072
UH
236echo
237echo "Detected libraries:"
238echo
239
240# Note: This only works for libs with pkg-config integration.
f1b296fc 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
45aed072
UH
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
589a1013 251echo -e "\nEnabled hardware drivers:\n"
f1b296fc 252echo " - demo............................ $HW_DEMO"
826938d8
UH
253echo
254