Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building irpmonc with MinGW #106

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

depdirs = \
libcallbackstreamdll \
libdparserdll \
libreqlistdll \
libsymbolsdll \
irpmondll \
libserver

maindirs = irpmonc irpmon-server

otherdirs = device-connector shared

.PHONY: all clean $(depdirs) $(maindirs) $(otherdirs)

all: $(otherdirs) $(maindirs)

$(maindirs): $(depdirs)
$(MAKE) -C $@

$(depdirs) $(otherdirs):
$(MAKE) -C $@

libserver: device-connector

clean:
$(foreach dir,$(depdirs) $(maindirs) $(otherdirs),$(MAKE) -C $(dir) $@ &&) :
20 changes: 20 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# for cross-building with MinGW
CROSS = x86_64-w64-mingw32-
INCLUDES = -I/usr/share/mingw-w64/include

INCLUDES += -I../include -I../shared
CPPFLAGS += $(INCLUDES) -O2
CFLAGS += $(INCLUDES) -O2

CC = $(CROSS)gcc
LD = $(CROSS)ld
CXX = $(CROSS)g++

all: $(EXE)

$(EXE): $(OBJS)
$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)

clean:
rm -f $(EXE) $(OBJS) $(DELOBJS)
7 changes: 7 additions & 0 deletions device-connector/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = device-connector.dll
OBJS = device-connector.o

include ../common.mk
9 changes: 9 additions & 0 deletions irpmon-server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

LDFLAGS += -L../libserver -mconsole
LDLIBS += -lserver

EXE = server
OBJS = server.o
DELOBJS = $(EXE).exe

include ../common.mk
16 changes: 16 additions & 0 deletions irpmonc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

CPPFLAGS += -DNOVSOCKETS

LDFLAGS += -municode \
-L../irpmondll -L../libdparserdll -L../libreqlistdll \
-L../libsymbolsdll -L../libcallbackstreamdll

LDLIBS += \
-lirpmondll -llibdparser -llibreqlist \
-llibsymbols -lcallbackstream

EXE = irpmonc
OBJS = driver-settings.o irpmonc.o guid-api.o stop-event.o
DELOBJS = $(EXE).exe

include ../common.mk
7 changes: 7 additions & 0 deletions irpmondll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = irpmondll.dll
OBJS = driver-com.o main.o

include ../common.mk
7 changes: 7 additions & 0 deletions libcallbackstreamdll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = libcallbackstream.dll
OBJS = callback-stream.o

include ../common.mk
7 changes: 7 additions & 0 deletions libdparserdll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = libdparser.dll
OBJS = dparser.o

include ../common.mk
7 changes: 7 additions & 0 deletions libreqlistdll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = libreqlist.dll
OBJS = reqlist.o

include ../common.mk
9 changes: 9 additions & 0 deletions libserver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

CFLAGS += -DNOVSOCKETS -D_WIN32_WINNT=0x0600
LDFLAGS += -shared -L../device-connector
LDLIBS += -ldevice-connector -lws2_32

EXE = libserver.dll
OBJS = libserver.o

include ../common.mk
12 changes: 12 additions & 0 deletions libserver/libserver.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <winsvc.h>
#ifndef NOVSOCKETS
#include "libvsock.h"
#endif
#include "irpmondll-types.h"
#include "network-connector.h"
#include "device-connector.h"
Expand Down Expand Up @@ -258,8 +262,11 @@ DWORD IRPMonServerStart(const char *Address, const char *Port, HANDLE ExitEvent)
goto Exit;
}

#ifndef NOVSOCKETS
useVSockets = strcmp(Address, "vsock") == 0;
#endif
if (useVSockets) {
#ifndef NOVSOCKETS
ADDRINFOA localAddrs;
struct sockaddr *a = NULL;
int aLen = 0;
Expand All @@ -282,6 +289,7 @@ DWORD IRPMonServerStart(const char *Address, const char *Port, HANDLE ExitEvent)
addrs->ai_addrlen = aLen;
addrs->ai_family = LibVSockGetAddressFamily();
addrs->ai_socktype = SOCK_STREAM;
#endif
} else {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
Expand All @@ -295,9 +303,13 @@ DWORD IRPMonServerStart(const char *Address, const char *Port, HANDLE ExitEvent)
}

ret = _Listener(addrs, ExitEvent);
#ifndef NOVSOCKETS
if (useVSockets)
LibVSockAddressFree(addrs->ai_addr);
else freeaddrinfo(addrs);
#else
freeaddrinfo(addrs);
#endif
Cleanup:
WSACleanup();
Exit:
Expand Down
7 changes: 7 additions & 0 deletions libsymbolsdll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = libsymbols.dll
OBJS = symbols.o

include ../common.mk
7 changes: 7 additions & 0 deletions libvsock/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = libvsock.dll
OBJS = libvsock.o

include ../common.mk
7 changes: 7 additions & 0 deletions shared/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LDFLAGS += -shared

EXE = request.dll
OBJS = request.o

include ../common.mk