dev-libs/libmissing: revbump to install fixed headers and static lib
authorFabian Groffen <grobian@gentoo.org>
Sun, 13 Oct 2019 18:09:59 +0000 (20:09 +0200)
committerFabian Groffen <grobian@gentoo.org>
Sun, 13 Oct 2019 18:12:46 +0000 (20:12 +0200)
Package-Manager: Portage-2.3.76, Repoman-2.3.16
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
dev-libs/libmissing/libmissing-1.1.0.ebuild [moved from dev-libs/libmissing/libmissing-1.0.0-r1.ebuild with 62% similarity]

similarity index 62%
rename from dev-libs/libmissing/libmissing-1.0.0-r1.ebuild
rename to dev-libs/libmissing/libmissing-1.1.0.ebuild
index c1371f6d4faf80a7bdefb289ac68655bd029a349..b7099ebe777589ae4e1fba4065418dbf8e079f57 100644 (file)
@@ -15,7 +15,7 @@ SRC_URI="https://git.savannah.gnu.org/cgit/gnulib.git/snapshot/gnulib-${GIT_TAG}
 LICENSE="GPL-2"
 SLOT="0"
 KEYWORDS="~ppc-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE="static-libs"
+#IUSE="static-libs"  # dynamic won't work :(
 
 DEPEND=""
 RDEPEND="${DEPEND}"
@@ -26,6 +26,25 @@ S="${WORKDIR}/gnulib-${GIT_TAG}"
 src_prepare() {
        default
 
+       # create a config file with just the definitions we need
+       mkdir extern-inline || die
+       cd extern-inline || die
+
+       cat > configure.ac <<- EOS
+               AC_PREREQ([2.69])
+               AC_INIT([${PN}], [${PV}], [prefix@gentoo.org])
+
+               AC_CONFIG_MACRO_DIR([../m4])
+               AC_CONFIG_HEADER([missing-include.h])
+
+               gl_EXTERN_INLINE
+       EOS
+
+       eautoreconf
+       sed -e '1,/PACKAGE_VERSION/d' missing-include.h.in \
+               > "${T}"/missing-include.h
+       cd .. || die
+
        mkdir "${PN}" || die
        cd "${PN}" || die
        cat > configure.ac <<- EOS
@@ -92,11 +111,11 @@ src_prepare() {
                "${modules[@]}"
 
        sed -i -e '/^noinst_LTLIBRARIES /s/noinst_/lib_/' lib/Makefile.am || die
-       echo "libmissing_la_LDFLAGS += version-info ${PV//./:}" >> lib/Makefile.am
+       echo "libmissing_la_LDFLAGS += -version-info ${PV//./:}" >> lib/Makefile.am
        cat >> lib/Makefile.am << 'EOS'
 install-data-local: $(BUILT_SOURCES)
        @for hdr in $(BUILT_SOURCES); do \
-               $(INSTALL_HEADER) -D "$$hdr" $(DESTDIR)$(includedir)/missing/$${hdr}; \
+               $(INSTALL_HEADER) -D "$$hdr" $(DESTDIR)$(includedir)/$${hdr}; \
        done;
 EOS
 
@@ -107,12 +126,16 @@ src_configure() {
        cd "${PN}" || die
 
        # ensure we don't pick up installed libmissing
+       export CPPFLAGS+="-DDISABLE_LIBMISSING"   # disable libmissing headers
+       export BINUTILS_CONFIG_DISABLE_MISSING=1  # disable -lmissing from ldwrapper
        export CPPFLAGS="${CPPFLAGS/-I${EPREFIX}\/usr\/include\/missing/}"
        export LIBS="${LIBS/-lmissing/}"
        einfo "CPPFLAGS: ${CPPFLAGS}"
        einfo "LIBS: ${LIBS}"
 
-       default
+       # gnulib cannot be used a shared library, doing so results in stack
+       # protector checks failing for reasons yet unknown to me
+       econf --disable-shared --enable-static || die
 }
 
 src_compile() {
@@ -122,8 +145,27 @@ src_compile() {
 
 src_install() {
        cd "${PN}" || die
+
        default
 
-       rm "${ED}"/usr/lib/libmissing.la \
-               "$(use static-libs || echo "${ED}"/usr/lib/libmissing.a)" || die
+       rm -f "${ED}"/usr/lib/libmissing.la || die
+
+       cd "${ED}/usr/include" || die
+
+       # fix config.h dependency so we can can distribute it without
+       local f
+       for f in $(grep "_GL_INLINE_HEADER_BEGIN" -l *.h */*.h) ; do
+               cat "${T}"/missing-include.h "${f}" > "${f}.new"
+               [[ -s "${f}.new" ]] && mv "${f}.new" "${f}"
+       done
+
+       # modify all header-files so we can disable them and that they won't
+       # clash with gnulib-based packages
+       for f in *.h */*.h ; do
+               sed -i \
+                       -e '1i#ifdef DISABLE_LIBMISSING\n# include_next <'"${f}"'>\n#else' \
+                       -e '$a#endif /* DISABLE_LIBMISSING */' \
+                       -e 's/_GL_/_LIBMISSING_/g' \
+                       "${f}" || die
+       done
 }