1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 autoreconfHook,
6}:
7
8stdenv.mkDerivation rec {
9 pname = "libmodbus";
10 version = "3.1.11";
11
12 src = fetchFromGitHub {
13 owner = "stephane";
14 repo = "libmodbus";
15 rev = "v${version}";
16 hash = "sha256-d/diR9yeV0WY0C6wqxYZfOjEKFeWTvN73MxcWtXPOJc=";
17 };
18
19 nativeBuildInputs = [ autoreconfHook ];
20
21 configureFlags = [
22 # when cross-compiling we assume that the host system will return a valid
23 # pointer for calls to malloc(0) or realloc(0)
24 # https://www.uclibc.org/FAQ.html#gnu_malloc
25 # https://www.gnu.org/software/autoconf/manual/autoconf.html#index-AC_005fFUNC_005fMALLOC-454
26 # the upstream source should be patched to avoid needing this
27 "ac_cv_func_malloc_0_nonnull=yes"
28 "ac_cv_func_realloc_0_nonnull=yes"
29 ];
30
31 meta = with lib; {
32 description = "Library to send/receive data according to the Modbus protocol";
33 homepage = "https://libmodbus.org/";
34 license = licenses.lgpl21Plus;
35 platforms = with platforms; unix ++ windows;
36 maintainers = [ maintainers.bjornfor ];
37 };
38}