crosstool-ng / crosstool-ng

A versatile (cross-)toolchain generator.
Other
2.07k stars 653 forks source link

mingw patches / how to build #1405

Open GitMensch opened 3 years ago

GitMensch commented 3 years ago

I did not found the following information and wanted to drop it it here - you may close this issue, copy part of it to documentation, include the patches or whatever you like. This information is partially written from mind so it may not be complete, still should give a good starter.

Prerequistes (rough outline):

Patches:

#./konfig/nconf.c, line 368, didn't want to search for a replacement, gnulib likely has one
+#ifdef _WIN32
+static char *strcasestr(const char *str, const char *pattern) {
+    size_t i;
+
+    if (!*pattern)
+        return (char*)str;
+
+    for (; *str; str++) {
+        if (toupper((unsigned char)*str) == toupper((unsigned char)*pattern)) {
+            for (i = 1;; i++) {
+                if (!pattern[i])
+                    return (char*)str;
+                if (toupper((unsigned char)str[i]) != toupper((unsigned char)pattern[i]))
+                    break;
+            }
+        }
+    }
+    return NULL;
+}
+
 static void print_function_line(void)
#./konfig/confdata.c, line 15, didn't want to search for a nicer version replacement, gnulib likely has one
 #include <unistd.h>

+#ifdef _WIN32
+#define mkdir(p,m) mkdir(p)
+#endif
+
 #include "lkc.h"

Then run make and use crosstool-ng per standard instructions.

Note: depending on the way you've got crosstool-ng and where you've unpacked it first you may have to manually rename some of the patch files (make will in this case say "don't know how to make 0011-xyz-long-name.patch` and the file name is shortened, in that case just rename via Explorer to the requested name and you should be fine).

Note: for the current curses version you also need a matching libgcc_s_sjlj-1.dll, if you don't have that, you may want to try this one. When using ct-ng: always unset TERM, otherwise it won't work from within msys.

mingwandroid commented 3 years ago

MinGW as a project is all but dead.

Any reason not to use mingw-w64?

alfred-lijun commented 2 years ago

thanks very much!

GitMensch commented 2 years ago

MinGW as a project is all but dead.

Nope, they still work on it (just with a pace that is much slower than mingw-w64), see its mailing list and the "recent" release of GCC currently at 9.2 - later than the post which claims it is dead ;-)

Any reason not to use mingw-w64?

One reason would be the often lesser dependency and support back to Win9x while mingw-w64 seems to be depending on Windows Server 2008 / Win Vista and its packaging within MSYS2 needs Windows Server 2008 R2 / Windows 7 (cygwin deprecated Windows Server 2008, too).