Commit 7fe6b335 authored by Greg Hellings's avatar Greg Hellings
Browse files

sword: enable Windows building

Modify build techniques for SWORD so that it compiles on Windows and we
can remove the platforms tag
parent 7869ffb0
Loading
Loading
Loading
Loading
+109 −47
Original line number Diff line number Diff line
@@ -5,10 +5,20 @@
  pkg-config,
  icu,
  clucene_core,

  autoreconfHook,
  bzip2,
  curl,
  xz,
}:

stdenv.mkDerivation (finalAttrs: {
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";

@@ -17,12 +27,27 @@ stdenv.mkDerivation (finalAttrs: {
      hash = "sha256-QkCc894vrxEIUj4sWsB0XSH57SpceO2HjuncwwNCa4o=";
    };

  nativeBuildInputs = [ pkg-config ];
  buildInputs = [
    nativeBuildInputs =
      [
        pkg-config
      ]
      ++ (lib.optionals stdenv.hostPlatform.isWindows [
        autoreconfHook # The Windows patch modifies autotools files
      ]);

    buildInputs =
      [
        icu
      ]
      ++ (lib.optionals stdenv.hostPlatform.isUnix [
        clucene_core
        curl
  ];
      ])
      ++ (lib.optionals stdenv.hostPlatform.isWindows [
        bzip2
        curlDep
        xz
      ]);

    outputs = [
      "out"
@@ -33,17 +58,50 @@ stdenv.mkDerivation (finalAttrs: {
      patchShebangs .;
    '';

  configureFlags = [
    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"
    ];

  CXXFLAGS = [
    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";
@@ -58,7 +116,11 @@ stdenv.mkDerivation (finalAttrs: {
        texts in around 100 languages.
      '';
      license = lib.licenses.gpl2;
    maintainers = with lib.maintainers; [ AndersonTorres greg ];
    platforms = lib.platforms.unix;
      maintainers = with lib.maintainers; [
        AndersonTorres
        greg
      ];
      platforms = lib.platforms.all;
    };
})
  }
)
+13 −0
Original line number Diff line number Diff line
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