summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2014-09-14 17:12:42 +0200
committerAndreas Baumann <abaumann@yahoo.com>2014-09-14 17:12:42 +0200
commitcecfe881aa8548ad2e7c62f2f0c6f04a09b6e4ef (patch)
treee1bf7db25f0392392f4cf3918b7c7ab968f81955
parent75746962c91e82725a764ccd09be1c9fd2593f25 (diff)
downloadbiruda-cecfe881aa8548ad2e7c62f2f0c6f04a09b6e4ef.tar.gz
biruda-cecfe881aa8548ad2e7c62f2f0c6f04a09b6e4ef.tar.bz2
started porting to native Windows, so far json-c is mising
-rw-r--r--INSTALL55
-rw-r--r--README2
-rw-r--r--src/GNUmakefile8
-rw-r--r--src/NMakefile52
-rw-r--r--src/biruda.c5
-rw-r--r--src/coordinator.c5
-rw-r--r--src/master.c5
-rw-r--r--src/sleep.h12
8 files changed, 135 insertions, 9 deletions
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..0d9ea01
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,55 @@
+Building on Windows
+-------------------
+
+* Any Visual Studio compiler should do fine
+* gengetopt: easiest is to install Cygwin and build your own version,
+ we just need the gengetopt.exe binary to generate the command line parser.
+ Alternatively you can build the *_cmdline.* files on Unix and copy them
+ to Windows:
+
+ # open a Cygwin shell
+ ./configure --prefix=/usr/local/bin
+ make
+ make install
+
+* confuse:
+
+ # Download the ZIP version
+ # Open windows\msvs.net.sln
+ # Choose Debug/Release
+ # eventually convert the solutions
+ # build
+ # create layout with bin, lib, include
+ # copy dlls into bin, libs into lib, *.h into include
+
+
+* pthreads-win32: for pthread emulation on Windows
+
+ # open a Visual Studio Command line
+ nmake clean vc-inlined-debug
+
+* nanomsg:
+
+ # Install cmake for Windows
+ # open a Visual Studio Command line
+ C:\Program Files\CMake\bin\cmake.exe .
+ # Open nanomsg.sln
+ # Choose Debug/Release
+ # Build the solution
+ # create layout with bin, lib, include
+ # copy dlls into bin, libs into lib, *.h into include
+
+* json-c:
+
+ # Open and convert json-c.vcproj
+ copy config.h.win32 config.h
+ copy json_config.h.in json_config.h
+ # Choose Debug/Release
+ # eventually convert the solutions
+ # build
+
+* biruda
+
+ # open a Visual Studio Command line
+ set PATH=%PATH%;c:\cygwin\bin
+ nmake /f NMakefile
diff --git a/README b/README
index b9266c4..132f1e0 100644
--- a/README
+++ b/README
@@ -25,7 +25,7 @@ Requirements
http://nanomsg.org/
* libmicrohttpd: for an embedded web interface
http://www.gnu.org/software/libmicrohttpd/
-* pthreads-win32: for pthread wrapper on Windows
+* pthreads: for threading support
http://sourceware.org/pthreads-win32/
* json-c: JSON for message payload
https://github.com/json-c/json-c/wiki
diff --git a/src/GNUmakefile b/src/GNUmakefile
index d3d1fb8..a5f0305 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -13,10 +13,10 @@ biruda: biruda.o biruda_cmdline.o master.o coordinator.o worker.o
$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
biruda_cmdline.o: biruda_cmdline.c
-biruda.o: biruda.c biruda_cmdline.h master.h coordinator.h worker.h
-master.o: master.c master.h
-coordinator.o: coordinator.c coordinator.h
-worker.o: worker.c worker.h
+biruda.o: biruda.c biruda_cmdline.h master.h coordinator.h worker.h sleep.h
+master.o: master.c master.h sleep.h
+coordinator.o: coordinator.c coordinator.h sleep.h
+worker.o: worker.c worker.h sleep.h
biruda_cmdline.c: biruda.ggo
gengetopt -F biruda_cmdline --unamed-opts --conf-parser --include-getopt -i $<
diff --git a/src/NMakefile b/src/NMakefile
new file mode 100644
index 0000000..562fb90
--- /dev/null
+++ b/src/NMakefile
@@ -0,0 +1,52 @@
+CYGWIN_DIR = C:\cygwin
+CYGWIN_PATH = C:\cygwin\bin
+
+CONFUSE_DIR = C:\develop\confuse-2.7
+PTHREADS_W32_DIR = C:\develop\pthreads-w32-2-9-1-release
+NANOMSG_DIR = C:\develop\nanomsg-0.4-beta
+
+GENGETOPT = $(CYGWIN_DIR)\usr\local\bin\gengetopt.exe
+
+!IFNDEF CC
+CC = cl
+!ENDIF
+!IFNDEF LINK
+LINK = link
+!ENDIF
+
+INCLUDE_DIRS = \
+ /I$(CONFUSE_DIR)\include \
+ /I$(PTHREADS_W32_DIR) \
+ /I$(NANOMSG_DIR)\include
+
+CLFLAGS = /TP /MD /W2 /WX /nologo /O2 $(INCLUDE_DIRS)
+LINKFLAGS = /nologo
+LIBS =
+
+.SUFFIXES: .c .obj .exe
+
+.c.obj:
+ $(CC) $(CLFLAGS) /c /Fo$@ $<
+
+all: biruda.exe
+
+biruda.exe: biruda.obj biruda_cmdline.obj master.obj coordinator.obj worker.obj
+ $(LINK) $(LINKFLAGS) -$(LIBS) /out:$@ $**
+
+biruda_cmdline.obj: biruda_cmdline.c
+biruda.obj: biruda.c biruda_cmdline.h master.h coordinator.h worker.h sleep.h
+master.obj: master.c master.h sleep.h
+coordinator.obj: coordinator.c coordinator.h sleep.h
+worker.obj: worker.c worker.h
+
+biruda_cmdline.c: biruda.ggo
+ $(GENGETOPT) -F biruda_cmdline --unamed-opts --conf-parser --include-getopt -i $**
+
+biruda_cmdline.h: biruda.ggo
+ $(GENGETOPT) -F biruda_cmdline --unamed-opts --conf-parser --include-getopt -i $**
+
+clean:
+ @-erase *.obj 2>NUL
+ @-erase biruda.exe 2>NUL
+ @-erase biruda_cmdline.h biruda_cmdline.c 2>NUL
+
diff --git a/src/biruda.c b/src/biruda.c
index c6679a0..fc50352 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -1,8 +1,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifdef _WIN32
+#else
#include <errno.h>
#include <unistd.h>
+#endif
#include "biruda_cmdline.h"
#include "confuse.h"
@@ -11,6 +14,8 @@
#include "worker.h"
#include "coordinator.h"
+#include "sleep.h"
+
static const char *DEFAULT_CONFIG_FILE = "/etc/biruda/biruda.conf";
static const unsigned int DEFAULT_WEBSERVER_PORT = 8080;
static const char *DEFAULT_WEBSERVER_HOST = "localhost";
diff --git a/src/coordinator.c b/src/coordinator.c
index 4bd2f0b..8cd2914 100644
--- a/src/coordinator.c
+++ b/src/coordinator.c
@@ -1,6 +1,6 @@
#include "coordinator.h"
-#include <pthread.h>
+#include "pthread.h"
#include "nanomsg/nn.h"
#include "nanomsg/survey.h"
@@ -8,9 +8,10 @@
#include "json-c/json.h"
#include <stdio.h>
-#include <unistd.h>
#include <string.h>
+#include "sleep.h"
+
static pthread_t coordinator_thread;
static int coordinator_sock;
static int coordinator_must_terminate = 0;
diff --git a/src/master.c b/src/master.c
index 770724e..9cbd994 100644
--- a/src/master.c
+++ b/src/master.c
@@ -1,6 +1,6 @@
#include "master.h"
-#include <pthread.h>
+#include "pthread.h"
#include "nanomsg/nn.h"
#include "nanomsg/survey.h"
@@ -8,9 +8,10 @@
#include "json-c/json.h"
#include <stdio.h>
-#include <unistd.h>
#include <string.h>
+#include "sleep.h"
+
static pthread_t master_thread;
static int master_sock;
static int master_must_terminate = 0;
diff --git a/src/sleep.h b/src/sleep.h
new file mode 100644
index 0000000..d71a845
--- /dev/null
+++ b/src/sleep.h
@@ -0,0 +1,12 @@
+#ifndef _BIRUDA_SLEEP_HEADER_INCLUDED
+#define _BIRUDA_SLEEP_HEADER_INCLUDED
+
+#ifndef _WIN32
+#include <unistd.h>
+#else
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+#define sleep( SECONDS ) Sleep( SECONDS * 1000 )
+#endif
+
+#endif