diff --git a/pkgs/by-name/sw/sword/package.nix b/pkgs/by-name/sw/sword/package.nix index a893d2e2d414..d2be17e78d92 100644 --- a/pkgs/by-name/sw/sword/package.nix +++ b/pkgs/by-name/sw/sword/package.nix @@ -5,60 +5,122 @@ pkg-config, icu, clucene_core, + + autoreconfHook, + bzip2, curl, + xz, }: -stdenv.mkDerivation (finalAttrs: { - pname = "sword"; - version = "1.9.0"; +stdenv.mkDerivation ( + finalAttrs: + let + # Used on Windows, where libpsl doesn't compile, yet + curlDep = curl.override { pslSupport = false; }; + in + { + pname = "sword"; + version = "1.9.0"; - src = fetchurl { - url = "https://www.crosswire.org/ftpmirror/pub/sword/source/v${lib.versions.majorMinor finalAttrs.version}/sword-${finalAttrs.version}.tar.gz"; - hash = "sha256-QkCc894vrxEIUj4sWsB0XSH57SpceO2HjuncwwNCa4o="; - }; + src = fetchurl { + url = "https://www.crosswire.org/ftpmirror/pub/sword/source/v${lib.versions.majorMinor finalAttrs.version}/sword-${finalAttrs.version}.tar.gz"; + hash = "sha256-QkCc894vrxEIUj4sWsB0XSH57SpceO2HjuncwwNCa4o="; + }; - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ - icu - clucene_core - curl - ]; + nativeBuildInputs = + [ + pkg-config + ] + ++ (lib.optionals stdenv.hostPlatform.isWindows [ + autoreconfHook # The Windows patch modifies autotools files + ]); - outputs = [ - "out" - "dev" - ]; + buildInputs = + [ + icu + ] + ++ (lib.optionals stdenv.hostPlatform.isUnix [ + clucene_core + curl + ]) + ++ (lib.optionals stdenv.hostPlatform.isWindows [ + bzip2 + curlDep + xz + ]); - prePatch = '' - patchShebangs .; - ''; + outputs = [ + "out" + "dev" + ]; - configureFlags = [ - "--without-conf" - "--enable-tests=no" - ]; - - CXXFLAGS = [ - "-Wno-unused-but-set-variable" - "-Wno-unknown-warning-option" - # compat with icu61+ https://github.com/unicode-org/icu/blob/release-64-2/icu4c/readme.html#L554 - "-DU_USING_ICU_NAMESPACE=1" - ]; - - meta = { - description = "Software framework that allows research manipulation of Biblical texts"; - homepage = "https://www.crosswire.org/sword/"; - longDescription = '' - The SWORD Project is the CrossWire Bible Society's free Bible software - project. Its purpose is to create cross-platform open-source tools -- - covered by the GNU General Public License -- that allow programmers and - Bible societies to write new Bible software more quickly and easily. We - also create Bible study software for all readers, students, scholars, and - translators of the Bible, and have a growing collection of many hundred - texts in around 100 languages. + prePatch = '' + patchShebangs .; ''; - license = lib.licenses.gpl2; - maintainers = with lib.maintainers; [ AndersonTorres greg ]; - platforms = lib.platforms.unix; - }; -}) + + preConfigure = lib.optionalString stdenv.hostPlatform.isWindows '' + substituteInPlace configure --replace-fail "-no-undefined" "-Wl,-no-undefined" + ''; + + patches = lib.optional stdenv.hostPlatform.isWindows ./sword-1.9.0-diatheke-includes.patch; + + configureFlags = + [ + "--without-conf" + "--enable-tests=no" + ] + ++ (lib.optionals stdenv.hostPlatform.isWindows [ + "--with-xz" + "--with-bzip2" + "--with-icuregex" + ]); + + makeFlags = lib.optionals stdenv.hostPlatform.isWindows [ + "LDFLAGS=-no-undefined" + ]; + + env = { + # When placed in nativeBuildInputs, icu.dev is finding the native ICU libs, but setting it + # explicitly here has it finding the platform appropriate version + ICU_CONFIG = lib.optionalString stdenv.hostPlatform.isWindows "${icu.dev}/bin/icu-config --noverify"; + CURL_CONFIG = lib.optionalString stdenv.hostPlatform.isWindows "${lib.getDev curlDep}/bin/curl-config"; + + CXXFLAGS = ( + builtins.concatStringsSep " " ( + [ + "-Wno-unused-but-set-variable" + "-Wno-unknown-warning-option" + # compat with icu61+ https://github.com/unicode-org/icu/blob/release-64-2/icu4c/readme.html#L554 + "-DU_USING_ICU_NAMESPACE=1" + ] + ++ (lib.optionals stdenv.hostPlatform.isWindows [ + "-Wint-to-pointer-cast" + "-fpermissive" + "-D_ICUSWORD_" + "-DCURL_STATICLIB" + ]) + ) + ); + }; + + meta = { + description = "Software framework that allows research manipulation of Biblical texts"; + homepage = "https://www.crosswire.org/sword/"; + longDescription = '' + The SWORD Project is the CrossWire Bible Society's free Bible software + project. Its purpose is to create cross-platform open-source tools -- + covered by the GNU General Public License -- that allow programmers and + Bible societies to write new Bible software more quickly and easily. We + also create Bible study software for all readers, students, scholars, and + translators of the Bible, and have a growing collection of many hundred + texts in around 100 languages. + ''; + license = lib.licenses.gpl2; + maintainers = with lib.maintainers; [ + AndersonTorres + greg + ]; + platforms = lib.platforms.all; + }; + } +) diff --git a/pkgs/by-name/sw/sword/sword-1.9.0-diatheke-includes.patch b/pkgs/by-name/sw/sword/sword-1.9.0-diatheke-includes.patch new file mode 100644 index 000000000000..182ec53d2183 --- /dev/null +++ b/pkgs/by-name/sw/sword/sword-1.9.0-diatheke-includes.patch @@ -0,0 +1,13 @@ +diff --git a/utilities/diatheke/Makefile.am b/utilities/diatheke/Makefile.am +index 8ba34e5..545af2c 100644 +--- a/utilities/diatheke/Makefile.am ++++ b/utilities/diatheke/Makefile.am +@@ -1,5 +1,8 @@ + AUTOMAKE_OPTIONS = 1.6 + ++if USE_INTERNAL_REGEX ++AM_CPPFLAGS = -I$(top_srcdir)/include/internal/regex ++endif + LDADD = $(top_builddir)/lib/libsword.la + + bin_PROGRAMS = diatheke