meson: Simplify code for libusb dependency
[libjaylink.git] / configure.ac
blob0200f4fd94406496d93a46c67ee95ac3f2f73e4a
1 ##
2 ## This file is part of the libjaylink project.
3 ##
4 ## Copyright (C) 2014-2015 Marc Schink <jaylink-dev@marcschink.de>
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 2 of the License, or
9 ## (at your option) any later version.
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.
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/>.
20 AC_PREREQ([2.64])
22 AC_INIT([libjaylink], [0.3.1], [dev@zapb.de], [libjaylink],
23         [https://gitlab.zapb.de/libjaylink/libjaylink.git])
24 AC_CONFIG_HEADERS([config.h])
25 AC_CONFIG_MACRO_DIR([m4])
26 AC_CONFIG_AUX_DIR([build-aux])
28 AC_CANONICAL_HOST
30 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
32 # Enable additional compiler warnings via -Wall and -Wextra. Use hidden
33 # visibility for all non-static symbols by default with -fvisibility=hidden.
34 JAYLINK_CFLAGS="-Wall -Wextra -Werror -fvisibility=hidden"
36 # Checks for programs.
37 AC_PROG_CC
38 # AC_PROG_CC_C99 is dropped in Autoconf >= 2.70 and done in AC_PROG_CC.
39 m4_version_prereq([2.70],[],[AC_PROG_CC_C99])
41 # Automake >= 1.12 requires AM_PROG_AR when using options -Wall and -Werror.
42 # To be compatible with older versions of Automake use AM_PROG_AR if it's
43 # defined only. This line must occur before LT_INIT.
44 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
46 # Initialize libtool.
47 LT_INIT
49 # Initialize pkg-config.
50 PKG_PROG_PKG_CONFIG
52 # Checks for libraries.
54 # Check for libusb-1.0.
55 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.16],
56         [HAVE_LIBUSB=yes], [HAVE_LIBUSB=no])
58 AS_IF([test "x$HAVE_LIBUSB" = "xyes"],
59         [libusb_msg="yes"], [libusb_msg="no (missing: libusb-1.0)"])
61 # Checks for header files.
63 # Checks for typedefs, structures, and compiler characteristics.
64 AC_C_BIGENDIAN
66 # Checks for library functions.
68 # Disable progress and informational output of libtool.
69 AC_SUBST([AM_LIBTOOLFLAGS], '--silent')
71 JAYLINK_SET_PACKAGE_VERSION([JAYLINK_VERSION_PACKAGE], [AC_PACKAGE_VERSION])
73 # Libtool interface version of libjaylink. This is not the same as the package
74 # version. For information about the versioning system of libtool, see:
75 # http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
76 JAYLINK_SET_LIBRARY_VERSION([JAYLINK_VERSION_LIBRARY], [2:0:2])
78 AC_ARG_ENABLE([subproject-build], AS_HELP_STRING([--enable-subproject-build],
79         [enable sub-project build [default=no]]))
81 AM_CONDITIONAL([SUBPROJECT_BUILD],
82         [test "x$enable_subproject_build" = "xyes"])
84 AC_ARG_WITH([libusb], [AS_HELP_STRING([--without-libusb],
85         [disable libusb support [default=detect]])])
87 AS_IF([test "x$with_libusb" != "xno"],
88         [with_libusb="yes"])
90 AS_IF([test "x$with_libusb$HAVE_LIBUSB" = "xyesyes"],
91         [AC_DEFINE([HAVE_LIBUSB], [1], [Define to 1 if libusb is available.])])
93 AS_IF([test "x$with_libusb" != "xyes"],
94         [libusb_msg="no (disabled)"])
96 AS_IF([test "x$with_libusb$HAVE_LIBUSB" = "xyesyes"],
97         [JAYLINK_PKG_LIBS="libusb-1.0"])
99 AM_CONDITIONAL([HAVE_LIBUSB],
100         [test "x$with_libusb$HAVE_LIBUSB" = "xyesyes"])
102 # Libtool interface version is not used for sub-project build as libjaylink is
103 # built as libtool convenience library.
104 AS_IF([test "x$enable_subproject_build" != "xyes"],
105         [JAYLINK_LDFLAGS="-version-info $JAYLINK_VERSION_LIBRARY"])
107 # Use C99 compatible stdio functions on MinGW instead of the incompatible
108 # functions provided by Microsoft.
109 AS_CASE([$host_os], [mingw*],
110         [JAYLINK_CFLAGS="$JAYLINK_CFLAGS -D__USE_MINGW_ANSI_STDIO"])
112 # Add the Winsock2 library on MinGW for socket and other network-related
113 # functions.
114 AS_CASE([$host_os], [mingw*], [JAYLINK_LIBS="$JAYLINK_LIBS -lws2_32"])
116 AC_SUBST([JAYLINK_CFLAGS])
117 AC_SUBST([JAYLINK_LDFLAGS])
118 AC_SUBST([JAYLINK_LIBS])
119 AC_SUBST([JAYLINK_PKG_LIBS])
121 AC_CONFIG_FILES([Makefile])
122 AC_CONFIG_FILES([libjaylink/Makefile])
123 AC_CONFIG_FILES([libjaylink/version.h])
124 AC_CONFIG_FILES([libjaylink.pc])
125 AC_CONFIG_FILES([Doxyfile])
127 AC_OUTPUT
129 echo
130 echo "libjaylink configuration summary:"
131 echo " - Package version ................ $JAYLINK_VERSION_PACKAGE"
132 echo " - Library version ................ $JAYLINK_VERSION_LIBRARY"
133 echo " - Installation prefix ............ $prefix"
134 echo " - Building on .................... $build"
135 echo " - Building for ................... $host"
137 echo
138 echo "Enabled transports:"
139 echo " - USB ............................ $libusb_msg"
140 echo " - TCP ............................ yes"
141 echo