New package: I2PD

This commit is contained in:
LABPBS
2021-09-29 17:01:31 -03:00
parent fe043336dc
commit f4fd47c8bc
4 changed files with 183 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
diff --git a/libi2pd/util.cpp b/libi2pd/util.cpp
index f7b376f6..4f4bfcde 100644
--- a/libi2pd/util.cpp
+++ b/libi2pd/util.cpp
@@ -129,7 +129,7 @@ namespace util
pthread_set_name_np(pthread_self(), name);
#elif defined(__NetBSD__)
pthread_setname_np(pthread_self(), "%s", (void *)name);
-#else
+#elif not defined(_WIN32)
pthread_setname_np(pthread_self(), name);
#endif
}

View File

@@ -0,0 +1,45 @@
diff --git a/libi2pd/I2PEndian.h b/libi2pd/I2PEndian.h
index 9ffc28d0..1cff6552 100644
--- a/libi2pd/I2PEndian.h
+++ b/libi2pd/I2PEndian.h
@@ -34,24 +34,22 @@
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
-#else
-#define NEEDS_LOCAL_ENDIAN
-#include <cstdint>
-uint16_t htobe16(uint16_t int16);
-uint32_t htobe32(uint32_t int32);
-uint64_t htobe64(uint64_t int64);
-
-uint16_t be16toh(uint16_t big16);
-uint32_t be32toh(uint32_t big32);
-uint64_t be64toh(uint64_t big64);
-
-// assume LittleEndine
-#define htole16
-#define htole32
-#define htole64
-#define le16toh
-#define le32toh
-#define le64toh
+#elif defined(_WIN32)
+
+#define htobe16(x) __builtin_bswap16(x)
+#define htole16(x) (x)
+#define be16toh(x) __builtin_bswap16(x)
+#define le16toh(x) (x)
+
+#define htobe32(x) __builtin_bswap32(x)
+#define htole32(x) (x)
+#define be32toh(x) __builtin_bswap32(x)
+#define le32toh(x) (x)
+
+#define htobe64(x) __builtin_bswap64(x)
+#define htole64(x) (x)
+#define be64toh(x) __builtin_bswap64(x)
+#define le64toh(x) (x)
#endif

View File

@@ -0,0 +1,63 @@
diff --git a/Makefile b/Makefile
index d7765af7..29f7c39e 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ SYS := $(shell $(CXX) -dumpmachine)
ifneq (, $(findstring darwin, $(SYS)))
SHARED_SUFFIX = dylib
-else ifneq (, $(findstring mingw, $(SYS))$(findstring cygwin, $(SYS)))
+else ifneq (, $(findstring mingw, $(SYS))$(findstring windows-gnu, $(SYS))$(findstring cygwin, $(SYS)))
SHARED_SUFFIX = dll
else
SHARED_SUFFIX = so
@@ -47,13 +47,13 @@ ifneq (, $(findstring darwin, $(SYS)))
else
include Makefile.osx
endif
-else ifneq (, $(findstring linux, $(SYS))$(findstring gnu, $(SYS)))
+else ifneq (, $(findstring linux, $(SYS)))
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
include Makefile.linux
else ifneq (, $(findstring freebsd, $(SYS))$(findstring openbsd, $(SYS)))
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
include Makefile.bsd
-else ifneq (, $(findstring mingw, $(SYS))$(findstring cygwin, $(SYS)))
+else ifneq (, $(findstring mingw, $(SYS))$(findstring windows-gnu, $(SYS))$(findstring cygwin, $(SYS)))
DAEMON_SRC += Win32/DaemonWin32.cpp Win32/Win32App.cpp Win32/Win32NetState.cpp
include Makefile.mingw
else # not supported
diff --git a/Makefile.mingw b/Makefile.mingw
index e31d895e..fa8e8eb6 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -3,26 +3,16 @@ USE_WIN32_APP := yes
WINDRES = windres
-CXXFLAGS := $(CXX_DEBUG) -DWIN32_LEAN_AND_MEAN -fPIC -msse
+CXXFLAGS ?= $(CXX_DEBUG) -fPIC -msse
INCFLAGS = -I$(DAEMON_SRC_DIR) -IWin32
-LDFLAGS := ${LD_DEBUG} -static
-
-# detect proper flag for c++11 support by compilers
-CXXVER := $(shell $(CXX) -dumpversion)
-ifeq ($(shell expr match ${CXXVER} "[4]\.[7-9]\|4\.1[0-9]\|[5-6]"),4) # gcc 4.7 - 6
- NEEDED_CXXFLAGS += -std=c++11
-else ifeq ($(shell expr match ${CXXVER} "[1,7-9]"),1) # gcc >= 7
- NEEDED_CXXFLAGS += -std=c++17
-else # not supported
-$(error Compiler too old)
-endif
+NEEDED_CXXFLAGS += -std=c++17 -DWIN32_LEAN_AND_MEAN
# Boost libraries suffix
BOOST_SUFFIX = -mt
# UPNP Support
ifeq ($(USE_UPNP),yes)
- CXXFLAGS += -DUSE_UPNP -DMINIUPNP_STATICLIB
+ NEEDED_CXXFLAGS += -DUSE_UPNP
LDLIBS = -lminiupnpc
endif

