Add static build to c-ares package with added shim static pkg-config file (#2827)

* 1. Modified libcares PKGBUILD for 2 round build, creating a static and shared library
2. Added patch to create a libcares-static.pc shim file that defines only the needed CFLAGS, and adding libcares-static as a Private dependency of libcares so it is linked and -DCARES_STATICLIB gets added correctly

Signed-off-by: irakhlin <i.rakhlin@gmail.com>

* Dont specify jobs num

* Increased pkgver from version 1 to version 2
This commit is contained in:
Ilya Rakhlin
2017-09-03 15:26:31 -04:00
committed by Алексей
parent fc636d058e
commit 2f2c5416dd
2 changed files with 112 additions and 6 deletions

View File

@@ -0,0 +1,83 @@
Makefile.am | 4 ++--
buildconf | 1 +
configure.ac | 2 +-
libcares-static.pc.in | 11 +++++++++++
libcares.pc.in | 2 +-
5 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 364db1a..3fa6ddc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,7 +54,7 @@ noinst_PROGRAMS =$(PROGS)
# regular sources and headers
EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
Makefile.m32 Makefile.netware Makefile.msvc Makefile.Watcom $(man_MANS) \
- config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
+ config-win32.h RELEASE-NOTES libcares.pc.in libcares-static.pc.in buildconf get_ver.awk maketgz \
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL.md \
README.md LICENSE.md
@@ -67,7 +67,7 @@ DIST_SUBDIRS = test
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcares.pc
-
+pkgconfig_DATA += libcares-static.pc
CARES_VERSION_INFO = -version-info 4:0:2
# This flag accepts an argument of the form current[:revision[:age]]. So,
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
diff --git a/buildconf b/buildconf
index a779d86..2bc10e5 100755
--- a/buildconf
+++ b/buildconf
@@ -162,6 +162,7 @@ for fname in .deps \
configure \
depcomp \
libcares.pc \
+ libcares-static.pc \
libtool \
libtool.m4 \
libtool.m4.tmp \
diff --git a/configure.ac b/configure.ac
index 7e86ad6..e970960 100644
--- a/configure.ac
+++ b/configure.ac
@@ -900,6 +900,6 @@ if test "x$build_tests" = "xyes" ; then
AC_CONFIG_SUBDIRS([test])
fi
-AC_CONFIG_FILES([Makefile libcares.pc])
+AC_CONFIG_FILES([Makefile libcares.pc libcares-static.pc])
AC_OUTPUT
XC_AMEND_DISTCLEAN(['.'])
diff --git a/libcares-static.pc.in b/libcares-static.pc.in
new file mode 100644
index 0000000..4612712
--- /dev/null
+++ b/libcares-static.pc.in
@@ -0,0 +1,11 @@
+#***************************************************************************
+# Project ___ __ _ _ __ ___ ___
+# / __|____ / _` | '__/ _ \/ __|
+# | (_|_____| (_| | | | __/\__ \
+# \___| \__,_|_| \___||___/
+#
+Name: c-ares-static
+URL: http://daniel.haxx.se/projects/c-ares/
+Description: asynchronous DNS lookup library
+Version: @VERSION@
+Cflags: -DCARES_STATICLIB
diff --git a/libcares.pc.in b/libcares.pc.in
index e757c1b..99fdbba 100644
--- a/libcares.pc.in
+++ b/libcares.pc.in
@@ -14,7 +14,7 @@ URL: http://daniel.haxx.se/projects/c-ares/
Description: asynchronous DNS lookup library
Version: @VERSION@
Requires:
-Requires.private:
+Requires.private: libcares-static
Cflags: -I${includedir} @CPPFLAG_CARES_STATICLIB@
Libs: -L${libdir} -lcares
Libs.private: @CARES_PRIVATE_LIBS@

View File

@@ -4,7 +4,7 @@ _realname=c-ares
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.13.0
pkgrel=1
pkgrel=2
pkgdesc="C library that performs DNS requests and name resolves asynchronously (mingw-w64)"
arch=('any')
url="https://c-ares.haxx.se/"
@@ -12,35 +12,58 @@ license=("MIT, BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
source=("https://c-ares.haxx.se/download/${_realname}-${pkgver}.tar.gz"{,.asc}
0001-Use-RPM-compiler-options.patch)
0001-Use-RPM-compiler-options.patch
0002-Add-static-pkg-config.patch)
validpgpkeys=('914C533DF9B2ADA2204F586D78E11C6B279D5C91'
'27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2')
sha256sums=('03f708f1b14a26ab26c38abd51137640cb444d3ec72380b21b20f1a8d2861da7'
'SKIP'
'f00faa8723fd530b027f96b987ef19138628a49afdf52ffb0554b36156fc9d74')
'f00faa8723fd530b027f96b987ef19138628a49afdf52ffb0554b36156fc9d74'
'70be0786506122dee5c105e6c00b5a430e564ac18d4e8a3778679039f84d74da')
prepare() {
cd "${srcdir}"/${_realname}-${pkgver}
patch -p1 -i ${srcdir}/0001-Use-RPM-compiler-options.patch
patch -p1 -i ${srcdir}/0002-Add-static-pkg-config.patch
autoreconf -fi
}
build() {
mkdir -p "${srcdir}/build-${MINGW_CHOST}"
cd "${srcdir}/build-${MINGW_CHOST}"
[[ -d "${srcdir}"/build-${CARCH}-shared ]] && rm -rf "${srcdir}"/build-${CARCH}-shared
[[ -d "${srcdir}"/build-${CARCH}-static ]] && rm -rf "${srcdir}"/build-${CARCH}-static
mkdir -p "${srcdir}"/build-${CARCH}-shared "${srcdir}"/build-${CARCH}-static
msg "Building shared library..."
(cd "${srcdir}"/build-${CARCH}-shared
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--enable-shared \
--disable-static
make
)
msg "Building static lib..."
(cd "${srcdir}"/build-${CARCH}-static
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--disable-shared \
--enable-static
make
)
}
package() {
cd "${srcdir}/build-${MINGW_CHOST}"
cd "${srcdir}"/build-${CARCH}-static
make DESTDIR="${pkgdir}" install
cd "${srcdir}"/build-${CARCH}-shared
make DESTDIR="${pkgdir}" install
# msys2-runtime-devel provide nameser.h but mingw-w64 don't have it
cp ${srcdir}/${_realname}-${pkgver}/nameser.h ${pkgdir}${MINGW_PREFIX}/include
}