From c04b21d77eaafbbcd46a543387b0b919dcedc672 Mon Sep 17 00:00:00 2001
From: "Wesley W. Terpstra" <w.terpstra@gsi.de>
Date: Fri, 10 Feb 2012 09:55:21 +0000
Subject: [PATCH] Port back to linux

---
 api/Makefile             | 11 +++++------
 api/transport/posix-ip.h |  5 +++--
 api/transport/ssh.c      |  4 ++++
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/api/Makefile b/api/Makefile
index b8f6584..a14f735 100644
--- a/api/Makefile
+++ b/api/Makefile
@@ -1,4 +1,5 @@
-TARGET  = i586-mingw32msvc-
+#TARGET  = i586-mingw32msvc-
+#LIBS	= -lwsock32 -lws2_32
 FLAGS	= -Wall -Wmissing-declarations -O0 -g -m32
 
 #FLAGS	:= $(FLAGS) -DEB_USE_DYNAMIC    # deterministic untill table overflow (default)
@@ -12,8 +13,6 @@ CXXFLAGS= $(FLAGS)
 CC	= $(TARGET)gcc
 CXX	= $(TARGET)g++
 
-LIBS	= -lwsock32 -lws2_32
-
 GOALS	= demo/sizes demo/eb-read demo/eb-write demo/eb-snoop test/loopback
 LIBRARY	= etherbone.a
 OBJECTS	= $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SOURCES)))
@@ -42,9 +41,9 @@ all:	$(GOALS) $(LIBRARY)
 
 $(LIBRARY):	$(OBJECTS)
 	rm -f $@
-	i586-mingw32msvc-g++ $(CXXFLAGS) -shared -Wl,--out-implib=libetherbone.dll.a -Wl,--output-def,etherbone.def -o $@ $^ $(LIBS)
-#	$(TARGET)ar rcs $@ $^
-#	$(TARGET)ranlib $@
+#	i586-mingw32msvc-g++ $(CXXFLAGS) -shared -Wl,--out-implib=libetherbone.dll.a -Wl,--output-def,etherbone.def -o $@ $^ $(LIBS)
+	$(TARGET)ar rcs $@ $^
+	$(TARGET)ranlib $@
 
 demo/%:	demo/%.c $(LIBRARY)
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
diff --git a/api/transport/posix-ip.h b/api/transport/posix-ip.h
index 8c8f83b..f831c1c 100644
--- a/api/transport/posix-ip.h
+++ b/api/transport/posix-ip.h
@@ -28,6 +28,8 @@
 #ifndef EB_POSIX_IP_H
 #define EB_POSIX_IP_H
 
+#include "../etherbone.h"
+
 #ifdef __WIN32
 #define _WIN32_WINNT 0x0501
 #define MSG_DONTWAIT 0 // !!!
@@ -43,11 +45,10 @@ typedef SOCKET eb_posix_sock_t;
 #include <sys/time.h>
 #include <netinet/in.h>
 #include <netdb.h>
+#include <unistd.h>
 typedef eb_descriptor_t eb_posix_sock_t;
 #endif
 
-#include "../etherbone.h"
-
 EB_PRIVATE void eb_posix_ip_close(eb_posix_sock_t sock);
 EB_PRIVATE eb_posix_sock_t eb_posix_ip_open(int type, int port);
 EB_PRIVATE socklen_t eb_posix_ip_resolve(const char* prefix, const char* address, int type, struct sockaddr_storage* out);
diff --git a/api/transport/ssh.c b/api/transport/ssh.c
index 05ede8f..f190ed1 100644
--- a/api/transport/ssh.c
+++ b/api/transport/ssh.c
@@ -35,6 +35,10 @@
 #include <stdlib.h>
 #include <errno.h>
 
+#ifndef __WIN32
+#include <unistd.h>
+#endif
+
 eb_status_t eb_ssh_open(struct eb_transport* transportp, int port) {
   /* noop */
   return EB_OK;
-- 
GitLab