diff --git a/configure/os/CONFIG.Common.win32-x86-mingw b/configure/os/CONFIG.Common.win32-x86-mingw index a8390e6ef..8b83bf5b0 100644 --- a/configure/os/CONFIG.Common.win32-x86-mingw +++ b/configure/os/CONFIG.Common.win32-x86-mingw @@ -9,6 +9,7 @@ include $(CONFIG)/os/CONFIG.Common.UnixCommon OS_CLASS = WIN32 ARCH_CLASS = x86 +POSIX = NO # Definitions used when COMMANDLINE_LIBRARY is READLINE LDLIBS_READLINE = -lreadline -lcurses diff --git a/configure/os/CONFIG.linux-x86.windows-x64-mingw b/configure/os/CONFIG.linux-x86.windows-x64-mingw new file mode 100644 index 000000000..3692d6cb2 --- /dev/null +++ b/configure/os/CONFIG.linux-x86.windows-x64-mingw @@ -0,0 +1,22 @@ +# CONFIG.linux-x86.windows-x64-mingw +# +# Definitions for linux-x86 host windows-x64-mingw target builds +# Override these definitions in CONFIG_SITE.linux-x86.windows-x64-mingw +#------------------------------------------------------- + +# Include common gnu compiler definitions +include $(CONFIG)/CONFIG.gnuCommon + +# Add resource compiler +RCCMD = $(GNU_BIN)/$(CMPLR_PREFIX)windres$(CMPLR_SUFFIX) $(INCLUDES) $< $@ + +# Remove -fPIC flags, add out-implib +SHRLIB_CFLAGS = +SHRLIB_LDFLAGS = -shared -Wl,--out-implib,$(LIB_PREFIX)$*$(LIB_SUFFIX) +LOADABLE_SHRLIB_LDFLAGS = -shared -Wl,--out-implib,$(LIB_PREFIX)$*$(LIB_SUFFIX) + +# No need to explicitly link with gcc library +GNU_LDLIBS_YES = + +# Link with system libraries +OP_SYS_LDLIBS = -lws2_32 -ladvapi32 -luser32 -lkernel32 -lwinmm diff --git a/configure/os/CONFIG.linux-x86_64.windows-x64-mingw b/configure/os/CONFIG.linux-x86_64.windows-x64-mingw new file mode 100644 index 000000000..f84301266 --- /dev/null +++ b/configure/os/CONFIG.linux-x86_64.windows-x64-mingw @@ -0,0 +1,9 @@ +# CONFIG.linux-x86_64.windows-x64-mingw +# +# Definitions for linux-x86_64 host windows-x64-mingw target builds +# Override these definitions in CONFIG_SITE.linux-x86_64.windows-x64-mingw +#------------------------------------------------------- + +# Settings as for the linux-x86 host architecture +include $(CONFIG)/os/CONFIG.linux-x86.windows-x64-mingw + diff --git a/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw b/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw index 1d132b74d..cb624242b 100644 --- a/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw +++ b/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw @@ -5,10 +5,9 @@ # Early versions of the MinGW cross-build tools can only build # static (non-DLL) libraries. Fedora's cross-build of gcc 4.4.6 -# needs these uncommented, other distributions have not been -# tested with this release of Base: -SHARED_LIBRARIES = NO -STATIC_BUILD = YES +# needs these uncommented, cross-gcc 4.6.3 for Ubuntu does not: +#SHARED_LIBRARIES = NO +#STATIC_BUILD = YES # The cross-build tools are in $(GNU_DIR)/bin # Default is /usr @@ -21,3 +20,6 @@ STATIC_BUILD = YES CMPLR_PREFIX = i686-pc-mingw32- # Debian? #CMPLR_PREFIX = i586-mingw32msvc- + +# Use static compiler-support libraries +OP_SYS_LDFLAGS += -static-libgcc -static-libstdc++ diff --git a/configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw b/configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw new file mode 100644 index 000000000..026410cfe --- /dev/null +++ b/configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw @@ -0,0 +1,23 @@ +# CONFIG_SITE.linux-x86.windows-x64-mingw +# +# Configuration for linux-x86 host windows-x64-mingw target builds +#------------------------------------------------------- + +# Early versions of the MinGW cross-build tools can only build +# static (non-DLL) libraries. For example RHEL's cross-gcc 4.4.6 +# needs these uncommented, cross-gcc 4.6.3 for Ubuntu does not: +#SHARED_LIBRARIES = NO +#STATIC_BUILD = YES + +# The cross-build tools are in $(GNU_DIR)/bin +# Default is /usr +#GNU_DIR = /usr/local + +# Different distribution cross-build packages use different prefixes: +# Ubuntu: +#CMPLR_PREFIX = i686-w64-mingw32- +# RHEL: +CMPLR_PREFIX = x86_64-w64-mingw32- + +# Use static compiler-support libraries +OP_SYS_LDFLAGS += -static-libgcc -static-libstdc++ diff --git a/configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw b/configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw new file mode 100644 index 000000000..e98ac7a02 --- /dev/null +++ b/configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw @@ -0,0 +1,8 @@ +# CONFIG_SITE.linux-x86_64.windows-x64-mingw +# +# Configuration for linux-x86_64 host windows-x64-mingw target builds +#------------------------------------------------------- + +# Inherit from the linux-x86 host architecture +include $(CONFIG)/os/CONFIG_SITE.linux-x86.windows-x64-mingw + diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 10daf1016..bf44e11ab 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,37 @@ +

