commit: 16f347ffdff4da72d9a262a82f32777229c413b2
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 9 00:38:23 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun 9 06:57:10 2023 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=16f347ff
Port to Meson
... yielding
```
/tmp/destdir
└── usr
└── local
├── bin
│ └── consoletype
├── lib
│ └── gentoo
│ └── functions.sh
├── libexec
│ └── gentoo
│ └── ecma48-cpr
└── share
└── man
└── man1
└── consoletype.1
11 directories, 4 files
```
Signed-off-by: Sam James <sam <AT> gentoo.org>
Makefile | 39 ---------------------------------
functions.sh => functions.sh.in | 7 +-----
meson.build | 48 +++++++++++++++++++++++++++++++++++++++++
meson_options.txt | 3 +++
4 files changed, 52 insertions(+), 45 deletions(-)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 3fa8d85..0000000
--- a/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# gentoo-functions Makefile
-# Copyright 2014-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-VERSION = 0.20
-GITREF ?= $(VERSION)
-PKG ?= gentoo-functions-$(VERSION)
-
-ROOTPREFIX ?=
-ROOTSBINDIR ?= $(ROOTPREFIX)/sbin
-ROOTLIBEXECDIR ?= $(ROOTPREFIX)/lib/gentoo
-
-PREFIX ?= /usr
-MANDIR ?= $(PREFIX)/share/man
-
-PROGRAMS = consoletype
-
-all: $(PROGRAMS)
-
-check: all
- ./test-functions
-
-install: all
- install -m 0755 -d $(DESTDIR)$(ROOTSBINDIR)
- install -m 0755 consoletype $(DESTDIR)$(ROOTSBINDIR)
- install -m 0755 -d $(DESTDIR)$(ROOTLIBEXECDIR)
- install -m 0644 functions.sh $(DESTDIR)$(ROOTLIBEXECDIR)
- install -m 0755 -d $(DESTDIR)$(MANDIR)/man1
- install -m 0644 consoletype.1 $(DESTDIR)$(MANDIR)/man1
-
-clean:
- rm -rf $(PROGRAMS)
-
-dist:
- git archive --prefix=$(PKG)/ $(GITREF) | xz > $(PKG).tar.xz
-
-consoletype: consoletype.c
-
-# vim: set ts=4 :
diff --git a/functions.sh b/functions.sh.in
similarity index 98%
rename from functions.sh
rename to functions.sh.in
index 154c8a4..3053162 100644
--- a/functions.sh
+++ b/functions.sh.in
@@ -9,11 +9,6 @@
# intended for internal use shall be prefixed with "genfun_" to indicate so,
# and to reduce the probability of name space conflicts.
-# FIXME. There is just one invocation of ./ecma48-cpr, which can be found in
-# the _update_cursor_coords function. If you think it should be named sometime
-# else, I'm open to suggestions. Its behaviour now resembles that of stty size,
-# except that it reports the cursor coordinates (obviously).
-
#
# Called by ebegin, eerrorn, einfon, and ewarnn.
#
@@ -632,7 +627,7 @@ _update_winsize() {
_update_cursor_coords() {
# shellcheck disable=2046
- set -- $(./ecma48-cpr)
+ set -- $(@GENTOO_LIBEXEC_DIR@/ecma48-cpr)
if [ "$#" -eq 2 ] && is_int "$1" && is_int "$2"; then
genfun_y=$1
genfun_x=$2
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..049812d
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,48 @@
+project(
+ 'gentoo-functions', 'c',
+ version: '0.20',
+ license: 'GPL-2.0-only',
+ default_options : [
+ 'warning_level=2',
+ 'c_std=gnu11',
+ ]
+)
+
+conf_data = configuration_data()
+conf_data.set('version', meson.project_version())
+conf_data.set('GENTOO_LIBEXEC_DIR', get_option('prefix') /
get_option('libexecdir') / 'gentoo')
+
+configure_file(
+ input: 'functions.sh.in',
+ output: 'functions.sh',
+ configuration: conf_data,
+ install: true,
+ install_dir: 'lib/gentoo'
+)
+
+cc = meson.get_compiler('c')
+
+executable(
+ 'consoletype',
+ 'consoletype.c',
+ install: true
+)
+
+install_man(
+ 'consoletype.1',
+)
+
+executable(
+ 'ecma48-cpr',
+ 'ecma48-cpr.c',
+ install: true,
+ install_dir: get_option('prefix') / get_option('libexecdir') / 'gentoo'
+)
+
+do_tests = get_option('tests')
+if do_tests
+ test(
+ 'test-functions', files('test-functions'),
+ workdir : meson.current_source_dir(),
+ )
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..7fbab2d
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('tests', type : 'boolean', value : true,
+ description : 'Build tests'
+)