termite: Add support for macOS (#43415)

Replace fetchgit with fetchFromGitHub now that it supports fetching
submodules. Remove unnecessary postPatch to add <math.h> as termite
already includes <cmath>. Add a patch to include <errno.h> on all
platforms and remove the --as-needed flag from ld on macOS.
This commit is contained in:
Michael Hoang 2018-07-14 09:00:39 +10:00 committed by xeji
parent 1e4cd7a810
commit d73fac6b10
3 changed files with 57 additions and 7 deletions

View file

@ -0,0 +1,24 @@
From 95c90f302c384f410dc92e64468ac7061b57fe2d Mon Sep 17 00:00:00 2001
From: Michael Hoang <enzime@users.noreply.github.com>
Date: Fri, 13 Jul 2018 19:03:09 +1000
Subject: [PATCH] Add errno.h header which isn't always included automatically.
---
termite.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/termite.cc b/termite.cc
index 160fe82..13e2572 100644
--- a/termite.cc
+++ b/termite.cc
@@ -21,6 +21,7 @@
#include <cstdlib>
#include <cstring>
#include <cmath>
+#include <errno.h>
#include <functional>
#include <limits>
#include <map>
--
2.17.1

View file

@ -1,4 +1,4 @@
{ stdenv, fetchgit, pkgconfig, vte, gtk3, ncurses, makeWrapper, wrapGAppsHook, symlinkJoin
{ stdenv, fetchFromGitHub, lib, pkgconfig, vte, gtk3, ncurses, makeWrapper, wrapGAppsHook, symlinkJoin
, configFile ? null
}:
@ -7,16 +7,17 @@ let
termite = stdenv.mkDerivation {
name = "termite-${version}";
src = fetchgit {
url = "https://github.com/thestinger/termite";
rev = "refs/tags/v${version}";
src = fetchFromGitHub {
owner = "thestinger";
repo = "termite";
rev = "v${version}";
sha256 = "02cn70ygl93ghhkhs3xdxn5b1yadc255v3yp8cmhhyzsv5027hvj";
fetchSubmodules = true;
};
# https://github.com/thestinger/termite/pull/516
patches = [ ./url_regexp_trailing.patch ];
postPatch = "sed '1i#include <math.h>' -i termite.cc";
patches = [ ./url_regexp_trailing.patch ./add_errno_header.patch
] ++ lib.optional stdenv.isDarwin ./remove_ldflags_macos.patch;
makeFlags = [ "VERSION=v${version}" "PREFIX=" "DESTDIR=$(out)" ];

View file

@ -0,0 +1,25 @@
From 1b5a6934635c55472eb7949bd87ab3f45fa1b2f3 Mon Sep 17 00:00:00 2001
From: Michael Hoang <enzime@users.noreply.github.com>
Date: Fri, 13 Jul 2018 19:01:51 +1000
Subject: [PATCH] Remove --as-needed flag from ld to fix compilation on macOS.
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b115f42..ab301ba 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ ifeq (${CXX}, clang++)
CXXFLAGS += -Wimplicit-fallthrough
endif
-LDFLAGS := -s -Wl,--as-needed ${LDFLAGS}
+LDFLAGS := -s -Wl ${LDFLAGS}
LDLIBS := ${shell pkg-config --libs ${GTK} ${VTE}}
termite: termite.cc url_regex.hh util/clamp.hh util/maybe.hh util/memory.hh
--
2.17.1