Hi, Please find attached a new port for libcpucycles library.
I'm not super sure if I got right how to set up a package providing a shared library. I didn't get any warnings from portcheck tool or from 'port-lib-depends-check' make target and it builds successfully under dpb. Any feedback is more than welcome. Is it OK to import it? Comment: library for counting CPU cycles Description: libcpucyples provides a simple API to access hardware precise timers to understand and improve software performance. libcpucycles understands machine-level cycle counters for most architectures. libcpucycles also understands common OS-level mechanisms, which give varying levels of accuracy. Maintainer: Miguel Landaeta <mig...@miguel.cc> WWW: https://cpucycles.cr.yp.to/ -- Miguel Landaeta, miguel at miguel.cc secure email with PGP 0x6E608B637D8967E9 available at http://keyserver.pgp.com/ "Faith means not wanting to know what is true." -- Nietzsche
libcpucycles.tgz
Description: application/tar-gz
diff --git a/misc/libcpucycles/Makefile b/misc/libcpucycles/Makefile new file mode 100644 index 00000000000..97c6a1f3dd7 --- /dev/null +++ b/misc/libcpucycles/Makefile @@ -0,0 +1,27 @@ +COMMENT= library for counting CPU cycles + +V= 20230115 +DISTNAME= libcpucycles-${V} +SHARED_LIBS+= cpucycles 0.0 # 1.0 +CATEGORIES= misc +HOMEPAGE= https://cpucycles.cr.yp.to/ +MASTER_SITES= ${HOMEPAGE} + +MAINTAINER= Miguel Landaeta <mig...@miguel.cc> + +# Public-domain +PERMIT_PACKAGE= Yes + +WANTLIB+= c m +MODULES+= lang/python +BUILD_DEPENDS= lang/python/${MODPY_DEFAULT_VERSION_3} +MODPY_RUNDEP= No +MODPY_PYTEST= No + +CONFIGURE_STYLE= simple +CONFIGURE_ARGS+= --prefix="${WRKINST}${PREFIX}" \ + --host="${MACHINE_ARCH}" \ + --soversion="0.0" +ALL_TARGET= + +.include <bsd.port.mk> diff --git a/misc/libcpucycles/distinfo b/misc/libcpucycles/distinfo new file mode 100644 index 00000000000..6f2ee7574ef --- /dev/null +++ b/misc/libcpucycles/distinfo @@ -0,0 +1,2 @@ +SHA256 (libcpucycles-20230115.tar.gz) = 3TjBIgVVAha5Jgfw9CcnxSoBCaFq8uqnoTg11T67wiU= +SIZE (libcpucycles-20230115.tar.gz) = 34852 diff --git a/misc/libcpucycles/patches/patch-configure_fix_soname b/misc/libcpucycles/patches/patch-configure_fix_soname new file mode 100644 index 00000000000..fa7d5dd1430 --- /dev/null +++ b/misc/libcpucycles/patches/patch-configure_fix_soname @@ -0,0 +1,78 @@ +Fix library soname. +Index: configure +--- configure.orig ++++ configure +@@ -10,6 +10,7 @@ + prefix = '/usr/local' + clean = True + linktype = 'so' ++soversion = '0.0' + + host = platform.machine() + host = ''.join(c for c in host if c in '_0123456789abcdefghijklmnopqrstuvwxyz') +@@ -43,6 +44,9 @@ + host = arg[7:] + host = host.split('-')[0] + continue ++ if arg.startswith('--soversion='): ++ soversion = arg[12:] ++ continue + if arg == '--clean': + clean = True + continue +@@ -54,6 +58,7 @@ + echoargs = './configure' + echoargs += ' --prefix=%s' % prefix + echoargs += ' --host=%s' % host ++echoargs += ' --soversion=%s' % soversion + if clean: echoargs += ' --clean' + if not clean: echoargs += ' --noclean' + print(echoargs) +@@ -222,23 +227,17 @@ + f.write('%s -shared \\\n' % firstcompiler) + if rpath: + f.write(' -Wl,-rpath=%s \\\n' % rpath) +- f.write(' -Wl,-soname,libcpucycles.so.1 \\\n') +- f.write(' -o package/lib/libcpucycles.so.1 \\\n') ++ f.write(' -Wl,-soname,libcpucycles.so.%s \\\n' % soversion) ++ f.write(' -o package/lib/libcpucycles.so.%s \\\n' % soversion) + f.write(' "$@"\n') +- f.write('chmod 644 package/lib/libcpucycles.so.1\n') ++ f.write('chmod 644 package/lib/libcpucycles.so.%s\n' % soversion) + os.chmod('build/%s/scripts/sharedlib' % host,0o755) + +-M = 'package/lib/libcpucycles.so.1: scripts/sharedlib %s\n' % ' '.join(cpucyclesofiles) ++M = 'package/lib/libcpucycles.so.%s: scripts/sharedlib %s\n' % (soversion, ' '.join(cpucyclesofiles)) + M += '\tscripts/sharedlib %s\n' % ' '.join(cpucyclesofiles) + M += '\n' + makefile = M + makefile + +-M = 'package/lib/libcpucycles.so: package/lib/libcpucycles.so.1\n' +-M += '\trm -f package/lib/libcpucycles.so\n' +-M += '\tln -s libcpucycles.so.1 package/lib/libcpucycles.so\n' +-M += '\n' +-makefile = M + makefile +- + # ----- command + + os.makedirs('build/%s/command'%host) +@@ -267,8 +266,8 @@ + M += '\tscripts/compiledefault command %s c -I include\n' % base + M += '\n' + makefile = M + makefile +- M = 'package/bin/%s: command/%s.o%s\n' % (base,base,''.join(' package/lib/%s.%s' % (x,linktype) for x in libs)) +- M += '\tcd command && ./link bin/%s %s.o%s -lm -lrt\n' % (base,base,''.join(' lib/%s.%s' % (x,linktype) for x in libs)) ++ M = 'package/bin/%s: command/%s.o%s\n' % (base,base,''.join(' package/lib/%s.%s.%s' % (x,linktype,soversion) for x in libs)) ++ M += '\tcd command && ./link bin/%s %s.o%s -lm -lrt\n' % (base,base,''.join(' lib/%s.%s.%s' % (x,linktype,soversion) for x in libs)) + M += '\n' + makefile = M + makefile + commands += ['package/bin/%s' % base] +@@ -286,7 +285,7 @@ + + # ----- make default + +-M = 'default: package/lib/libcpucycles.a package/lib/libcpucycles.so package/lib/libcpucycles.so.1 \\\n' ++M = 'default: package/lib/libcpucycles.a package/lib/libcpucycles.so.%s \\\n' % soversion + M += 'commands\n' + M += '\n' + makefile = M + makefile diff --git a/misc/libcpucycles/patches/patch-configure_remove_librt b/misc/libcpucycles/patches/patch-configure_remove_librt new file mode 100644 index 00000000000..227492cecfb --- /dev/null +++ b/misc/libcpucycles/patches/patch-configure_remove_librt @@ -0,0 +1,13 @@ +OpenBSD neither provides nor requires librt. +Index: configure +--- configure.orig ++++ configure +@@ -267,7 +267,7 @@ + M += '\n' + makefile = M + makefile + M = 'package/bin/%s: command/%s.o%s\n' % (base,base,''.join(' package/lib/%s.%s.%s' % (x,linktype,soversion) for x in libs)) +- M += '\tcd command && ./link bin/%s %s.o%s -lm -lrt\n' % (base,base,''.join(' lib/%s.%s.%s' % (x,linktype,soversion) for x in libs)) ++ M += '\tcd command && ./link bin/%s %s.o%s -lm\n' % (base,base,''.join(' lib/%s.%s.%s' % (x,linktype,soversion) for x in libs)) + M += '\n' + makefile = M + makefile + commands += ['package/bin/%s' % base] diff --git a/misc/libcpucycles/patches/patch-configure_translate_host_arch b/misc/libcpucycles/patches/patch-configure_translate_host_arch new file mode 100644 index 00000000000..f7826cf4b8b --- /dev/null +++ b/misc/libcpucycles/patches/patch-configure_translate_host_arch @@ -0,0 +1,36 @@ +Translate OpenBSD architecture name to the name used by upstream. +Index: configure +--- configure.orig ++++ configure +@@ -37,13 +37,30 @@ + + makefile = '' + ++ ++# Some OpenBSD architecture names don't match the ++# architecture name used by upstream, so they require to ++# be translated, so they can be recognized by build scripts. ++# ++def translate_arch(openbsd_arch): ++ archs = { ++ 'arm': 'arm32', ++ 'armv7': 'arm32', ++ 'i386': 'x86', ++ 'powerpc64': 'ppc64', ++ 'macppc': 'ppc32', ++ 'powerpc': 'ppc32', ++ } ++ return archs.get(openbsd_arch, openbsd_arch) ++ ++ + for arg in sys.argv[1:]: + if arg.startswith('--prefix='): + prefix = arg[9:] + continue + if arg.startswith('--host='): + host = arg[7:] +- host = host.split('-')[0] ++ host = translate_arch(host.split('-')[0]) + continue + if arg.startswith('--soversion='): + soversion = arg[12:] diff --git a/misc/libcpucycles/patches/patch-cpucycles_3 b/misc/libcpucycles/patches/patch-cpucycles_3 new file mode 100644 index 00000000000..d7c6775c415 --- /dev/null +++ b/misc/libcpucycles/patches/patch-cpucycles_3 @@ -0,0 +1,40 @@ +Small adjustments to make library manpage consistent +Index: doc/man/cpucycles.3 +--- doc/man/cpucycles.3.orig ++++ doc/man/cpucycles.3 +@@ -1,12 +1,13 @@ + .\" Automatically generated by Pandoc 2.9.2.1 + .\" +-.TH "cpucycles" "3" "" "" "" ++.TH "CPUCYCLES" "3" "" "" + .hy +-.SS NAME + .PP ++.SH NAME ++.PP + cpucycles - count CPU cycles +-.SS SYNOPSIS +-.IP ++.SH SYNOPSIS ++.PP + .nf + \f[C] + #include <cpucycles.h> +@@ -19,8 +20,7 @@ + .fi + .PP + Link with \f[C]-lcpucycles\f[R]. +-Old systems may also need \f[C]-lrt\f[R]. +-.SS DESCRIPTION ++.SH DESCRIPTION + .PP + \f[C]cpucycles()\f[R] returns an estimate for the number of CPU cycles + that have occurred since an unspecified time in the past (perhaps system +@@ -52,6 +52,6 @@ + selects one of the available counters and updates the + \f[C]cpucycles\f[R] pointer accordingly. + Subsequent calls to \f[C]cpucycles()\f[R] are thread-safe. +-.SS SEE ALSO ++.SH SEE ALSO + .PP + \f[B]gettimeofday\f[R](2), \f[B]clock_gettime\f[R](2) diff --git a/misc/libcpucycles/pkg/DESCR b/misc/libcpucycles/pkg/DESCR new file mode 100644 index 00000000000..06d10731f20 --- /dev/null +++ b/misc/libcpucycles/pkg/DESCR @@ -0,0 +1,6 @@ +libcpucyples provides a simple API to access hardware precise timers +to understand and improve software performance. + +libcpucycles understands machine-level cycle counters for most architectures. +libcpucycles also understands common OS-level mechanisms, which give varying +levels of accuracy. diff --git a/misc/libcpucycles/pkg/PLIST b/misc/libcpucycles/pkg/PLIST new file mode 100644 index 00000000000..fd12f3cabd2 --- /dev/null +++ b/misc/libcpucycles/pkg/PLIST @@ -0,0 +1,5 @@ +@bin bin/cpucycles-info +include/cpucycles.h +@static-lib lib/libcpucycles.a +@lib lib/libcpucycles.so.${LIBcpucycles_VERSION} +@man man/man3/cpucycles.3