commit:     ae86e8c552c377835ac0d2bfd521e06e55432c7f
Author:     Aisha Tammy <gentoo <AT> aisha <DOT> cc>
AuthorDate: Mon Nov 23 02:46:51 2020 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> riseup <DOT> net>
CommitDate: Mon Nov 23 02:46:51 2020 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=ae86e8c5

net-libs/usockets: add pkg-config file

really painful upstream makes life hell
libressl is considered a joke
shared libraries are considered a joke
not doing -O3 -flto is considered a joke
rehauled the whole Makefile to make it useable

Package-Manager: Portage-3.0.8, Repoman-3.0.1
Signed-off-by: Aisha Tammy <gentoo <AT> aisha.cc>

 .../usockets/files/usockets-0.6.0-Makefile.patch   | 128 +++++++++++++++++++++
 net-libs/usockets/files/usockets-Makefile.patch    |  62 ----------
 net-libs/usockets/usockets-0.6.0-r1.ebuild         |  20 ++--
 net-libs/usockets/usockets-9999.ebuild             |  20 ++--
 4 files changed, 148 insertions(+), 82 deletions(-)

diff --git a/net-libs/usockets/files/usockets-0.6.0-Makefile.patch 
b/net-libs/usockets/files/usockets-0.6.0-Makefile.patch
new file mode 100644
index 00000000..ebc9a0db
--- /dev/null
+++ b/net-libs/usockets/files/usockets-0.6.0-Makefile.patch
@@ -0,0 +1,128 @@
+diff --git a/Makefile b/Makefile
+index 27f97ce..c269c3f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,60 +1,62 @@
++DESTDIR ?=
++
++prefix ?=     /usr
++exec_prefix ?=        $(prefix)
++LIB ?=                lib
++libdir ?=     $(exec_prefix)/$(LIB)
++includedir ?= $(exec_prefix)/include/uSockets
++
++VERSION ?=    0.0
++LIBTARGET =   libusockets.so.$(VERSION)
++
++LIBS =
++REQUIRES =
++
+ # WITH_OPENSSL=1 enables OpenSSL 1.1+ support or BoringSSL
+ # For now we need to link with C++ for OpenSSL support, but should be removed 
with time
+ ifeq ($(WITH_OPENSSL),1)
+-      override CFLAGS += -DLIBUS_USE_OPENSSL
+-      # With problems on macOS, make sure to pass needed LDFLAGS required to 
find these
+-      override LDFLAGS += -lssl -lcrypto -lstdc++
+-else
+-      # WITH_WOLFSSL=1 enables WolfSSL 4.2.0 support (mutually exclusive with 
OpenSSL)
+-      ifeq ($(WITH_WOLFSSL),1)
+-              # todo: change these
+-              override CFLAGS += -DLIBUS_USE_WOLFSSL -I/usr/local/include
+-              override LDFLAGS += -L/usr/local/lib -lwolfssl
+-      else
+-              override CFLAGS += -DLIBUS_NO_SSL
+-      endif
++CFLAGS +=     -DLIBUS_USE_OPENSSL
++LIBS +=               -lssl -lcrypto -lstdc++
++REQUIRES +=   libssl libcrypto
+ endif
+ 
+ # WITH_LIBUV=1 builds with libuv as event-loop
+ ifeq ($(WITH_LIBUV),1)
+-      override CFLAGS += -DLIBUS_USE_LIBUV
+-      override LDFLAGS += -luv
+-endif
+-
+-# WITH_GCD=1 builds with libdispatch as event-loop
+-ifeq ($(WITH_GCD),1)
+-      override CFLAGS += -DLIBUS_USE_GCD
+-      override LDFLAGS += -framework CoreFoundation
++CFLAGS +=     -DLIBUS_USE_LIBUV
++LIBS +=               -luv
++REQUIRES +=   libuv
+ endif
+ 
+-# WITH_ASAN builds with sanitizers
+-ifeq ($(WITH_ASAN),1)
+-      override CFLAGS += -fsanitize=address -g
+-      override LDFLAGS += -lasan
+-endif
+-
+-override CFLAGS += -std=c11 -Isrc
+-override LDFLAGS += uSockets.a
++CFLAGS += -std=c11 -Isrc
+ 
+-# By default we build the uSockets.a static library
+ default:
+-      rm -f *.o
+-      $(CC) $(CFLAGS) -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
+-# For now we do rely on C++17 for OpenSSL support but we will be porting this 
work to C11
++      $(CC) $(CFLAGS) -fPIC -c src/*.c src/eventing/*.c src/crypto/*.c
+ ifeq ($(WITH_OPENSSL),1)
+-      $(CXX) $(CXXFLAGS) -std=c++17 -flto -O3 -c src/crypto/*.cpp
++      $(CXX) $(CXXFLAGS) -fPIC -std=c++17 -c src/crypto/*.cpp
+ endif
+-      $(AR) rvs uSockets.a *.o
+-
+-# Builds all examples
+-.PHONY: examples
+-examples: default
+-      for f in examples/*.c; do $(CC) -flto -O3 $(CFLAGS) -o $$(basename 
"$$f" ".c") "$$f" $(LDFLAGS); done
+-
+-swift_examples:
+-      swiftc -O -I . examples/swift_http_server/main.swift uSockets.a -o 
swift_http_server
++      $(AR) rvs libusockets.a *.o
++      $(CC) -shared -fPIC -Wl,-soname,$(LIBTARGET) $(CFLAGS) -o $(LIBTARGET) 
*.o $(LIBS) $(LDFLAGS)
++      sed -e "s:@PREFIX@:$(prefix):" -e "s:@REQUIRES@:$(REQUIRES):" \
++      -e "s:@LIB@:$(LIB):" -e "s:@VERSION@:$(VERSION):" libusockets.pc.in > 
libusockets.pc
++
++install:
++      install -d "$(DESTDIR)$(libdir)/pkgconfig" \
++      "$(DESTDIR)$(includedir)/internal/eventing" \
++      "$(DESTDIR)$(includedir)/internal/networking"
++      install -m 644 src/*.h "$(DESTDIR)$(includedir)/"
++      install -m 644 src/internal/*.h "$(DESTDIR)$(includedir)/internal/"
++      install -m 644 src/internal/eventing/*.h 
"$(DESTDIR)$(includedir)/internal/eventing/"
++      install -m 644 src/internal/networking/*.h 
"$(DESTDIR)$(includedir)/internal/networking/"
++      install -m 755 $(LIBTARGET) "$(DESTDIR)$(libdir)"
++      ln -sf $(LIBTARGET) "$(DESTDIR)$(libdir)/libusockets.so"
++      install -m 755 libusockets.a "$(DESTDIR)$(libdir)/"
++      install -m 644 libusockets.pc "$(DESTDIR)$(libdir)/pkgconfig/"
+ 
+ clean:
+       rm -f *.o
+       rm -f *.a
++      rm -f *.so
+       rm -rf .certs
++      rm -f libusockets.pc
++
++.PHONY: 
+diff --git a/libusockets.pc.in b/libusockets.pc.in
+new file mode 100644
+index 0000000..b63637b
+--- /dev/null
++++ b/libusockets.pc.in
+@@ -0,0 +1,13 @@
++prefix=@PREFIX@
++exec_prefix=${prefix}
++libdir=${exec_prefix}/@LIB@
++includedir=${prefix}/include
++
++Name: uSockets
++Version: @VERSION@
++Description: eventing, networking and crypto for async applications.
++URL: https://github.com/uNetworking/uSockets
++
++Cflags: -I${includedir}
++Libs: -L${libdir} -lusockets
++Requires.private: @REQUIRES@

diff --git a/net-libs/usockets/files/usockets-Makefile.patch 
b/net-libs/usockets/files/usockets-Makefile.patch
deleted file mode 100644
index a3c50bc1..00000000
--- a/net-libs/usockets/files/usockets-Makefile.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 27f97ce..066305c 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,3 +1,13 @@
-+DESTDIR ?=
-+
-+prefix ?=       "/usr/local"
-+exec_prefix ?=  "$(prefix)"
-+libdir ?=       "$(exec_prefix)/lib"
-+includedir ?=   "$(exec_prefix)/include/uSockets"
-+
-+# OpenBSD specific library version
-+LIBTARGET =     libusockets.so.$(LIBusockets_VERSION)
-+
- # WITH_OPENSSL=1 enables OpenSSL 1.1+ support or BoringSSL
- # For now we need to link with C++ for OpenSSL support, but should be removed 
with time
- ifeq ($(WITH_OPENSSL),1)
-@@ -34,17 +44,31 @@ ifeq ($(WITH_ASAN),1)
- endif
- 
- override CFLAGS += -std=c11 -Isrc
--override LDFLAGS += uSockets.a
- 
--# By default we build the uSockets.a static library
-+
- default:
-       rm -f *.o
--      $(CC) $(CFLAGS) -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
--# For now we do rely on C++17 for OpenSSL support but we will be porting this 
work to C11
-+      $(CC) $(CFLAGS) -fPIC -c src/*.c src/eventing/*.c src/crypto/*.c
- ifeq ($(WITH_OPENSSL),1)
--      $(CXX) $(CXXFLAGS) -std=c++17 -flto -O3 -c src/crypto/*.cpp
-+      $(CXX) $(CXXFLAGS) -fPIC -std=c++17 -c src/crypto/*.cpp
- endif
--      $(AR) rvs uSockets.a *.o
-+      $(AR) rvs libusockets.a *.o
-+      $(CC) -shared -fPIC -Wl,-soname,$(LIBTARGET) $(CFLAGS) -o $(LIBTARGET) 
*.o $(LDFLAGS)
-+
-+install:
-+      # install the folders needed  (making sure that the exist)
-+      install -d "$(DESTDIR)$(libdir)" \
-+      "$(DESTDIR)$(includedir)/internal/eventing" \
-+      "$(DESTDIR)$(includedir)/internal/networking"
-+      install -m 755 $(LIBTARGET) "$(DESTDIR)$(libdir)/"
-+      ln -sf $(LIBTARGET)"$(DESTDIR)$(libdir)/libusockets.so"
-+      # install static library
-+      install -m 755 libusockets.a "$(DESTDIR)$(libdir)/"
-+      # we also install all the header files
-+      install  src/*.h "$(DESTDIR)$(includedir)/"
-+      install -m 644 src/internal/*.h "$(DESTDIR)$(includedir)/internal/"
-+      install -m 644 src/internal/eventing/*.h 
"$(DESTDIR)$(includedir)/internal/eventing/"
-+      install -m 644 src/internal/networking/*.h 
"$(DESTDIR)$(includedir)/internal/networking/"
- 
- # Builds all examples
- .PHONY: examples
-@@ -57,4 +81,5 @@ swift_examples:
- clean:
-       rm -f *.o
-       rm -f *.a
-+      rm -f *.so
-       rm -rf .certs

diff --git a/net-libs/usockets/usockets-0.6.0-r1.ebuild 
b/net-libs/usockets/usockets-0.6.0-r1.ebuild
index 2da9a11a..1d42acf6 100644
--- a/net-libs/usockets/usockets-0.6.0-r1.ebuild
+++ b/net-libs/usockets/usockets-0.6.0-r1.ebuild
@@ -19,36 +19,36 @@ fi
 
 LICENSE="Apache-2.0"
 SLOT="0"
-IUSE="libuv +ssl libressl static-libs"
+IUSE="libuv +ssl static-libs"
 
 DEPEND="ssl? (
-               libressl? ( >=dev-libs/libressl-3.0.0:=[static-libs?] )
-               !libressl? ( >=dev-libs/openssl-1.1.0:=[static-libs?] )
+               >=dev-libs/openssl-1.1.0:=[static-libs?]
        )
        libuv? ( dev-libs/libuv[static-libs?] )
 "
 RDEPEND="${DEPEND}"
 
 PATCHES=(
-       "${FILESDIR}/usockets-Makefile.patch"
+       "${FILESDIR}/${PN}-0.6.0-Makefile.patch"
 )
 
 src_compile() {
        # the Makefile uses environment variables
-       emake LIBusockets_VERSION=${PV} \
+       emake VERSION=${PV} \
+             LIB="$(get_libdir)" \
              WITH_OPENSSL=$(usex ssl 1 0) \
              WITH_LIBUV=$(usex libuv 1 0) \
              default
 }
 
 src_install() {
-       emake libdir="/usr/$(get_libdir)" \
-             prefix="/usr" \
-             DESTDIR="${ED}" \
-             LIBusockets_VERSION=${PV} \
+       emake LIB="$(get_libdir)" \
+             prefix="${EPREFIX%/}/usr" \
+             DESTDIR="${D}" \
+             VERSION=${PV} \
              install
        einstalldocs
        if ! use static-libs; then
-               rm "${D}/usr/$(get_libdir)/libusockets.a" || die
+               rm -f "${ED}/usr/$(get_libdir)/libusockets.a" || die
        fi
 }

diff --git a/net-libs/usockets/usockets-9999.ebuild 
b/net-libs/usockets/usockets-9999.ebuild
index 2da9a11a..1d42acf6 100644
--- a/net-libs/usockets/usockets-9999.ebuild
+++ b/net-libs/usockets/usockets-9999.ebuild
@@ -19,36 +19,36 @@ fi
 
 LICENSE="Apache-2.0"
 SLOT="0"
-IUSE="libuv +ssl libressl static-libs"
+IUSE="libuv +ssl static-libs"
 
 DEPEND="ssl? (
-               libressl? ( >=dev-libs/libressl-3.0.0:=[static-libs?] )
-               !libressl? ( >=dev-libs/openssl-1.1.0:=[static-libs?] )
+               >=dev-libs/openssl-1.1.0:=[static-libs?]
        )
        libuv? ( dev-libs/libuv[static-libs?] )
 "
 RDEPEND="${DEPEND}"
 
 PATCHES=(
-       "${FILESDIR}/usockets-Makefile.patch"
+       "${FILESDIR}/${PN}-0.6.0-Makefile.patch"
 )
 
 src_compile() {
        # the Makefile uses environment variables
-       emake LIBusockets_VERSION=${PV} \
+       emake VERSION=${PV} \
+             LIB="$(get_libdir)" \
              WITH_OPENSSL=$(usex ssl 1 0) \
              WITH_LIBUV=$(usex libuv 1 0) \
              default
 }
 
 src_install() {
-       emake libdir="/usr/$(get_libdir)" \
-             prefix="/usr" \
-             DESTDIR="${ED}" \
-             LIBusockets_VERSION=${PV} \
+       emake LIB="$(get_libdir)" \
+             prefix="${EPREFIX%/}/usr" \
+             DESTDIR="${D}" \
+             VERSION=${PV} \
              install
        einstalldocs
        if ! use static-libs; then
-               rm "${D}/usr/$(get_libdir)/libusockets.a" || die
+               rm -f "${ED}/usr/$(get_libdir)/libusockets.a" || die
        fi
 }

Reply via email to