diff --git a/.gitignore b/.gitignore index 81afb4a..d32d72a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o git-crypt +git-crypt.exe diff --git a/Makefile b/Makefile index 68eb9db..0c14f10 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,19 @@ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man +SYS := $(shell $(CXX) -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/ \ @@ -67,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 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"