| 1 |
# -*- Autoconf -*- |
| 2 |
# Copyright 2014 Google Inc. All Rights Reserved. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
# |
| 16 |
# Detect installed libais. |
| 17 |
# |
| 18 |
# Use the AX_LIB_AIS autoconf macro to enable libais support in |
| 19 |
# other libraries or programs. |
| 20 |
# |
| 21 |
# AX_LIB_AIS defaults to not looking for libais (--without-ais or |
| 22 |
# --with-ais=no). |
| 23 |
# |
| 24 |
# Specifying --with-ais assumes that libais is installed in /usr. |
| 25 |
# --with-ais=DIR will look for DIR/include/ais.h and |
| 26 |
# DIR/lib/libais.{so,a,dylib}. If either the header or library is |
| 27 |
# not found, it will abort the configure script. |
| 28 |
# |
| 29 |
# When configured, the following variables are available in configure: |
| 30 |
# |
| 31 |
# AIS_HOME - Root of the libais tree. |
| 32 |
# AIS_INC - Include directive (-I) needed for libais. |
| 33 |
# AIS_LIB - Library path directive (-L) for libais. |
| 34 |
# |
| 35 |
# These variables are set for generated files file AC_SUBST: |
| 36 |
# |
| 37 |
# AIS_CPPFLAGS - Include directive (-I) needed for libais. |
| 38 |
# AIS_LDFLAGS - Library path directive (-L) for libais. |
| 39 |
# AIS_LIBS - The actual library to link against. |
| 40 |
# |
| 41 |
# For C++ source, AC_DEFINE sets HAVE_AIS in any config headers. Use like so: |
| 42 |
# |
| 43 |
# #ifdef HAVE_AIS |
| 44 |
# #include <ais.h> |
| 45 |
# #endif |
| 46 |
|
| 47 |
AC_DEFUN([AX_LIB_AIS], [ |
| 48 |
|
| 49 |
AC_ARG_WITH( |
| 50 |
[ais], |
| 51 |
AS_HELP_STRING( |
| 52 |
[--with-ais], |
| 53 |
[Include ais support (ARG=no, yes or libais directory).])) |
| 54 |
|
| 55 |
AS_IF([test x$with_ais == xyes], [have_ais=yes], |
| 56 |
[test x$with_ais == xno], [have_ais=no], |
| 57 |
[test x$with_ais != x], [have_ais=yes], |
| 58 |
[have_ais=no]) |
| 59 |
|
| 60 |
AC_MSG_CHECKING([for libais]) |
| 61 |
AS_IF([test $have_ais == yes], [AC_MSG_RESULT(yes)], |
| 62 |
[AC_MSG_RESULT(skip)]) |
| 63 |
|
| 64 |
AS_IF([test $have_ais == yes], [ |
| 65 |
AS_IF([test $with_ais == yes], [AIS_HOME=/usr], |
| 66 |
[AIS_HOME=$with_ais]) |
| 67 |
AIS_INCDIR=$AIS_HOME/include |
| 68 |
AIS_LIBDIR=$AIS_HOME/lib |
| 69 |
|
| 70 |
AIS_INC=-I$AIS_HOME/include |
| 71 |
AIS_LIB=-L$AIS_HOME/lib |
| 72 |
|
| 73 |
OLD_CPPFLAGS=$CPPFLAGS |
| 74 |
OLD_LDFLAGS=$LDFLAGS |
| 75 |
CPPFLAGS="$CPPFLAGS ${AIS_INC}" |
| 76 |
LDFLAGS="$LDFLAGS ${AIS_LIB}" |
| 77 |
AC_LANG_PUSH([C++]) |
| 78 |
AC_CHECK_HEADER([ais.h], [ac_cv_ais_h=yes], [ac_cv_ais_h=no]) |
| 79 |
AC_CHECK_LIB([ais], [LibAisVersionMajor], |
| 80 |
[ac_cv_lib_ais=yes], [ac_cv_lib_ais=no]) |
| 81 |
AC_LANG_POP |
| 82 |
CPPFLAGS="$OLD_CPPFLAGS" |
| 83 |
LDFLAGS="$OLD_LDFLAGS" |
| 84 |
|
| 85 |
# AC_MSG_FAILURE ? |
| 86 |
AS_IF([test $ac_cv_ais_h == no], |
| 87 |
[AC_MSG_ERROR([ais.h not found with $AIS_INC])]) |
| 88 |
AS_IF([test $ac_cv_lib_ais == no], |
| 89 |
[AC_MSG_ERROR([libais not found with $AIS_LIB])]) |
| 90 |
|
| 91 |
AC_DEFINE(HAVE_AIS, 1, |
| 92 |
[Use libais for NMEA Automatic Identification System.]) |
| 93 |
|
| 94 |
HAVE_AIS=$have_ais |
| 95 |
AC_SUBST(HAVE_AIS, $HAVE_AIS) |
| 96 |
AC_SUBST(AIS_CPPFLAGS, $AIS_INC) |
| 97 |
AC_SUBST(AIS_LDFLAGS, $AIS_LIB) |
| 98 |
AC_SUBST(AIS_LIBS, -lais) |
| 99 |
]) |
| 100 |
|
| 101 |
]) |