This file is part of MXE. See LICENSE.md for licensing information.

Contains ad hoc patches for cross building.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jonas Kvinge <jonas@jkvinge.net>
Date: Tue, 11 Oct 2022 18:27:06 +0200
Subject: [PATCH 1/1] MinGW build fixes


diff --git a/C/7zip_gcc_c.mak b/C/7zip_gcc_c.mak
index 1111111..2222222 100644
--- a/C/7zip_gcc_c.mak
+++ b/C/7zip_gcc_c.mak
@@ -93,7 +93,7 @@ DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll
 endif
 
 
-LIB2 = -lOle32 -loleaut32 -luuid -ladvapi32 -lUser32
+LIB2 = -lOle32 -loleaut32 -luuid -ladvapi32 -luser32
 
 CXXFLAGS_EXTRA = -DUNICODE -D_UNICODE
 # -Wno-delete-non-virtual-dtor
@@ -157,7 +157,7 @@ $(PROGPATH_STATIC): $(OBJS)
 
 ifndef NO_DEFAULT_RES
 $O/resource.o: resource.rc
-	windres.exe $(RFLAGS) resource.rc $O/resource.o
+	$(WINDRES) $(RFLAGS) resource.rc $O/resource.o
 endif
 
 
diff --git a/C/Alloc.c b/C/Alloc.c
index 1111111..2222222 100644
--- a/C/Alloc.c
+++ b/C/Alloc.c
@@ -6,7 +6,7 @@
 #include <stdio.h>
 
 #ifdef _WIN32
-#include <Windows.h>
+#include <windows.h>
 #endif
 #include <stdlib.h>
 
diff --git a/C/CpuArch.c b/C/CpuArch.c
index 1111111..2222222 100644
--- a/C/CpuArch.c
+++ b/C/CpuArch.c
@@ -217,7 +217,7 @@ BoolInt CPU_Is_InOrder()
 }
 
 #if !defined(MY_CPU_AMD64) && defined(_WIN32)
-#include <Windows.h>
+#include <windows.h>
 static BoolInt CPU_Sys_Is_SSE_Supported()
 {
   OSVERSIONINFO vi;
@@ -275,7 +275,7 @@ BoolInt CPU_IsSupported_SHA()
 // #include <stdio.h>
 
 #ifdef _WIN32
-#include <Windows.h>
+#include <windows.h>
 #endif
 
 BoolInt CPU_IsSupported_AVX2()
@@ -351,7 +351,7 @@ BoolInt CPU_IsSupported_PageGB()
 
 #ifdef _WIN32
 
-#include <Windows.h>
+#include <windows.h>
 
 BoolInt CPU_IsSupported_CRC32()  { return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) ? 1 : 0; }
 BoolInt CPU_IsSupported_CRYPTO() { return IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) ? 1 : 0; }
diff --git a/C/DllSecur.c b/C/DllSecur.c
index 1111111..2222222 100644
--- a/C/DllSecur.c
+++ b/C/DllSecur.c
@@ -5,7 +5,7 @@
 
 #ifdef _WIN32
 
-#include <Windows.h>
+#include <windows.h>
 
 #include "DllSecur.h"
 
diff --git a/C/Threads.h b/C/Threads.h
index 1111111..2222222 100644
--- a/C/Threads.h
+++ b/C/Threads.h
@@ -5,7 +5,7 @@
 #define __7Z_THREADS_H
 
 #ifdef _WIN32
-#include <Windows.h>
+#include <windows.h>
 #else
 
 #if defined(__linux__)
diff --git a/CPP/7zip/7zip_gcc.mak b/CPP/7zip/7zip_gcc.mak
index 1111111..2222222 100644
--- a/CPP/7zip/7zip_gcc.mak
+++ b/CPP/7zip/7zip_gcc.mak
@@ -113,8 +113,8 @@ MY_MKDIR=mkdir
 DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll
 endif
 
