From f02f6f0dc7fc0f3a42fdc89f09914073a92106a6 Mon Sep 17 00:00:00 2001
From: maciozo <maciozo@maciozo.com>
Date: Sat, 4 May 2019 22:26:02 +0100
Subject: [PATCH] [WIP] New package: libircclient-1.10

---
 common/shlibs                                 |  1 +
 srcpkgs/libircclient-devel                    |  1 +
 srcpkgs/libircclient/files/libircclient.pc    |  7 ++
 .../patches/build_shared_and_static.patch     | 19 +++++
 srcpkgs/libircclient/template                 | 73 +++++++++++++++++++
 5 files changed, 101 insertions(+)
 create mode 120000 srcpkgs/libircclient-devel
 create mode 100644 srcpkgs/libircclient/files/libircclient.pc
 create mode 100644 srcpkgs/libircclient/patches/build_shared_and_static.patch
 create mode 100644 srcpkgs/libircclient/template

diff --git a/common/shlibs b/common/shlibs
index 5bdd8d9832a..24d4b412653 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3450,3 +3450,4 @@ liboblibs.so.0.0 oblibs-0.0.1.1_1
 libaal-1.0.so.7 libaal-1.0.7_1
 libaal-minimal.so.0 libaal-1.0.7_1
 libcli.so.1.9 libcli-1.9.8.4_1
+libircclient.so.1 libircclient-1.10_1
diff --git a/srcpkgs/libircclient-devel b/srcpkgs/libircclient-devel
new file mode 120000
index 00000000000..2dfa3a687e7
--- /dev/null
+++ b/srcpkgs/libircclient-devel
@@ -0,0 +1 @@
+libircclient
\ No newline at end of file
diff --git a/srcpkgs/libircclient/files/libircclient.pc b/srcpkgs/libircclient/files/libircclient.pc
new file mode 100644
index 00000000000..ca92609cb9c
--- /dev/null
+++ b/srcpkgs/libircclient/files/libircclient.pc
@@ -0,0 +1,7 @@
+prefix=/usr
+libdir=${prefix}/lib
+
+Name: libircclient
+Description: IRC client library
+Version: 1.10
+Libs: -L${libdir} -lircclient -lcrypto -lssl
diff --git a/srcpkgs/libircclient/patches/build_shared_and_static.patch b/srcpkgs/libircclient/patches/build_shared_and_static.patch
new file mode 100644
index 00000000000..ae4cc764585
--- /dev/null
+++ b/srcpkgs/libircclient/patches/build_shared_and_static.patch
@@ -0,0 +1,19 @@
+*** src/Makefile.in.old	2019-05-04 19:22:44.323241339 +0100
+--- src/Makefile.in	2019-05-04 19:26:35.051551494 +0100
+***************
+*** 9,15 ****
+  
+  OBJS = libircclient.o
+  
+! all:	@TARGET@
+  
+  static:	libircclient.a
+  shared: libircclient.so
+--- 9,15 ----
+  
+  OBJS = libircclient.o
+  
+! all: libircclient.so libircclient.a
+  
+  static:	libircclient.a
+  shared: libircclient.so
diff --git a/srcpkgs/libircclient/template b/srcpkgs/libircclient/template
new file mode 100644
index 00000000000..ce95f33a66b
--- /dev/null
+++ b/srcpkgs/libircclient/template
@@ -0,0 +1,73 @@
+# Template file for 'libircclient'
+pkgname=libircclient
+version=1.10
+revision=1
+build_style=gnu-configure
+configure_args="--enable-openssl --enable-ipv6 --enable-shared"
+makedepends="libressl-devel"
+short_desc="IRC client library"
+maintainer="maciozo@maciozo.com <maciozo@maciozo.com>"
+license="LGPL-3.0-or-later"
+homepage="https://www.ulduzsoft.com/linux/libircclient/"
+distfiles="https://netix.dl.sourceforge.net/project/libircclient/libircclient/${version}/libircclient-${version}.tar.gz"
+checksum=bbb26f3af348b252c5204917a7f91cfdf172f1b6afbf4df1e561b03e20503c2d
+
+case "$XBPS_TARGET_MACHINE" in
+	*-musl)	depends+=" musl-devel";;
+	*) depends+=" glibc-devel";;
+esac
+
+do_install() {
+	#mkdir -p ${PKGDESTDIR}/usr/lib
+	#mkdir -p ${PKGDESTDIR}/usr/include
+	#mkdir -p ${PKGDESTDIR}/doc/sources
+	
+	vmkdir usr/lib
+	vcopy src/*.so /usr/lib
+	vcopy src/*.a /usr/lib
+	#cp ${wrksrc}/src/*.so ${PKGDESTDIR}/usr/lib/
+	#cp ${wrksrc}/src/*.a ${PKGDESTDIR}/usr/lib/
+	
+	# Generate versioned shlib link (libircclient.so.x -> libircclient.so)
+	
+	for _sharedlib in ${PKGDESTDIR}/usr/lib/*.so; do
+		echo $(basename ${_sharedlib})
+		_soname=$(objdump -p ${_sharedlib} | awk '/SONAME/ {print $2}')
+		ln -s $(basename ${_sharedlib}) ${PKGDESTDIR}/usr/lib/${_soname}
+	done
+
+	#cp ${wrksrc}/include/* ${PKGDESTDIR}/usr/include
+	#cp ${wrksrc}/doc/*.rst ${PKGDESTDIR}/doc
+	#cp ${wrksrc}/doc/sources/*.rst ${PKGDESTDIR}/doc/sources
+	vmkdir usr/include
+	vcopy include/* /usr/include
+	
+	vmkdir usr/share/doc/${pkgname}
+	vcopy doc/*.rst /usr/share/doc/${pkgname}
+	
+	vmkdir usr/share/doc/${pkgname}/sources
+	vcopy doc/sources/*.rst /usr/share/doc/${pkgname}/sources
+}
+
+libircclient-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+
+	pkg_install() {
+		#mkdir -p ${PKGDESTDIR}/usr/share/doc/${pkgname}
+		#mv ${DESTDIR}/doc/* ${PKGDESTDIR}/usr/share/doc/${pkgname}
+		vmkdir usr/share/doc/${pkgname}
+		vmove usr/share/doc/${sourcepkg}/*
+
+		#mkdir -p ${PKGDESTDIR}/usr/lib/pkgconfig
+		vmkdir usr/lib/pkgconfig
+		vcopy ${FILESDIR}/libircclient.pc /usr/lib/pkgconfig/
+
+		vmkdir usr/include
+		vmove usr/include
+		
+		vmkdir usr/lib
+		vmove "usr/lib/*.a"
+		vman man/libircclient.1
+	}
+}
