From b155e882ec4127336df8f6da32d3961c6f1fef85 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Thu, 22 Feb 2018 19:47:53 -0800 Subject: [PATCH 1/4] Fix build on mingw & cygwin --- Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Makefile b/Makefile index 68eb9db..72c0782 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,19 @@ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man +SYS := $(shell gcc -dumpmachine) +CYGWIN := $(findstring cygwin,$(SYS)) +MINGW32 := $(findstring mingw32,$(SYS)) + +# https://stackoverflow.com/a/21749803/1432614 +ifdef CYGWIN + CXXFLAGS += -U__STRICT_ANSI__ +endif + +ifdef MINGW32 + CXXFLAGS += -static +endif + ENABLE_MAN ?= no DOCBOOK_XSL ?= http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl @@ -27,6 +40,10 @@ OBJFILES = \ OBJFILES += crypto-openssl-10.o crypto-openssl-11.o LDFLAGS += -lcrypto +ifdef MINGW32 + LDFLAGS += -lgdi32 +endif + XSLTPROC ?= xsltproc DOCBOOK_FLAGS += --param man.output.in.separate.dir 1 \ --stringparam man.output.base.dir man/ \ From 804f7c99a1f453a1c959404e7b8728af810c4355 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Thu, 22 Feb 2018 19:48:18 -0800 Subject: [PATCH 2/4] Ignore .exes on mingw/cygwin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 81afb4a..d32d72a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o git-crypt +git-crypt.exe From 701fb8e708e2dae95d4664501cd062450fdf4126 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Thu, 22 Feb 2018 19:49:16 -0800 Subject: [PATCH 3/4] Set cout to unbuffered on mingw/cygwin (fixes #144) --- util-win32.cpp | 1 + util.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/util-win32.cpp b/util-win32.cpp index 4c47a2d..6965c48 100644 --- a/util-win32.cpp +++ b/util-win32.cpp @@ -170,6 +170,7 @@ static void init_std_streams_platform () { _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); + std::cout.setf(std::ios::unitbuf); } void create_protected_file (const char* path) // TODO diff --git a/util.cpp b/util.cpp index 4e1aa78..75bdf7b 100644 --- a/util.cpp +++ b/util.cpp @@ -150,7 +150,7 @@ void init_std_streams () init_std_streams_platform(); } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__CYGWIN__) #include "util-win32.cpp" #else #include "util-unix.cpp" From 0dec70739b3f4e6d22007c102f581448c4e9d2f1 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Fri, 23 Feb 2018 07:42:49 -0800 Subject: [PATCH 4/4] Replace gcc with $CXX in Makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 72c0782..0c14f10 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man -SYS := $(shell gcc -dumpmachine) +SYS := $(shell $(CXX) -dumpmachine) CYGWIN := $(findstring cygwin,$(SYS)) MINGW32 := $(findstring mingw32,$(SYS)) @@ -84,7 +84,7 @@ CLEAN_TARGETS := clean-bin $(CLEAN_MAN_TARGETS-$(ENABLE_MAN)) clean: $(CLEAN_TARGETS) clean-bin: - rm -f $(OBJFILES) git-crypt + rm -f $(OBJFILES) git-crypt git-crypt.exe clean-man: rm -f man/man1/git-crypt.1