1SUMMARY = "Tools for performance analysis"
2HOMEPAGE = "http://lmbench.sourceforge.net/"
3SECTION = "console/utils"
4LICENSE = "GPLv2 & GPL-2.0-with-lmbench-restriction"
5LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
6                    file://COPYING-2;md5=8e9aee2ccc75d61d107e43794a25cdf9"
7
8inherit autotools-brokensep
9
10DEPENDS += "libtirpc"
11CFLAGS += "-I${STAGING_INCDIR}/tirpc"
12LDLIBS += " -ltirpc "
13
14PR = "r2"
15
16SRC_URI = "${SOURCEFORGE_MIRROR}/lmbench/lmbench-${PV}.tgz \
17           file://lmbench-run \
18           file://rename-line-binary.patch \
19           file://update-results-script.patch \
20           file://obey-ranlib.patch \
21           file://update-config-script.patch \
22           file://lmbench_result_html_report.patch \
23           file://fix-lmbench-memory-check-failure.patch \
24           file://0001-avoid-gcc-optimize-away-the-loops.patch \
25           file://0001-lat_http.c-Add-printf-format.patch \
26           file://0001-Check-for-musl-define-guard-before-redefining-sockle.patch \
27           file://0002-build-Adjust-CFLAGS-LDFLAGS-to-append-values-passed-.patch \
28           file://0001-src-Makefile-use-libdir-instead-of-hardcoded-lib.patch \
29           "
30SRC_URI[md5sum] = "b3351a3294db66a72e2864a199d37cbf"
31SRC_URI[sha256sum] = "cbd5777d15f44eab7666dcac418054c3c09df99826961a397d9acf43d8a2a551"
32
33UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/lmbench/files/development/"
34UPSTREAM_CHECK_REGEX = "lmbench-(?P<pver>\d+(\.\d+)+-[a-z]+\d+)"
35
36EXTRA_OEMAKE = 'CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" CFLAGS="${CFLAGS}" \
37                LDFLAGS="${LDFLAGS}" LDLIBS="${LDLIBS}" LD="${LD}" OS="${TARGET_SYS}" \
38                TARGET="${TARGET_OS}" BASE="${prefix}" MANDIR="${mandir}"'
39
40do_configure() {
41    :
42}
43
44do_compile () {
45    for CONFIG_SITE_ITEM in $CONFIG_SITE; do
46        . $CONFIG_SITE_ITEM
47    done
48    if [ X"$ac_cv_uint" = X"yes" ]; then
49        CFLAGS="${CFLAGS} -DHAVE_uint"
50    fi
51    install -d ${S}/bin/${TARGET_SYS}
52    oe_runmake -C src
53}
54
55do_install () {
56    install -d ${D}${sysconfdir}/default/volatiles \
57           ${D}${bindir} ${D}${mandir} ${D}${libdir}/lmbench \
58           ${D}${datadir}/lmbench/scripts
59
60    echo "d root root 0755 ${localstatedir}/run/${BPN} none" \
61           > ${D}${sysconfdir}/default/volatiles/99_lmbench
62    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
63        install -d ${D}${sysconfdir}/tmpfiles.d
64        echo "d /run/${BPN} - - - -" \
65              > ${D}${sysconfdir}/tmpfiles.d/lmbench.conf
66    fi
67
68    oe_runmake BASE="${D}${prefix}" MANDIR="${D}${mandir}" \
69            DESTDIR="${D}" \
70            -C src install
71    mv ${D}${bindir}/line ${D}${bindir}/lm_line
72    install -m 0755 ${WORKDIR}/lmbench-run ${D}${bindir}/
73    sed -i -e 's,^SHAREDIR=.*$,SHAREDIR=${datadir}/${BPN},;' \
74           -e 's,^BINDIR=.*$,BINDIR=${libdir}/${BPN},;' \
75           -e 's,^CONFIG=.*$,CONFIG=`$SCRIPTSDIR/config`,;' \
76           ${D}${bindir}/lmbench-run
77    install -m 0755 ${S}/scripts/lmbench ${D}${bindir}
78    install -m 0755 ${S}/scripts/* ${D}${datadir}/lmbench/scripts
79}
80
81pkg_postinst_${PN} () {
82    if [ -z "$D" ]; then
83        if command -v systemd-tmpfiles >/dev/null; then
84            systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/lmbench.conf
85        elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
86            ${sysconfdir}/init.d/populate-volatile.sh update
87        fi
88    fi
89}
90
91RDEPENDS_${PN} = "perl"
92FILES_${PN} += "${datadir}/lmbench ${libdir}/lmbench"
93