From 323d016db8a5bbf921034ca6f2a4ccfad19c338b Mon Sep 17 00:00:00 2001 From: Mikal Villa Date: Sat, 2 Aug 2014 23:15:57 +0200 Subject: [PATCH] [Anoncoin] Adding i2psam --- .gitignore | 1 + i2psam.cpp | 11 ------- i2psam.h | 24 +++++--------- makefile.linux-mingw | 8 ++--- makefile.mingw | 78 ++++++++++++++++++++++++++++++++++++++++++++ makefile.unix | 4 +-- 6 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 .gitignore create mode 100644 makefile.mingw diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbe22c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +libi2psam.a diff --git a/i2psam.cpp b/i2psam.cpp index 9d6fea9..9540962 100644 --- a/i2psam.cpp +++ b/i2psam.cpp @@ -4,17 +4,6 @@ //-------------------------------------------------------------------------------------------------- #include "i2psam.h" -#ifdef WIN32 -//#define _WIN32_WINNT 0x0501 -#define WIN32_LEAN_AND_MEAN 1 -#define FD_SETSIZE -#include -#else -#include -#include // for sockaddr_in -#include // for ntohs and htons -#endif - #include #include #include // for memset diff --git a/i2psam.h b/i2psam.h index 299a8e2..6791437 100644 --- a/i2psam.h +++ b/i2psam.h @@ -12,18 +12,15 @@ #include #include -//#ifdef WIN32 -////#define _WIN32_WINNT 0x0501 -//#define WIN32_LEAN_AND_MEAN 1 -//#define FD_SETSIZE -//#include -//#else -//#include -//#include // for sockaddr_in -//#include // for ntohs and htons -//#endif - -#ifndef WIN32 +#ifdef WIN32 +//#define _WIN32_WINNT 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#include +#else +#include +#include // for sockaddr_in +#include // for ntohs and htons +#endif // TODO: check a possible bug about cast -1 to SOCKET #define SAM_INVALID_SOCKET (-1) @@ -236,9 +233,6 @@ public: const sockaddr_in& getAddress() const; private: - struct SocketImpl; - std::auto_ptr impl_; - SOCKET socket_; sockaddr_in servAddr_; std::string SAMHost_; diff --git a/makefile.linux-mingw b/makefile.linux-mingw index 200bef3..1e4d302 100644 --- a/makefile.linux-mingw +++ b/makefile.linux-mingw @@ -7,13 +7,13 @@ ####### Compiler, tools and options -CC = i586-mingw32msvc-gcc -CXX = i586-mingw32msvc-g++ +CC = i686-w64-mingw32-gcc +CXX = i686-w64-mingw32-g++ DEFINES = -D_MT -DWIN32 -D_WINDOWS -CFLAGS = -pipe -isystem /usr/i586-mingw32msvc/include/ -O2 -Wall -Wextra $(DEFINES) +CFLAGS = -pipe -isystem /usr/i686-w64-mingw32/include/ -O2 -Wall -Wextra $(DEFINES) CXXFLAGS = -O2 -fexceptions -Wall -Wextra $(DEFINES) INCPATH = -I'../../dependencies/mingw32/qt/include' -I'../../dependencies/mingw32' -I'../../dependencies/mingw32/qt/include/ActiveQt' -I'../../dependencies/mingw32/qt/mkspecs/unsupported/win32-g++-cross' -LIB = i586-mingw32msvc-ar -ru +LIB = i686-w64-mingw32-ar -ru COPY = cp SED = sed COPY_FILE = $(COPY) diff --git a/makefile.mingw b/makefile.mingw new file mode 100644 index 0000000..1e4d302 --- /dev/null +++ b/makefile.mingw @@ -0,0 +1,78 @@ +############################################################################# +# Makefile for building: libi2psam +# Generated by qmake (2.01a) (Qt 4.8.3) on: ?? ????. 10 02:43:02 2013 +# Project: i2psam.pro +# Template: lib +############################################################################# + +####### Compiler, tools and options + +CC = i686-w64-mingw32-gcc +CXX = i686-w64-mingw32-g++ +DEFINES = -D_MT -DWIN32 -D_WINDOWS +CFLAGS = -pipe -isystem /usr/i686-w64-mingw32/include/ -O2 -Wall -Wextra $(DEFINES) +CXXFLAGS = -O2 -fexceptions -Wall -Wextra $(DEFINES) +INCPATH = -I'../../dependencies/mingw32/qt/include' -I'../../dependencies/mingw32' -I'../../dependencies/mingw32/qt/include/ActiveQt' -I'../../dependencies/mingw32/qt/mkspecs/unsupported/win32-g++-cross' +LIB = i686-w64-mingw32-ar -ru +COPY = cp +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = cp -R +DEL_FILE = rm -f +DEL_DIR = rmdir +MOVE = mv +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) + +####### Files + +SOURCES = i2psam.cpp +OBJECTS = i2psam.o +TARGET = libi2psam.a + +####### Implicit rules + +.SUFFIXES: .cpp .cc .cxx .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +first: all +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(LIB) $(TARGET) $(OBJECTS) + +clean: + -$(DEL_FILE) release/$(TARGET) + -$(DEL_FILE) release/i2psam.o + +distclean: clean + -$(DEL_FILE) $(TARGET) + +####### Compile + +release/i2psam.o: i2psam.cpp i2psam.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/i2psam.o i2psam.cpp + +####### Install + +FORCE: + diff --git a/makefile.unix b/makefile.unix index c247e0c..f38879e 100644 --- a/makefile.unix +++ b/makefile.unix @@ -10,8 +10,8 @@ CC = gcc CXX = g++ -CFLAGS = -m64 -pipe -O2 -fPIC -Wall -W -D_REENTRANT $(DEFINES) -CXXFLAGS = -m64 -pipe -O2 -fPIC -Wall -W -D_REENTRANT $(DEFINES) +CFLAGS = -pipe -O2 -fPIC -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -O2 -fPIC -Wall -W -D_REENTRANT $(DEFINES) AR = ar cqs RANLIB = TAR = tar -cf