nixpkgs/pkgs/development/libraries/paho-mqtt-c/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1018 B
Nix
Raw Normal View History

paho-mqtt-c: pass static/shared build to cmake Allows to build paho-mqtt-c with pkgsStatic, which results in the following build failure without this change: ```console $ nix build ".#paho-mqtt-c" error: builder for '/nix/store/519ajxyj9vgzzk0mi1yll0df29synv5z-paho.mqtt.c-static-x86_64-unknown-linux-musl-1.3.13.drv' failed with exit code 2; last 10 log lines: > collect2: error: ld returned 1 exit status > make[2]: *** [src/CMakeFiles/paho-mqtt3cs.dir/build.make:163: src/libpaho-mqtt3cs.so.1.3.13] Error 1 > make[1]: *** [CMakeFiles/Makefile2:295: src/CMakeFiles/paho-mqtt3cs.dir/all] Error 2 > [ 64%] Linking C shared library libpaho-mqtt3as.so > /nix/store/zq91mr9h32cippzbnn321vrmbqkh4mi5-x86_64-unknown-linux-musl-binutils-2.40/bin/x86_64-unknown-linux-musl-ld: /nix/store/xqh4v9h8zlizphynp8d0mik2j2rzd94s-x86_64-unknown-linux-musl-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-musl/13.2.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object > /nix/store/zq91mr9h32cippzbnn321vrmbqkh4mi5-x86_64-unknown-linux-musl-binutils-2.40/bin/x86_64-unknown-linux-musl-ld: failed to set dynamic section sizes: bad value > collect2: error: ld returned 1 exit status > make[2]: *** [src/CMakeFiles/paho-mqtt3as.dir/build.make:179: src/libpaho-mqtt3as.so.1.3.13] Error 1 > make[1]: *** [CMakeFiles/Makefile2:321: src/CMakeFiles/paho-mqtt3as.dir/all] Error 2 > make: *** [Makefile:166: all] Error 2 For full logs, run 'nix log /nix/store/519ajxyj9vgzzk0mi1yll0df29synv5z-paho.mqtt.c-static-x86_64-unknown-linux-musl-1.3.13.drv'. ``` Co-authored-by: Nikolay Korotkiy <sikmir@disroot.org>
2024-02-27 11:45:40 +00:00
{ lib, stdenv, fetchFromGitHub, cmake, openssl, enableStatic ? stdenv.hostPlatform.isStatic, enableShared ? !stdenv.hostPlatform.isStatic }:
2022-10-04 08:36:50 +00:00
stdenv.mkDerivation rec {
pname = "paho.mqtt.c";
2023-10-19 12:38:03 +00:00
version = "1.3.13";
2022-10-04 08:36:50 +00:00
src = fetchFromGitHub {
owner = "eclipse";
repo = "paho.mqtt.c";
rev = "v${version}";
2023-10-19 12:38:03 +00:00
hash = "sha256-dKQnepQAryAjImh2rX1jdgiKBtJQy9wzk/7rGQjUtPg=";
2022-10-04 08:36:50 +00:00
};
postPatch = ''
substituteInPlace src/MQTTVersion.c \
--replace "namebuf[60]" "namebuf[120]" \
--replace "lib%s" "$out/lib/lib%s"
'';
nativeBuildInputs = [ cmake ];
buildInputs = [ openssl ];
paho-mqtt-c: pass static/shared build to cmake Allows to build paho-mqtt-c with pkgsStatic, which results in the following build failure without this change: ```console $ nix build ".#paho-mqtt-c" error: builder for '/nix/store/519ajxyj9vgzzk0mi1yll0df29synv5z-paho.mqtt.c-static-x86_64-unknown-linux-musl-1.3.13.drv' failed with exit code 2; last 10 log lines: > collect2: error: ld returned 1 exit status > make[2]: *** [src/CMakeFiles/paho-mqtt3cs.dir/build.make:163: src/libpaho-mqtt3cs.so.1.3.13] Error 1 > make[1]: *** [CMakeFiles/Makefile2:295: src/CMakeFiles/paho-mqtt3cs.dir/all] Error 2 > [ 64%] Linking C shared library libpaho-mqtt3as.so > /nix/store/zq91mr9h32cippzbnn321vrmbqkh4mi5-x86_64-unknown-linux-musl-binutils-2.40/bin/x86_64-unknown-linux-musl-ld: /nix/store/xqh4v9h8zlizphynp8d0mik2j2rzd94s-x86_64-unknown-linux-musl-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-musl/13.2.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object > /nix/store/zq91mr9h32cippzbnn321vrmbqkh4mi5-x86_64-unknown-linux-musl-binutils-2.40/bin/x86_64-unknown-linux-musl-ld: failed to set dynamic section sizes: bad value > collect2: error: ld returned 1 exit status > make[2]: *** [src/CMakeFiles/paho-mqtt3as.dir/build.make:179: src/libpaho-mqtt3as.so.1.3.13] Error 1 > make[1]: *** [CMakeFiles/Makefile2:321: src/CMakeFiles/paho-mqtt3as.dir/all] Error 2 > make: *** [Makefile:166: all] Error 2 For full logs, run 'nix log /nix/store/519ajxyj9vgzzk0mi1yll0df29synv5z-paho.mqtt.c-static-x86_64-unknown-linux-musl-1.3.13.drv'. ``` Co-authored-by: Nikolay Korotkiy <sikmir@disroot.org>
2024-02-27 11:45:40 +00:00
cmakeFlags = [
(lib.cmakeBool "PAHO_WITH_SSL" true)
(lib.cmakeBool "PAHO_BUILD_STATIC" enableStatic)
(lib.cmakeBool "PAHO_BUILD_SHARED" enableShared)
];
2022-10-04 08:36:50 +00:00
meta = with lib; {
description = "Eclipse Paho MQTT C Client Library";
homepage = "https://www.eclipse.org/paho/";
license = licenses.epl20;
maintainers = with maintainers; [ sikmir ];
platforms = platforms.unix;
};
}