exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

mhd.m4 (2500B)


      1 # mhd.m4
      2 
      3 #  This file is part of TALER
      4 #  Copyright (C) 2022, 2025 Taler Systems SA
      5 #
      6 #  TALER is free software; you can redistribute it and/or modify it under the
      7 #  terms of the GNU General Public License as published by the Free Software
      8 #  Foundation; either version 3, or (at your option) any later version.
      9 #
     10 #  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     11 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     12 #  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     13 #
     14 #  You should have received a copy of the GNU General Public License along with
     15 #  TALER; see the file COPYING.  If not, If not, see <http://www.gnu.org/license>
     16 
     17 # serial 2
     18 
     19 dnl MHD_VERSION_AT_LEAST([VERSION])
     20 dnl
     21 dnl Check that microhttpd.h defines MHD_VERSION and compare it against
     22 dnl the required version without executing compiled code.
     23 dnl This allows for cross-compilation scenarios to work correctly.
     24 dnl
     25 dnl If the check fails, display error message and exit.
     26 dnl Uses AX_COMPARE_VERSION to compare versions.
     27 dnl Sets shell var mhd_cv_version with detected version.
     28 dnl
     29 AC_DEFUN([MHD_VERSION_AT_LEAST],
     30 [
     31   AC_MSG_CHECKING([for libmicrohttpd version >= $1])
     32 
     33   # Try to get version by compiling & running a test program (won't work for cross-compilation)
     34   AC_RUN_IFELSE([AC_LANG_PROGRAM([[
     35     #include <stdio.h>
     36     #include <microhttpd.h>
     37   ]],[[
     38     int v = MHD_VERSION;
     39     FILE *f = fopen("conftest.out", "w");
     40     if (f == NULL) return 1;
     41     fprintf(f, "%d.%d.%d\n",
     42             (v >> 24) & 0xff,
     43             (v >> 16) & 0xff,
     44             (v >>  8) & 0xff);
     45     fclose(f);
     46     return 0;
     47   ]])],
     48     [mhd_cv_version=$(cat conftest.out)
     49      rm -f conftest.out],
     50     [mhd_cv_version=0],
     51     [
     52       # Cross compiling mode - compute version via macros
     53       AC_COMPUTE_INT([mhd_major], [(MHD_VERSION >> 24) & 0xff], [[#include <microhttpd.h>]], [mhd_major=0])
     54       AC_COMPUTE_INT([mhd_minor], [(MHD_VERSION >> 16) & 0xff], [[#include <microhttpd.h>]], [mhd_minor=0])
     55       AC_COMPUTE_INT([mhd_micro], [(MHD_VERSION >> 8) & 0xff], [[#include <microhttpd.h>]], [mhd_micro=0])
     56       mhd_cv_version="$mhd_major.$mhd_minor.$mhd_micro"
     57     ])
     58 
     59   # Compare version and report result
     60   AX_COMPARE_VERSION([$mhd_cv_version],[ge],[$1],
     61     [AC_MSG_RESULT([yes ($mhd_cv_version)])],
     62     [AC_MSG_RESULT([no ($mhd_cv_version)])
     63      AC_MSG_ERROR([[
     64 ***
     65 *** You need libmicrohttpd >= $1 to build this program.
     66 *** ]])])
     67 ])
     68 
     69 # mhd.m4 ends here