MinGW Cross-builds from Linux

+ +

Build configuration files have been back-ported from the 3.15 branch that +allow cross-building of the windows-x64-mingw target from either linux-x86 or +linux-x86_64 hosts. Similar support for the 32-bit win32-x86-mingw cross-target +was added in Base-3.14.12.5. Adjust the settings in the configuration file +configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw and add windows-x64-mingw +to the CROSS_COMPILER_TARGET_ARCHS variable in configure/CONFIG_SITE or in +configure/os/CONFIG_SITE.linux-x86.Common.

+ +

The Linux MinGW cross-builds now use the compiler flags -static-libgcc +-static-libstdc++ which avoids having to copy some DLLs onto the Windows +system to be able to run the generated binaries. These compiler flags can be +disabled by editing the configure/os/CONFIG_SITE.linux-x86.target file +for Linux distributions where the cross-build toolset doesn't make static +versions of those libraries available. The RHEL-6.8 MinGW toolset does not +package a static version of the library winpthread-1 so on that host OS it is +still necessary to provide a copy of the libwinpthread-1.dll file for the +Windows system to use. The simplest way to do this is to manually copy it into +the IOC application's bin/win32-x86-mingw or bin/windows-x64-mingw directory +after building the IOC, like this (note that Windows DLLs are always installed +into the bin directory, not the lib directory):

+ +
+$ cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll bin/win32-x86-mingw
+$ cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll bin/windows-x64-mingw
+
+ +

Some additional MinGW-specific changes have also been back-ported from the +Base-3.15 branch.

+

General Time updates

The iocInit code now performs a sanity check of the current time diff --git a/src/libCom/osi/os/WIN32/epicsGetopt.c b/src/libCom/osi/os/WIN32/epicsGetopt.c index 97bb11f47..1ea064ea2 100644 --- a/src/libCom/osi/os/WIN32/epicsGetopt.c +++ b/src/libCom/osi/os/WIN32/epicsGetopt.c @@ -1,3 +1,5 @@ +#ifndef _MINGW + /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -121,3 +123,5 @@ int getopt(nargc, nargv, ostr) } return (optopt); /* dump back option letter */ } + +#endif /* !_MINGW */ diff --git a/src/libCom/osi/os/WIN32/epicsGetopt.h b/src/libCom/osi/os/WIN32/epicsGetopt.h index aa3bc7422..f92041085 100644 --- a/src/libCom/osi/os/WIN32/epicsGetopt.h +++ b/src/libCom/osi/os/WIN32/epicsGetopt.h @@ -12,6 +12,12 @@ #ifndef _EPICS_GETOPT_H #define _EPICS_GETOPT_H +#ifdef _MINGW + +#include + +#else /* _MINGW */ + #include "shareLib.h" #ifdef __cplusplus @@ -28,4 +34,6 @@ epicsShareExtern int optind, opterr, optopt; } #endif +#endif /* _MINGW */ + #endif /* _EPICS_GETOPT_H */ diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 7f3d34500..5f61fc894 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -92,7 +92,7 @@ static const int osdRealtimePriorityList [osdRealtimePriorityStateCount] = #if !defined(EPICS_DLL_NO) BOOL WINAPI DllMain ( - HANDLE hModule, DWORD dwReason, LPVOID lpReserved ) + HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved ) { static DWORD dllHandleIndex; HMODULE dllHandle = 0;