From 0c09fe5449c8c9aaac454f964b808b9b881202d2 Mon Sep 17 00:00:00 2001 From: Alexander Epaneshnikov Date: Sat, 19 Jun 2021 05:53:04 +0300 Subject: [PATCH] switch to meson (#30) switch to a meson-based build system --- .gitignore | 4 +- Makefile | 37 ------------------- README.md | 12 ++++-- doc/meson.build | 1 + meson.build | 21 +++++++++++ meson_options.txt | 2 + services/meson.build | 4 ++ services/systemd/espeakup.conf | 1 - .../{espeakup.service => espeakup.service.in} | 6 +-- services/systemd/meson.build | 17 +++++++++ src/cli.c | 1 + src/espeakup.h | 1 - src/meson.build | 12 ++++++ src/version.h.in | 25 +++++++++++++ 14 files changed, 96 insertions(+), 48 deletions(-) delete mode 100644 Makefile create mode 100644 doc/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 services/meson.build delete mode 100644 services/systemd/espeakup.conf rename services/systemd/{espeakup.service => espeakup.service.in} (67%) create mode 100644 services/systemd/meson.build create mode 100644 src/meson.build create mode 100644 src/version.h.in diff --git a/.gitignore b/.gitignore index d1c8b4b..1b2211d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -espeakup -src/*.d -src/*.o +build* diff --git a/Makefile b/Makefile deleted file mode 100644 index d8d47a5..0000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -PREFIX = /usr/local -BINDIR = ${PREFIX}/bin -MANDIR = ${PREFIX}/share/man -SRC_DIR = src -DEPFLAGS = -MMD -WARNFLAGS = -Wall -Wpedantic \ - -Wextra - -CFLAGS += ${DEPFLAGS} ${WARNFLAGS} - -LDLIBS = -lespeak-ng -lpthread -lasound -lm - -INSTALL = install -BINMODE = 0755 -MANMODE = 0644 - -SRC = $(wildcard $(SRC_DIR)/*.c) -OBJECTS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c)) - -all: espeakup - -install: espeakup - ${INSTALL} -d ${DESTDIR}${BINDIR} - ${INSTALL} -m ${BINMODE} $< ${DESTDIR}${BINDIR} - ${INSTALL} -d ${DESTDIR}${MANDIR}/man8 - ${INSTALL} -m ${MANMODE} doc/espeakup.8 ${DESTDIR}${MANDIR}/man8 - -espeakup: ${OBJECTS} - cc $(LDLIBS) -o ./espeakup $(OBJECTS) - -clean: - ${RM} $(SRC_DIR)/*.d $(SRC_DIR)/*.o - -distclean: clean - ${RM} espeakup - --include ${SRCS:.c=.d} diff --git a/README.md b/README.md index a69a5df..d05278f 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,15 @@ is beyond the scope of this document. The preferred way to install espeakup is using your distribution's packaging system, but if your distribution does not have a package for -espeakup yet, espeakup just uses a Makefile, so you should be able to -change to the source directory, then type make, then as root, make -install. +espeakup yet, espeakup just uses meson, so you should be able to +change to the source directory, then type: + +```bash +meson . ./build +cd ./build +ninja +sudo ninja install +``` ## Starting Up diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000..7726ab6 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1 @@ +install_man('espeakup.8') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..261df7e --- /dev/null +++ b/meson.build @@ -0,0 +1,21 @@ +project('espeakup', 'c', + default_options : ['buildtype=debugoptimized', 'c_std=gnu11', 'warning_level=3'], + license : 'GPL-3.0-or-later', + version : '0.81', + meson_version : '>=0.47.0') + +cc = meson.get_compiler('c') +thread_dep = dependency('threads') +espeak_dep = dependency('espeak-ng') +alsa_dep = dependency('alsa') +math_dep = cc.find_library('m', required : false) + +subdir('doc') +subdir('services') +subdir('src') + +executable('espeakup', + espeakup_version, + espeakup_sources, + dependencies : [thread_dep, espeak_dep, alsa_dep, math_dep], + install : true) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..45e3a33 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('systemd', type : 'feature', value : 'auto', + description :'enable systemd support') diff --git a/services/meson.build b/services/meson.build new file mode 100644 index 0000000..0be40f1 --- /dev/null +++ b/services/meson.build @@ -0,0 +1,4 @@ +systemd = dependency('systemd', required: get_option('systemd')) +if systemd.found() + subdir('systemd') +endif diff --git a/services/systemd/espeakup.conf b/services/systemd/espeakup.conf deleted file mode 100644 index 56aebc1..0000000 --- a/services/systemd/espeakup.conf +++ /dev/null @@ -1 +0,0 @@ -default_voice= diff --git a/services/systemd/espeakup.service b/services/systemd/espeakup.service.in similarity index 67% rename from services/systemd/espeakup.service rename to services/systemd/espeakup.service.in index b840489..ec5f4da 100644 --- a/services/systemd/espeakup.service +++ b/services/systemd/espeakup.service.in @@ -6,10 +6,10 @@ After=systemd-udev-settle.service sound.target [Service] Type=forking -EnvironmentFile=/etc/conf.d/espeakup PIDFile=/run/espeakup.pid -ExecStartPre=+/sbin/modprobe speakup_soft -ExecStart=/usr/bin/espeakup --default-voice=${default_voice} +Environment="default_voice=" +ExecStartPre=+modprobe speakup_soft +ExecStart=@bindir@/espeakup --default-voice=${default_voice} ExecReload=kill -HUP $MAINPID Restart=always diff --git a/services/systemd/meson.build b/services/systemd/meson.build new file mode 100644 index 0000000..4a693ed --- /dev/null +++ b/services/systemd/meson.build @@ -0,0 +1,17 @@ +unitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir') +prefixdir = get_option('prefix') +bindir = join_paths(prefixdir, get_option('bindir')) + +unit_conf = configuration_data() + +unit_conf.set('bindir', bindir) + +service_file = configure_file( + input : 'espeakup.service.in', + output : 'espeakup.service', + configuration : unit_conf +) + +install_data(service_file, + install_dir : unitdir +) diff --git a/src/cli.c b/src/cli.c index b8a6543..280b507 100644 --- a/src/cli.c +++ b/src/cli.c @@ -23,6 +23,7 @@ #include #include "espeakup.h" +#include "version.h" /* pid path */ extern char *pidPath; diff --git a/src/espeakup.h b/src/espeakup.h index 9518c6d..d6daaf0 100644 --- a/src/espeakup.h +++ b/src/espeakup.h @@ -28,7 +28,6 @@ #include "queue.h" -#define PACKAGE_VERSION "0.81" #define PACKAGE_BUGREPORT "https://github.com/linux-speakup/espeakup/issues" enum espeakup_mode_t { diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..f1c4610 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,12 @@ +espeakup_version = vcs_tag(input : 'version.h.in', output : 'version.h') + + +espeakup_sources = files([ + 'cli.c', + 'espeak.c', + 'espeakup.c', + 'queue.c', + 'signal.c', + 'softsynth.c', + 'stringhandling.c' +]) diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000..8c0038e --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,25 @@ +/* + * espeakup - interface which allows speakup to use espeak + * + * Copyright (C) 2008 William Hubbs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __VERSION_H +#define __VERSION_H + +#define PACKAGE_VERSION "@VCS_TAG@" + +#endif