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