ircd
-config.mak
+ircd.exe
+config.mk
TARGET:=ircd
SOURCES:=$(wildcard *.c NetSock/*.c)
HEADERS:=$(wildcard *.h NetSock/*.h)
--include config.mak
+-include config.mk
.PHONY: all clean
-all: $(TARGET)
+all: $(TARGET) $(if $(CC.w32),$(TARGET).exe,)
clean:
- $(RM) $(TARGET)
+ $(RM) $(TARGET) $(TARGET).exe
$(TARGET): $(SOURCES) $(HEADERS)
$(CC) $(CFLAGS) $(LDFLAGS) $(SOURCES) $(LDLIBS) -o $@
+$(TARGET).exe: $(SOURCES) $(HEADERS)
+ $(CC.w32) $(CFLAGS.w32) $(LDFLAGS.w32) $(SOURCES) $(LDLIBS.w32) -o $@
// Windows
#if defined(_WIN32)
+#ifndef I_KNOW_HOW_TO_USE_A_LINKER
#pragma message("Warning: Windows detected.")
#pragma message("IMPORTANT: COMPILE WITH -lws2_32")
#pragma comment(lib, "ws2_32.lib")
+#endif
//#include <WinSock2.h>
//#include <WS2tcpip.h>
//#include <Windows.h>
#include <ws2tcpip.h>
#include <windows.h>
//#define PRISocket "llu" // The format string for SOCKET
+#ifndef PRISocket
#define PRISocket "p" // The format string for SOCKET
+#endif
#define net_errno() (WSAGetLastError())
#define net_wouldblock() (WSAGetLastError() == WSAEWOULDBLOCK)
// Funcs
const char *net_strerror(int e);
// Variables
extern struct WSAData net_wd;
+#define SHUT_RD SD_RECEIVE
+#define SHUT_WR SD_SEND
+#define SHUT_RDWR SD_BOTH
// POSIX
#else
--- /dev/null
+HEADERS+=config.mk
+CC=clang
+CFLAGS=-Wall -Wextra
+CC.w32=i686-w64-mingw32-gcc
+CFLAGS.w32=-Wall -Wextra -DPRISocket='"u"' -DI_KNOW_HOW_TO_USE_A_LINKER -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
+LDLIBS.w32=-lws2_32
} else if(strncmp(packet, "NICK ", 5) == 0) {
// User now registered
setNick(client, packet+5, 32);
- printf("USER SET NICKNAME %lu %s\n", client->nickLen, client->nick);
+ printf("USER SET NICKNAME %s\n", client->nick);
fflush(stdout);
} else if(strncmp(packet, "USER ", 5) == 0) {
// Send welcome