From dcd484702ed7be933403e0710a803cec293de4d2 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Wed, 25 Jun 2014 23:19:37 +0100 Subject: [PATCH] Build with newer toolchain. Various fixups to build under win-builds.org toolchain rather than MinGW. No longer builds under MinGW as I have removed headers/definitions that it lacks. --- Makefile | 16 +++++-- include/icftypes.h | 117 --------------------------------------------- include/netfw.h | 3 -- src/addr.c | 4 +- src/addrcache.c | 2 +- src/directplay.c | 3 +- src/firewall.c | 7 ++- src/interface.c | 5 +- src/interface.h | 5 +- src/ipxconfig.cpp | 3 +- src/ipxwrapper.c | 6 +-- src/ipxwrapper.h | 3 +- src/log.c | 1 + src/router.c | 4 +- src/winsock.c | 30 ++---------- 15 files changed, 45 insertions(+), 164 deletions(-) delete mode 100644 include/icftypes.h diff --git a/Makefile b/Makefile index 3ae2b4f..98c0b65 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,16 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +ifdef HOST +CC := $(HOST)-gcc +CXX := $(HOST)-g++ +endif + +WINDRES ?= $(shell \ + (which "$(HOST)-windres" > /dev/null 2>&1 && echo "$(HOST)-windres") \ + || echo "windres" \ +) + ifdef DEBUG DBG_OPT := -g else @@ -49,7 +59,7 @@ all: ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe dpwsockx.dll clean: rm -f ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe dpwsockx.dll - rm -f src/*.o src/*_stubs.s version.o Makefile.dep + rm -f src/*.o src/*_stubs.s icons/*.o version.o Makefile.dep rm -f tests/*.exe tests/*.o dist: all @@ -99,7 +109,7 @@ ipxwrapper.dll: $(IPXWRAPPER_DEPS) $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -shared -o ipxwrapper.dll $(IPXWRAPPER_DEPS) version.o -liphlpapi -lversion -lole32 -loleaut32 ipxconfig.exe: src/ipxconfig.cpp icons/ipxconfig.o src/addr.o src/interface.o src/common.o src/config.o src/wpcap_stubs.o - $(CXX) $(CXXFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -static-libstdc++ -D_WIN32_IE=0x0400 -mwindows -o ipxconfig.exe $^ -liphlpapi -lcomctl32 -lws2_32 + $(CXX) $(CXXFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -static-libstdc++ -D_WIN32_IE=0x0500 -mwindows -o ipxconfig.exe $^ -liphlpapi -lcomctl32 -lws2_32 dpwsockx.dll: src/directplay.o src/log.o src/dpwsockx_stubs.o src/common.o src/config.o src/addr.o src/dpwsockx.def $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -shared -o $@ $^ -lwsock32 @@ -120,7 +130,7 @@ src/wpcap_stubs.s: src/wpcap_stubs.txt perl mkstubs.pl src/wpcap_stubs.txt src/wpcap_stubs.s 5 icons/%.o: icons/%.rc icons/%.ico - windres $< -O coff -o $@ + $(WINDRES) $< -O coff -o $@ %.dll: src/stubdll.o src/%_stubs.o src/log.o src/common.o src/config.o src/addr.o src/%.def $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -shared -o $@ $^ diff --git a/include/icftypes.h b/include/icftypes.h deleted file mode 100644 index c3d7b33..0000000 --- a/include/icftypes.h +++ /dev/null @@ -1,117 +0,0 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 6.00.0366 */ -/* Compiler settings for icftypes.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - - -#ifndef __icftypes_h__ -#define __icftypes_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -/* header files for imported files */ -#include "wtypes.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -void * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void * ); - -/* interface __MIDL_itf_icftypes_0000 */ -/* [local] */ - -typedef -enum NET_FW_POLICY_TYPE_ - { NET_FW_POLICY_GROUP = 0, - NET_FW_POLICY_LOCAL = NET_FW_POLICY_GROUP + 1, - NET_FW_POLICY_EFFECTIVE = NET_FW_POLICY_LOCAL + 1, - NET_FW_POLICY_TYPE_MAX = NET_FW_POLICY_EFFECTIVE + 1 - } NET_FW_POLICY_TYPE; - -typedef -enum NET_FW_PROFILE_TYPE_ - { NET_FW_PROFILE_DOMAIN = 0, - NET_FW_PROFILE_STANDARD = NET_FW_PROFILE_DOMAIN + 1, - NET_FW_PROFILE_CURRENT = NET_FW_PROFILE_STANDARD + 1, - NET_FW_PROFILE_TYPE_MAX = NET_FW_PROFILE_CURRENT + 1 - } NET_FW_PROFILE_TYPE; - -typedef -enum NET_FW_IP_VERSION_ - { NET_FW_IP_VERSION_V4 = 0, - NET_FW_IP_VERSION_V6 = NET_FW_IP_VERSION_V4 + 1, - NET_FW_IP_VERSION_ANY = NET_FW_IP_VERSION_V6 + 1, - NET_FW_IP_VERSION_MAX = NET_FW_IP_VERSION_ANY + 1 - } NET_FW_IP_VERSION; - -typedef -enum NET_FW_SCOPE_ - { NET_FW_SCOPE_ALL = 0, - NET_FW_SCOPE_LOCAL_SUBNET = NET_FW_SCOPE_ALL + 1, - NET_FW_SCOPE_CUSTOM = NET_FW_SCOPE_LOCAL_SUBNET + 1, - NET_FW_SCOPE_MAX = NET_FW_SCOPE_CUSTOM + 1 - } NET_FW_SCOPE; - -typedef -enum NET_FW_IP_PROTOCOL_ - { NET_FW_IP_PROTOCOL_TCP = 6, - NET_FW_IP_PROTOCOL_UDP = 17 - } NET_FW_IP_PROTOCOL; - -typedef -enum NET_FW_SERVICE_TYPE_ - { NET_FW_SERVICE_FILE_AND_PRINT = 0, - NET_FW_SERVICE_UPNP = NET_FW_SERVICE_FILE_AND_PRINT + 1, - NET_FW_SERVICE_REMOTE_DESKTOP = NET_FW_SERVICE_UPNP + 1, - NET_FW_SERVICE_NONE = NET_FW_SERVICE_REMOTE_DESKTOP + 1, - NET_FW_SERVICE_TYPE_MAX = NET_FW_SERVICE_NONE + 1 - } NET_FW_SERVICE_TYPE; - - - -extern RPC_IF_HANDLE __MIDL_itf_icftypes_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_icftypes_0000_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/include/netfw.h b/include/netfw.h index a6f4289..84f969f 100644 --- a/include/netfw.h +++ b/include/netfw.h @@ -219,9 +219,6 @@ typedef struct NetFwMgr NetFwMgr; extern "C"{ #endif -void * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void * ); - #ifndef __INetFwRemoteAdminSettings_INTERFACE_DEFINED__ #define __INetFwRemoteAdminSettings_INTERFACE_DEFINED__ diff --git a/src/addr.c b/src/addr.c index 2eaee1d..0fc95c2 100644 --- a/src/addr.c +++ b/src/addr.c @@ -15,8 +15,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#define WINSOCK_API_LINKAGE + #include +#include #include #include #include diff --git a/src/addrcache.c b/src/addrcache.c index 56a6d1e..e7e2b2a 100644 --- a/src/addrcache.c +++ b/src/addrcache.c @@ -15,8 +15,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include #include +#include #include #include #include diff --git a/src/directplay.c b/src/directplay.c index 581b760..0c3333f 100644 --- a/src/directplay.c +++ b/src/directplay.c @@ -16,10 +16,11 @@ */ #define INITGUID +#define WINSOCK_API_LINKAGE +#include #include #include -#include #include #include "ipxwrapper.h" diff --git a/src/firewall.c b/src/firewall.c index 268a2b7..505061d 100644 --- a/src/firewall.c +++ b/src/firewall.c @@ -18,13 +18,18 @@ #define COBJMACROS #define CINTERFACE +#include #include #include -#include #include #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#include +#pragma GCC diagnostic pop + #include "ipxwrapper.h" /* Define the GUIDs of the relevant COM objects here since the ones in the diff --git a/src/interface.c b/src/interface.c index 5ff136b..46fd805 100644 --- a/src/interface.c +++ b/src/interface.c @@ -15,6 +15,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#define WINSOCK_API_LINKAGE + #include #include #include @@ -34,9 +36,6 @@ static CRITICAL_SECTION interface_cache_cs; static ipx_interface_t *interface_cache = NULL; static time_t interface_cache_ctime = 0; -/* Missing in MinGW... */ -char *_strdup(const char *strSource); - /* Fetch a list of network interfaces available on the system. * * Returns a linked list of IP_ADAPTER_INFO structures, all allocated within a diff --git a/src/interface.h b/src/interface.h index b2efba3..a6df2ca 100644 --- a/src/interface.h +++ b/src/interface.h @@ -32,7 +32,10 @@ extern "C" { /* TODO: Dynamic MTU, per interface. */ #define ETHERNET_MTU 1500 -#define WILDCARD_IFACE_HWADDR addr48_in((unsigned char[]){0x00,0x00,0x00,0x00,0x00,0x00}) +#define WILDCARD_IFACE_HWADDR ({ \ + const unsigned char x[] = {0x00,0x00,0x00,0x00,0x00,0x00}; \ + addr48_in(x); \ +}) typedef struct ipx_interface_ip ipx_interface_ip_t; diff --git a/src/ipxconfig.cpp b/src/ipxconfig.cpp index ebab14d..016fe08 100644 --- a/src/ipxconfig.cpp +++ b/src/ipxconfig.cpp @@ -460,7 +460,8 @@ static bool save_config() if(pri_index == 0) { - primary_iface = addr48_in((unsigned char[]){0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}); + const unsigned char f6[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + primary_iface = addr48_in(f6); } else{ /* Iterate over the NIC list to find the selected primary diff --git a/src/ipxwrapper.c b/src/ipxwrapper.c index 5a6d5df..25ae94d 100644 --- a/src/ipxwrapper.c +++ b/src/ipxwrapper.c @@ -15,8 +15,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#define WINSOCK_API_LINKAGE + #include +#include #include #include #include @@ -32,8 +34,6 @@ #include "router.h" #include "addrcache.h" -int _putenv(const char *envstring); - extern const char *version_string; extern const char *compile_time; diff --git a/src/ipxwrapper.h b/src/ipxwrapper.h index 69bd2c4..a63c2a7 100644 --- a/src/ipxwrapper.h +++ b/src/ipxwrapper.h @@ -17,8 +17,9 @@ #ifndef IPXWRAPPER_H #define IPXWRAPPER_H -#include + #include +#include #include #include #include diff --git a/src/log.c b/src/log.c index 60d9ea2..dd93aca 100644 --- a/src/log.c +++ b/src/log.c @@ -15,6 +15,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include diff --git a/src/router.c b/src/router.c index 0924476..cbf4baa 100644 --- a/src/router.c +++ b/src/router.c @@ -15,8 +15,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#define WINSOCK_API_LINKAGE + #include +#include #include #include #include diff --git a/src/winsock.c b/src/winsock.c index 27ea058..459f921 100644 --- a/src/winsock.c +++ b/src/winsock.c @@ -15,8 +15,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#define WINSOCK_API_LINKAGE + #include +#include #include #include #include @@ -28,32 +30,6 @@ #include "router.h" #include "addrcache.h" -#define XP_CONNECTIONLESS 0x00000001 -#define XP_GUARANTEED_DELIVERY 0x00000002 -#define XP_GUARANTEED_ORDER 0x00000004 -#define XP_MESSAGE_ORIENTED 0x00000008 -#define XP_PSEUDO_STREAM 0x00000010 -#define XP_GRACEFUL_CLOSE 0x00000020 -#define XP_EXPEDITED_DATA 0x00000040 -#define XP_CONNECT_DATA 0x00000080 -#define XP_DISCONNECT_DATA 0x00000100 -#define XP_SUPPORTS_BROADCAST 0x00000200 -#define XP_SUPPORTS_MULTICAST 0x00000400 -#define XP_BANDWITH_ALLOCATION 0x00000800 -#define XP_FRAGMENTATION 0x00001000 -#define XP_ENCRYPTS 0x00002000 - -typedef struct _PROTOCOL_INFO { - DWORD dwServiceFlags ; - INT iAddressFamily ; - INT iMaxSockAddr ; - INT iMinSockAddr ; - INT iSocketType ; - INT iProtocol ; - DWORD dwMessageSize ; - void *lpProtocol ; -} PROTOCOL_INFO; - struct sockaddr_ipx_ext { short sa_family; char sa_netnum[4];