debian: fix build-deps for focal
[amule.git] / m4 / libupnp.m4
bloba9e08dbc9c4b4e081115d77ec25632140a586633
1 #                                                       -*- Autoconf -*-
2 # This file is part of the aMule project.
3 # This file is part of the libupnp library project.
5 # Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
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 2 of the License, or
10 # (at your option) any later version.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
22 dnl --------------------------------------------------------------------------
23 dnl LIBUPNP_CHECK([VERSION = 1.6.6], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
24 dnl
25 dnl Check for the libupnp library
26 dnl --------------------------------------------------------------------------
27 dnl
28 dnl This macro sets these variables:
29 dnl - LIBUPNP_VERSION
30 dnl     Something like "1.6.7"
31 dnl - LIBUPNP_CPPFLAGS
32 dnl     Flags to be added to CPPFLAGS
33 dnl - LIBUPNP_CFLAGS
34 dnl     Flags to be added to CFLAGS
35 dnl - LIBUPNP_LDFLAGS
36 dnl     Flags to be added to LDFLAGS
37 dnl - LIBUPNP_LIBS
38 dnl     Library to be added to LIBS
39 dnl
40 dnl The LIBUPNP_CPPFLAGS, LIBUPNP_CFLAGS, LIBUPNP_LDFLAGS and LIBUPNP_LIBS variables are also substituted.
41 dnl
42 AC_DEFUN([LIBUPNP_CHECK],
43 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
44 m4_define([MIN_LIBUPNP_VERSION], [m4_ifval([$1], [$1], [1.6.6])])dnl
46 dnl     Test for --with-libupnp-prefix
47         AC_ARG_WITH(
48                 [libupnp-prefix],[
49                 AS_HELP_STRING(
50                         [--with-libupnp-prefix=PREFIX],
51                         [UPnP library location])],[
52                 AS_IF([test -d "$withval/lib64/pkgconfig"],[
53                         export PKG_CONFIG_PATH=$withval/lib64/pkgconfig
54                 ],[
55                         export PKG_CONFIG_PATH=$withval/lib/pkgconfig
56                 ])
57         ])
59 dnl     Check for libupnp >= MIN_LIBUPNP_VERSION
60         AS_IF([test $cross_compiling = no], [
61                 AC_MSG_CHECKING([for libupnp version >= MIN_LIBUPNP_VERSION])
62                 AS_IF([test -n "$PKG_CONFIG"], [
63                         AS_IF([$PKG_CONFIG libupnp --exists], [
64                                 LIBUPNP_VERSION=`$PKG_CONFIG libupnp --modversion`
65                                 AS_IF([$PKG_CONFIG libupnp --atleast-version=MIN_LIBUPNP_VERSION], [
66                                         result=yes
67                                         resultstr=" (version $LIBUPNP_VERSION)"
68                                         LIBUPNP_CPPFLAGS=`$PKG_CONFIG libupnp --cflags-only-I`
69                                         LIBUPNP_CFLAGS=`$PKG_CONFIG libupnp --cflags-only-other`
70                                         LIBUPNP_LDFLAGS=`$PKG_CONFIG libupnp --libs-only-L`
71                                         LIBUPNP_LIBS=`$PKG_CONFIG libupnp --libs-only-other`
72                                         LIBUPNP_LIBS="$LIBUPNP_LIBS `$PKG_CONFIG libupnp --libs-only-l`"
73                                 ], [
74                                         result=no
75                                         resultstr=" (version $LIBUPNP_VERSION is not new enough)"
76                                 ])
77                         ], [
78                                 result=no
79                                 resultstr=" (try to use --with-libupnp-prefix=PREFIX)"
80                         ])
81                 ], [
82                         result=no
83                         resultstr=" (pkg-config not found)"
84                 ])
85                 AC_MSG_RESULT([$result$resultstr])
86                 libupnp_error="libupnp >= MIN_LIBUPNP_VERSION not found$resultstr"
87         ], [
88 dnl Currently cross-compilation with libupnp is not supported.
89                 result=no
90                 libupnp_error="cross compiling"
91         ])
93 dnl     Execute the right action.
94         AS_IF([test ${result:-no} = yes], [$2], [$3])
96 dnl Exported symbols
97 AC_SUBST([LIBUPNP_CPPFLAGS])dnl
98 AC_SUBST([LIBUPNP_CFLAGS])dnl
99 AC_SUBST([LIBUPNP_LDFLAGS])dnl
100 AC_SUBST([LIBUPNP_LIBS])dnl
101 m4_undefine([MIN_LIBUPNP_VERSION])dnl