From 49a1247dc150c5c11a50225c98b142838e10110d Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Sun, 30 Nov 2014 09:27:40 +0300
Subject: [PATCH 21/27] Auto detect WINDRES with autoconf.

Fix building .rc files.
---
 builds/posix/make.defaults       |  4 +++-
 builds/posix/make.rules          |  4 ++--
 builds/posix/make.shared.targets | 10 +++++-----
 configure.in                     | 10 ++++++++++
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults
index 2ad21f93f5..a3836acf9a 100755
--- a/builds/posix/make.defaults
+++ b/builds/posix/make.defaults
@@ -139,9 +139,11 @@ ECHO=			echo
 QUIET_ECHO=		@echo
 CD=			cd
 CAT=			cat
-AR=			ar @AR_OPTIONS@ crsu
+AR=			@AR@ @AR_OPTIONS@ crsu
 LN=			@LN_S@
+DLLTOOL=			@DLLTOOL@
 RANLIB=			@RANLIB@
+RC=			@RC@
 BTYACC=$(ROOT)/extern/btyacc/btyacc
 
 CC =	@CC@
diff --git a/builds/posix/make.rules b/builds/posix/make.rules
index a784cb21ab..600b8f9e6a 100644
--- a/builds/posix/make.rules
+++ b/builds/posix/make.rules
@@ -115,5 +115,5 @@ $(OBJ)/%.o: $(SRC_ROOT)/%.cpp
 
 # Rules for making resource files
 
-$(GEN_ROOT)/%.res: $(SRC_ROOT)/%.rc
-	windres --output-format=coff --include-dir=$(<D) $< $@
+$(OBJ)/%.res: $(SRC_ROOT)/%.rc
+	$(RC) --output-format=coff --include-dir=$(<D) $< $@
diff --git a/builds/posix/make.shared.targets b/builds/posix/make.shared.targets
index ff5c2a2b1c..f881106012 100644
--- a/builds/posix/make.shared.targets
+++ b/builds/posix/make.shared.targets
@@ -93,16 +93,16 @@ $(BLRTABLE): $(BLRTABLE_Objects)
 
 # Adding resources as prerequisite for some files
 
-$(FilesToAddVersionInfo): $(GEN_ROOT)/jrd/version.res
-$(FilesToAddDialog): $(GEN_ROOT)/remote/os/win32/window.res
-$(FilesToAddDialog2): $(GEN_ROOT)/iscguard/iscguard.res
+$(FilesToAddVersionInfo): $(OBJ)/jrd/version.res
+$(FilesToAddDialog): $(OBJ)/remote/os/win32/window.res
+$(FilesToAddDialog2): $(OBJ)/iscguard/iscguard.res
 
 # Explicit dependence of resource script
-$(GEN_ROOT)/remote/os/win32/window.res: $(SRC_ROOT)/remote/os/win32/window.rc $(SRC_ROOT)/remote/os/win32/window.rh \
+$(OBJ)/remote/os/win32/window.res: $(SRC_ROOT)/remote/os/win32/window.rc $(SRC_ROOT)/remote/os/win32/window.rh \
  $(SRC_ROOT)/jrd/version.rc $(SRC_ROOT)/jrd/build_no.h $(SRC_ROOT)/remote/os/win32/property.rc \
  $(SRC_ROOT)/remote/os/win32/property.rh
 
-$(GEN_ROOT)/iscguard/iscguard.res: $(SRC_ROOT)/iscguard/iscguard.rc $(SRC_ROOT)/iscguard/iscguard.rh \
+$(OBJ)/iscguard/iscguard.res: $(SRC_ROOT)/iscguard/iscguard.rc $(SRC_ROOT)/iscguard/iscguard.rh \
  $(SRC_ROOT)/jrd/version.rc 
 
 .PHONY: FORCE
diff --git a/configure.in b/configure.in
index 10ad6a2857..17509964ff 100644
--- a/configure.in
+++ b/configure.in
@@ -684,6 +684,16 @@ AC_LIBTOOL_DLOPEN
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_MAKE_SET
 AC_PROG_LIBTOOL
+if test $PLATFORM = win32; then
+  # Checks for mingw resource compiler.
+  AC_CHECK_PROGS([RC],
+     [$target-windres \
+      windres])
+
+  if test -z "${RC}"; then
+    AC_MSG_ERROR(windres command is not found.);
+  fi
+fi
 
 dnl Check for system header files
 AC_HEADER_DIRENT
-- 
2.13.0