61
mingw-w64-i2pd/PKGBUILD Normal file
View File

@@ -0,0 +1,61 @@
# Maintainer: Lucio Perusini <lucioperusini@gmail.com>
_realname=i2pd
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=2.39.0
pkgrel=1
pkgdesc='A full-featured C++ implementation of the I2P router (mingw-w64)'
url='https://i2pd.website/'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-boost"
"${MINGW_PACKAGE_PREFIX}-openssl"
"${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-miniupnpc")
options=('strip')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/PurpleI2P/i2pd/archive/${pkgver}.tar.gz"
"0001-i2pd-endian.patch"
"0001-i2pd-dont-use-pthread_setname.patch"
"0001-i2pd-makefile.patch")
sha256sums=('3ffeb614cec826e13b50e8306177018ecb8d873668dfe66aadc733ca9fcaa568'
'643e996fdb0ee422fbba5608210dd3803a02a8e73adcb4bae540ab0591967df6'
'94581b519676ecb4e7fd9d9ddc7c113ea3d2d8d4ff50c13f563e325711c17bf5'
'6df9fe849539abdda74a281e5df1ba2c82d56690de9edc640c5e5212f865a626')
noextract=("${_realname}-${pkgver}.tar.gz") # symlinks
prepare() {
cd "${srcdir}"
bsdtar -xf "${_realname}-${pkgver}.tar.gz" || true
cd "${_realname}-${pkgver}"
patch -Np1 -i "${srcdir}"/0001-i2pd-endian.patch
patch -Np1 -i "${srcdir}"/0001-i2pd-dont-use-pthread_setname.patch
patch -Np1 -i "${srcdir}"/0001-i2pd-makefile.patch
}
build() {
cp -rf "${_realname}-${pkgver}" "build-${MSYSTEM}"
cd "${srcdir}"/build-${MSYSTEM}
make USE_AESNI=no USE_UPNP=yes USE_MESHNET=yes
}
package() {
cd "${srcdir}"/build-${MSYSTEM}
#bin
install -d "${pkgdir}${MINGW_PREFIX}/bin/"
cp i2pd.exe "${pkgdir}${MINGW_PREFIX}/bin/"
#config
install -d "${pkgdir}${MINGW_PREFIX}/etc/i2pd"
cp contrib/{i2pd,tunnels}.conf "${pkgdir}${MINGW_PREFIX}/etc/i2pd"
install -d "${pkgdir}${MINGW_PREFIX}/etc/i2pd/tunnels.d"
# certificates
install -d "${pkgdir}${MINGW_PREFIX}/share/i2pd"
cp -r contrib/certificates "${pkgdir}${MINGW_PREFIX}/share/i2pd"
# license
install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}