Changeset 14262 for trunk/configure.ac


Ignore:
Timestamp:
Apr 27, 2014, 7:31:10 PM (8 years ago)
Author:
jordan
Message:

upgrade miniupnp version to 1.9. update autoconf script to detect the API version; update upnp.c's #ifdefs to use the API version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r14259 r14262  
    244244dnl
    245245
    246 AC_MSG_CHECKING([supported miniupnp library])
    247 upnp_version="none"
    248246ac_save_LIBS="$LIBS"
    249247LIBS="-lminiupnpc"
    250 # See if the OS has its miniupnp 1.5 installed
    251 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
     248AC_MSG_CHECKING([system miniupnpc library])
     249
     250dnl See if ANY version of miniupnpc is installed
     251AC_LINK_IFELSE(
     252  [AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
     253                   [struct UPNPDev dev;])],
     254  [upnp_version="unknown"],
     255  [upnp_version="none"]
     256)
     257
     258dnl Let's hope it's 1.7 or higher, since it provides
     259dnl MINIUPNPC_API_VERSION and we won't have to figure
     260dnl it out on our own
     261if test "x$upnp_version" = "xunknown" ; then
     262  AC_RUN_IFELSE(
     263    [AC_LANG_PROGRAM(
     264      [#include <stdlib.h>
     265       #include <miniupnpc/miniupnpc.h>],
     266      [#ifdef MINIUPNPC_API_VERSION
     267       return EXIT_SUCCESS;
     268       #else
     269       return EXIT_FAILURE;
     270       #endif]
     271    )],
     272    [upnp_version=">= 1.7"]
     273  )
     274fi
     275
     276dnl Or maybe it's miniupnp 1.6
     277if test "x$upnp_version" = "xunknown" ; then
     278  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
     279    #include <stdlib.h>
     280    #include <errno.h>
     281    #include <miniupnpc/miniupnpc.h>
     282    #include <miniupnpc/upnpcommands.h>
     283  ]], [[
     284    struct UPNPDev * devlist;
     285    struct UPNPUrls urls;
     286    struct IGDdatas data;
     287    char lanaddr[16];
     288    char portStr[8];
     289    char intPort[8];
     290    char intClient[16];
     291    upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
     292    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
     293    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
     294                        portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
     295  ]])],[
     296  AC_DEFINE(MINIUPNPC_API_VERSION, 8, [miniupnpc 1.6's API version is 8])
     297  upnp_version="1.6"])
     298fi
     299
     300dnl Or maybe it's miniupnp 1.5
     301if test "x$upnp_version" = "xunknown" ; then
     302  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
    252303    #include <stdlib.h>
    253304    #include <miniupnpc/miniupnpc.h>
    254305    #include <miniupnpc/upnpcommands.h>
    255 ]], [[
     306  ]], [[
    256307    struct UPNPDev * devlist;
    257     struct UPNPUrls    urls;
    258     struct IGDdatas    data;
     308    struct UPNPUrls urls;
     309    struct IGDdatas data;
    259310    char lanaddr[16];
    260311    char portStr[8];
     
    265316    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
    266317                        portStr, "TCP", intClient, intPort );
    267 ]])],[
    268 AC_DEFINE(HAVE_MINIUPNP_15, 1, [Define to 1 if you have miniupnpc version 1.5])
    269 upnp_version="1.5"],[])
    270 
    271 # See if the OS has its miniupnp 1.6 installed
    272 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
    273     #include <stdlib.h>
    274     #include <errno.h>
    275     #include <miniupnpc/miniupnpc.h>
    276     #include <miniupnpc/upnpcommands.h>
    277 ]], [[
    278     struct UPNPDev * devlist;
    279     struct UPNPUrls    urls;
    280     struct IGDdatas    data;
    281     char lanaddr[16];
    282     char portStr[8];
    283     char intPort[8];
    284     char intClient[16];
    285     upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
    286     UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
    287     UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
    288                         portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
    289 ]])],[
    290 AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
    291 upnp_version="1.6"],[])
     318  ]])],[
     319  AC_DEFINE(MINIUPNPC_API_VERSION, 5, [miniupnpc 1.5's API version is 5])
     320  upnp_version="1.5"])
     321fi
    292322
    293323# ... and the results of our tests
     
    299329    LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
    300330    LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
    301     dnl because this is the version that we bundle...
    302     AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
    303331else
    304332    AC_DEFINE([SYSTEM_MINIUPNP])
Note: See TracChangeset for help on using the changeset viewer.