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