build: Add basic support for MinGW hosts.

This doesn't fully work yet (the FS code in libroot_build
needs to be adapted, as some of the symlink-related calls
are not available on MinGW), but it gets much further than
the "Cygwin" target did.
This commit is contained in:
Augustin Cavalier
2018-11-23 16:24:25 -05:00
parent 37c106060a
commit 807304b100
9 changed files with 79 additions and 42 deletions
+2 -1
View File
@@ -242,7 +242,7 @@ HOST_UNARFLAGS ?= x ;
# check the host platform compatibility # check the host platform compatibility
SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host
: linux openbsd freebsd darwin ; : linux openbsd freebsd darwin mingw ;
HOST_PLATFORM_(host)_COMPATIBLE = 1 ; HOST_PLATFORM_(host)_COMPATIBLE = 1 ;
if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd
@@ -670,6 +670,7 @@ switch $(HOST_PLATFORM) {
case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ; case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ;
case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ; case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ;
case darwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_DARWIN ; case darwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_DARWIN ;
case mingw : HOST_DEFINES += HAIKU_HOST_PLATFORM_MINGW ;
} }
# define host platform 64 bit macro # define host platform 64 bit macro
+3 -3
View File
@@ -685,9 +685,9 @@ rule BuildPlatformSharedLibrary
if $(HOST_PLATFORM) = darwin { if $(HOST_PLATFORM) = darwin {
LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ]
-dynamic -dynamiclib -Xlinker -flat_namespace ; -dynamic -dynamiclib -Xlinker -flat_namespace ;
# } else if $(HOST_PLATFORM) = cygwin { } else if $(HOST_PLATFORM) = mingw {
# LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ]
# -shared -Xlinker --allow-multiple-definition ; -shared -Xlinker --allow-multiple-definition ;
} else { } else {
LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ]
-shared -Xlinker -soname=\"$(target:G=)\" ; -shared -Xlinker -soname=\"$(target:G=)\" ;
+4 -4
View File
@@ -322,7 +322,7 @@ rule Cc
actions Cc actions Cc
{ {
$(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)" ; $(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)"
} }
rule C++ rule C++
@@ -399,13 +399,13 @@ rule C++
actions C++ actions C++
{ {
$(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)"
} }
# Force recreation of the archive to avoid build errors caused by
# stale dependencies after renaming or deleting object files.
actions together Archive actions together Archive
{ {
# Force recreation of the archive to avoid build errors caused by
# stale dependencies after renaming or deleting object files.
$(RM) $(<) $(RM) $(<)
$(AR) $(<) $(>) $(AR) $(<) $(>)
} }
Vendored Executable → Regular
+1
View File
@@ -782,6 +782,7 @@ case "${platform}" in
Haiku) HOST_PLATFORM=haiku_host ;; Haiku) HOST_PLATFORM=haiku_host ;;
Linux) HOST_PLATFORM=linux ;; Linux) HOST_PLATFORM=linux ;;
OpenBSD) HOST_PLATFORM=openbsd ;; OpenBSD) HOST_PLATFORM=openbsd ;;
MINGW*) HOST_PLATFORM=mingw ;;
*) echo Unsupported platform: ${platform} *) echo Unsupported platform: ${platform}
exit 1 ;; exit 1 ;;
esac esac
+19 -1
View File
@@ -1,6 +1,21 @@
#ifndef BEOS_BUILD_COMPATIBILITY_H #ifndef BEOS_BUILD_COMPATIBILITY_H
#define BEOS_BUILD_COMPATIBILITY_H #define BEOS_BUILD_COMPATIBILITY_H
// These things have to be done before anything is included
#if defined(HAIKU_HOST_PLATFORM_MINGW)
#define _MODE_T_
#define _POSIX_
typedef int mode_t;
#include <stdint.h>
#include <limits.h>
typedef uint32_t uid_t;
typedef uint32_t gid_t;
#include <io.h>
#define mkdir(path, mode) mkdir(path)
#endif
// DEFFILEMODE is not available on MinGW and on platforms with MUSL // DEFFILEMODE is not available on MinGW and on platforms with MUSL
#ifndef DEFFILEMODE #ifndef DEFFILEMODE
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
@@ -25,9 +40,12 @@ typedef unsigned long haiku_build_addr_t;
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h> #include <unistd.h>
#if !defined(HAIKU_HOST_PLATFORM_MINGW)
#include <sys/uio.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
+15
View File
@@ -0,0 +1,15 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_MINGW_ENDIAN
#define _HAIKU_BUILD_COMPATIBILITY_MINGW_ENDIAN
// There's no <endian.h> in MinGW.
#include <sys/param.h>
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BIG_ENDIAN BIG_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#endif // _HAIKU_BUILD_COMPATIBILITY_MINGW_ENDIAN
-22
View File
@@ -1,22 +0,0 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_SUNOS_ENDIAN
#define _HAIKU_BUILD_COMPATIBILITY_SUNOS_ENDIAN
// There's no <endian.h> in Solaris.
#include <sys/byteorder.h>
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __PDP_ENDIAN 3412
#if defined(_LITTLE_ENDIAN)
#define BYTE_ORDER __LITTLE_ENDIAN
#elif defined(_BIG_ENDIAN)
#define BYTE_ORDER __BIG_ENDIAN
#else
#error Unable to determine byte order!
#endif
#define __BYTE_ORDER BYTE_ORDER
#endif // _HAIKU_BUILD_COMPATIBILITY_SUNOS_ENDIAN
+33 -11
View File
@@ -49,7 +49,9 @@ init_error_map()
ADD_ERROR(ERANGE); ADD_ERROR(ERANGE);
ADD_ERROR(EPROTOTYPE); ADD_ERROR(EPROTOTYPE);
ADD_ERROR(EPROTONOSUPPORT); ADD_ERROR(EPROTONOSUPPORT);
ADD_ERROR(EPFNOSUPPORT); #ifdef EPFNOSUPPORT
ADD_ERROR(EPFNOSUPPORT);
#endif
ADD_ERROR(EAFNOSUPPORT); ADD_ERROR(EAFNOSUPPORT);
ADD_ERROR(EADDRINUSE); ADD_ERROR(EADDRINUSE);
ADD_ERROR(EADDRNOTAVAIL); ADD_ERROR(EADDRNOTAVAIL);
@@ -60,7 +62,9 @@ init_error_map()
ADD_ERROR(ECONNRESET); ADD_ERROR(ECONNRESET);
ADD_ERROR(EISCONN); ADD_ERROR(EISCONN);
ADD_ERROR(ENOTCONN); ADD_ERROR(ENOTCONN);
ADD_ERROR(ESHUTDOWN); #ifdef ESHUTDOWN
ADD_ERROR(ESHUTDOWN);
#endif
ADD_ERROR(ECONNREFUSED); ADD_ERROR(ECONNREFUSED);
ADD_ERROR(EHOSTUNREACH); ADD_ERROR(EHOSTUNREACH);
ADD_ERROR(ENOPROTOOPT); ADD_ERROR(ENOPROTOOPT);
@@ -68,25 +72,41 @@ init_error_map()
ADD_ERROR(EINPROGRESS); ADD_ERROR(EINPROGRESS);
ADD_ERROR(EALREADY); ADD_ERROR(EALREADY);
ADD_ERROR(EILSEQ); ADD_ERROR(EILSEQ);
ADD_ERROR(ENOMSG); #ifdef ENOMSG
ADD_ERROR(ESTALE); ADD_ERROR(ENOMSG);
#endif
#ifdef ESTALE
ADD_ERROR(ESTALE);
#endif
ADD_ERROR(EOVERFLOW); ADD_ERROR(EOVERFLOW);
ADD_ERROR(EMSGSIZE); ADD_ERROR(EMSGSIZE);
ADD_ERROR(EOPNOTSUPP); ADD_ERROR(EOPNOTSUPP);
ADD_ERROR(ENOTSOCK); ADD_ERROR(ENOTSOCK);
ADD_ERROR(EHOSTDOWN); #ifdef EHOSTDOWN
ADD_ERROR(EBADMSG); ADD_ERROR(EHOSTDOWN);
#endif
#ifdef EBADMSG
ADD_ERROR(EBADMSG);
#endif
#ifdef ECANCELED #ifdef ECANCELED
ADD_ERROR(ECANCELED); ADD_ERROR(ECANCELED);
#endif #endif
ADD_ERROR(EDESTADDRREQ); ADD_ERROR(EDESTADDRREQ);
ADD_ERROR(EDQUOT); #ifdef EDQUOT
ADD_ERROR(EIDRM); ADD_ERROR(EDQUOT);
ADD_ERROR(EMULTIHOP); #endif
#ifdef EIDRM
ADD_ERROR(EIDRM);
#endif
#ifdef EMULTIHOP
ADD_ERROR(EMULTIHOP);
#endif
#ifdef ENODATA #ifdef ENODATA
ADD_ERROR(ENODATA); ADD_ERROR(ENODATA);
#endif #endif
ADD_ERROR(ENOLINK); #ifdef ENOLINK
ADD_ERROR(ENOLINK);
#endif
#ifdef ENOSR #ifdef ENOSR
ADD_ERROR(ENOSR); ADD_ERROR(ENOSR);
#endif #endif
@@ -98,7 +118,9 @@ init_error_map()
#ifdef ETIME #ifdef ETIME
ADD_ERROR(ETIME); ADD_ERROR(ETIME);
#endif #endif
ADD_ERROR(ETXTBSY); #ifdef ETXTBSY
ADD_ERROR(ETXTBSY);
#endif
ADD_ERROR(ENOMEM); ADD_ERROR(ENOMEM);
ADD_ERROR(EACCES); ADD_ERROR(EACCES);
ADD_ERROR(EINTR); ADD_ERROR(EINTR);
+2
View File
@@ -33,6 +33,8 @@ switch $(HOST_PLATFORM) {
DEFINES += HAVE_STRCHRNUL HAVE_FUNOPEN ; DEFINES += HAVE_STRCHRNUL HAVE_FUNOPEN ;
case darwin : case darwin :
DEFINES += HAVE_FUNOPEN HAVE_QSORT_R ; DEFINES += HAVE_FUNOPEN HAVE_QSORT_R ;
case mingw :
DEFINES += ;
case * : case * :
Exit $(SUBDIR)/Jamfile: "Please add a case for your platform" Exit $(SUBDIR)/Jamfile: "Please add a case for your platform"
"($(HOST_PLATFORM))!" ; "($(HOST_PLATFORM))!" ;