1 # Copyright 2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
8 # NOTE: PV is the libtool version number current:revision:age
10 DESCRIPTION="Library with missing functions based on GNUlib"
11 HOMEPAGE="https://prefix.gentoo.org"
12 GIT_TAG="b451121ab45497e78cb6f612c8673a9705193391"
13 SRC_URI="https://git.savannah.gnu.org/cgit/gnulib.git/snapshot/gnulib-${GIT_TAG}.tar.gz"
17 KEYWORDS="~ppc-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
18 #IUSE="static-libs" # dynamic won't work :(
24 S="${WORKDIR}/gnulib-${GIT_TAG}"
29 # create a config file with just the definitions we need
30 mkdir extern-inline || die
31 cd extern-inline || die
33 cat > configure.ac <<- EOS
35 AC_INIT([${PN}], [${PV}], [prefix@gentoo.org])
37 AC_CONFIG_MACRO_DIR([../m4])
38 AC_CONFIG_HEADER([missing-include.h])
44 sed -e '1,/PACKAGE_VERSION/d' missing-include.h.in \
45 > "${T}"/missing-include.h
50 cat > configure.ac <<- EOS
52 AC_INIT([${PN}], [${PV}], [prefix@gentoo.org])
56 AC_CONFIG_MACRO_DIR([m4])
57 AC_CONFIG_HEADER([config.h])
63 AC_CONFIG_FILES([Makefile lib/Makefile])
68 cat > Makefile.am <<- EOS
78 rev=${CHOST##*-darwin}
79 platform="Mac OS X 10.$((rev - 4))"
82 rev=${CHOST##*-solaris2.}
83 # we only support Solaris 10 (and perhaps 9) and up, so we
84 # don't have to bother about 2.x, just X
85 platform="Solaris ${rev}"
89 # blacklist some modules that cause collisions
90 # iconv provided by virtual/iconv -> sys-libs/libiconv
92 cd "${S}"/doc/posix-functions
93 grep -A1 "This function is missing" *.texi | \
94 grep "${platform}" | \
95 sed -e 's:^\(.[^-]*\)-.*$:\1:' | \
96 xargs sed -n 's/^Gnulib module: \([a-z].*\)$/\1/p' | \
97 sed -e 's: or .*$::' -e 's:, :\n:g' | \
102 # get platform specific set of missing functions
103 einfo "Including sources for missing functions on ${platform}:"
104 einfo "${modules[*]}"
105 "${S}"/gnulib-tool -S \
113 sed -i -e '/^noinst_LTLIBRARIES /s/noinst_/lib_/' lib/Makefile.am || die
114 echo "libmissing_la_LDFLAGS += -version-info ${PV//./:}" >> lib/Makefile.am
115 cat >> lib/Makefile.am << 'EOS'
116 install-data-local: $(BUILT_SOURCES)
117 @for hdr in $(BUILT_SOURCES); do \
118 $(INSTALL_HEADER) -D "$$hdr" $(DESTDIR)$(includedir)/$${hdr}; \
128 # ensure we don't pick up installed libmissing
129 export CPPFLAGS+="-DDISABLE_LIBMISSING" # disable libmissing headers
130 export BINUTILS_CONFIG_DISABLE_MISSING=1 # disable -lmissing from ldwrapper
131 export CPPFLAGS="${CPPFLAGS/-I${EPREFIX}\/usr\/include\/missing/}"
132 export LIBS="${LIBS/-lmissing/}"
133 einfo "CPPFLAGS: ${CPPFLAGS}"
134 einfo "LIBS: ${LIBS}"
136 # gnulib cannot be used a shared library, doing so results in stack
137 # protector checks failing for reasons yet unknown to me
138 econf --disable-shared --enable-static || die
151 rm -f "${ED}"/usr/lib/libmissing.la || die
153 cd "${ED}/usr/include" || die
155 # fix config.h dependency so we can can distribute it without
157 for f in $(grep "_GL_INLINE_HEADER_BEGIN" -l *.h */*.h) ; do
158 cat "${T}"/missing-include.h "${f}" > "${f}.new"
159 [[ -s "${f}.new" ]] && mv "${f}.new" "${f}"
162 # modify all header-files so we can disable them and that they won't
163 # clash with gnulib-based packages
164 for f in *.h */*.h ; do
166 -e '1i#ifdef DISABLE_LIBMISSING\n# include_next <'"${f}"'>\n#else' \
167 -e '$a#endif /* DISABLE_LIBMISSING */' \
168 -e 's/_GL_/_LIBMISSING_/g' \