Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on Mingw/Cygwin (fixes #144) #145

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.o
git-crypt
git-crypt.exe
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/ \
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions util-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down