-LIB2_GUI = -lOle32 -lGdi32 -lComctl32 -lComdlg32 $(LIB_HTMLHELP)
-LIB2 = -loleaut32 -luuid -ladvapi32 -lUser32 $(LIB2_GUI)
+LIB2_GUI = -lole32 -lgdi32 -lcomctl32 -lcomdlg32 $(LIB_HTMLHELP)
+LIB2 = -loleaut32 -luuid -ladvapi32 -luser32 $(LIB2_GUI)
 
 CXXFLAGS_EXTRA = -DUNICODE -D_UNICODE
 # -Wno-delete-non-virtual-dtor
@@ -206,7 +206,7 @@ $(PROGPATH_STATIC): $(OBJS)
 
 ifndef NO_DEFAULT_RES
 $O/resource.o: resource.rc
-	windres.exe $(RFLAGS) resource.rc $O/resource.o
+	$(WINDRES) $(RFLAGS) resource.rc $O/resource.o
 endif
 
 $O/LzmaAlone.o: LzmaAlone.cpp
diff --git a/CPP/7zip/Bundles/LzmaCon/makefile.gcc b/CPP/7zip/Bundles/LzmaCon/makefile.gcc
index 1111111..2222222 100644
--- a/CPP/7zip/Bundles/LzmaCon/makefile.gcc
+++ b/CPP/7zip/Bundles/LzmaCon/makefile.gcc
@@ -77,6 +77,7 @@ WIN_OBJS = \
   $O/FileIO.o \
   $O/PropVariant.o \
   $O/System.o \
+  $O/Registry.o \
   $O/SystemInfo.o \
 
 COMPRESS_OBJS = \
diff --git a/CPP/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp
index 1111111..2222222 100644
--- a/CPP/7zip/Common/FileStreams.cpp
+++ b/CPP/7zip/Common/FileStreams.cpp
@@ -1,6 +1,7 @@
 // FileStreams.cpp
 
 #include "StdAfx.h"
+#include <stdio.h>
 
 // #include <stdio.h>
 
diff --git a/CPP/7zip/MyVersionInfo.rc b/CPP/7zip/MyVersionInfo.rc
index 1111111..2222222 100644
--- a/CPP/7zip/MyVersionInfo.rc
+++ b/CPP/7zip/MyVersionInfo.rc
@@ -1,2 +1,2 @@
 #include "MyVersion.h"
-#include "..\..\C\7zVersion.rc"
+#include "../../C/7zVersion.rc"
diff --git a/CPP/Common/MyInitGuid.h b/CPP/Common/MyInitGuid.h
index 1111111..2222222 100644
--- a/CPP/Common/MyInitGuid.h
+++ b/CPP/Common/MyInitGuid.h
@@ -29,7 +29,7 @@ Also we need IID_IUnknown that is initialized in some file for linking:
 #include <basetyps.h>
 #endif
 
-#include <InitGuid.h>
+#include <initguid.h>
 
 #ifdef UNDER_CE
 DEFINE_GUID(IID_IUnknown,
diff --git a/CPP/Common/MyString.h b/CPP/Common/MyString.h
index 1111111..2222222 100644
--- a/CPP/Common/MyString.h
+++ b/CPP/Common/MyString.h
@@ -4,6 +4,7 @@
 #define __COMMON_MY_STRING_H
 
 #include <string.h>
+#include <windows.h>
 
 #ifndef _WIN32
 #include <wctype.h>
diff --git a/CPP/Common/MyWindows.h b/CPP/Common/MyWindows.h
index 1111111..2222222 100644
--- a/CPP/Common/MyWindows.h
+++ b/CPP/Common/MyWindows.h
@@ -5,7 +5,7 @@
 
 #ifdef _WIN32
 
-#include <Windows.h>
+#include <windows.h>
 
 #ifdef UNDER_CE
   #undef VARIANT_TRUE
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h
index 1111111..2222222 100644
--- a/CPP/Windows/FileIO.h
+++ b/CPP/Windows/FileIO.h
@@ -17,7 +17,7 @@
 #ifdef _WIN32
 
 #if defined(_WIN32) && !defined(UNDER_CE)
-#include <WinIoCtl.h>
+#include <winioctl.h>
 #endif
 
 #else
