From 0677f49c83dbf2b987c8a387a8c1192167e14d4a Mon Sep 17 00:00:00 2001
From: superfury <[EMAIL REDACTED]>
Date: Fri, 16 Sep 2022 11:15:04 +0200
Subject: [PATCH] - Added support for the Sony PSP to the Makefile and headers.
---
Makefile.psp | 22 ++++++++++++++++++++++
SDLnetsys.h | 8 +++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
create mode 100644 Makefile.psp
diff --git a/Makefile.psp b/Makefile.psp
new file mode 100644
index 0000000..30e839a
--- /dev/null
+++ b/Makefile.psp
@@ -0,0 +1,22 @@
+TARGET_LIB = libSDL2_net.a
+OBJS= SDLnet.o \
+ SDLnetselect.o \
+ SDLnetTCP.o \
+ SDLnetUDP.o \
+
+INCDIR = .
+CFLAGS = -g -O2 -G0 -Wall -D__PSP__ $(shell $(PSPBIN)/sdl2-config --cflags)
+CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
+ASFLAGS = $(CFLAGS)
+
+PSPBIN = $(shell psp-config -d)/bin
+
+LDFLAGS=-L$(shell psp-config --pspsdk-path)/lib
+LIBS=-lc -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser
+
+install: $(TARGET_LIB)
+ cp $(TARGET_LIB) $(shell psp-config --psp-prefix)/lib
+ cp SDL_net.h $(shell psp-config --psp-prefix)/include
+
+PSPSDK=$(shell psp-config --pspsdk-path)
+include $(PSPSDK)/lib/build.mak
diff --git a/SDLnetsys.h b/SDLnetsys.h
index 825d1cc..51a0e37 100644
--- a/SDLnetsys.h
+++ b/SDLnetsys.h
@@ -41,7 +41,7 @@
#include <ws2tcpip.h>
#include <iphlpapi.h>
#else /* UNIX */
-#ifdef __OS2__
+#if defined(__OS2__) || defined(__PSP__)
#include <sys/param.h>
#endif
#include <sys/types.h>
@@ -58,10 +58,16 @@
#endif
#include <netinet/tcp.h>
#include <sys/socket.h>
+#ifndef __PSP__
#include <net/if.h>
+#endif
#include <netdb.h>
#endif /* WIN32 */
+#ifdef __PSP__
+#include <sys/select.h> /* for FD_SET, etc */
+#endif
+
#ifdef __OS2__
typedef int socklen_t;
#elif 0