Replace autotools with meson

To introduce much simpler build configuration which is also easier to
maintain.
This commit is contained in:
Martin Lund 2022-02-09 20:50:50 +01:00
parent c01152bb38
commit e9208d693e
26 changed files with 156 additions and 550 deletions

View file

@ -1,24 +0,0 @@
AM_CPPFLAGS = -I$(srcdir)/include
AM_CFLAGS = -Wall
bin_PROGRAMS = tio
tio_SOURCES = tty.c \
options.c \
time.c \
main.c \
log.c \
error.c \
include/tio/tty.h \
include/tio/options.h \
include/tio/time.h \
include/tio/print.h \
include/tio/log.h \
include/tio/error.h
if ADD_SETSPEED2
tio_SOURCES += setspeed2.c
endif
if ENABLE_BASH_COMPLETION
bashcompletiondir=@BASH_COMPLETION_DIR@
bashcompletion_DATA=bash-completion/tio
endif

View file

@ -0,0 +1,19 @@
conf = configuration_data()
conf.set('baudrates', baudrates)
completion_file = configure_file( input: files('tio.in'),
output: 'tio',
configuration: conf,
)
bashcompletiondir = get_option('bashcompletiondir')
if bashcompletiondir == ''
bash_completion_dep = dependency('bash-completion', required: false)
if bash_completion_dep.found()
bashcompletiondir = join_paths(get_option('datadir'), 'bash-completion', 'completions')
endif
endif
if (bashcompletiondir != 'no') and (bashcompletiondir != '')
install_data(completion_file, install_dir: bashcompletiondir)
endif

View file

@ -27,7 +27,7 @@ _tio()
# Complete the arguments to the options.
case "${prev}" in
-b | --baudrate)
local baudrates="@BAUDRATES@"
local baudrates="@baudrates@"
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
return 0
;;

View file

@ -24,9 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "tio/options.h"
#include "tio/print.h"
#include "tio/error.h"
#include "options.h"
#include "print.h"
#include "error.h"
char error[2][1000];

View file

@ -24,9 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "tio/options.h"
#include "tio/print.h"
#include "tio/error.h"
#include "options.h"
#include "print.h"
#include "error.h"
static FILE *fp;
static bool log_error = false;

View file

@ -23,11 +23,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "tio/options.h"
#include "tio/tty.h"
#include "tio/log.h"
#include "tio/error.h"
#include "tio/print.h"
#include "options.h"
#include "tty.h"
#include "log.h"
#include "error.h"
#include "print.h"
int main(int argc, char *argv[])
{

24
src/meson.build Normal file
View file

@ -0,0 +1,24 @@
config_h = configuration_data()
config_h.set_quoted('VERSION', meson.project_version())
config_h.set('BAUDRATE_CASES', baudrate_cases)
configure_file(output: 'config.h', configuration: config_h)
tio_sources = [
'error.c',
'log.c',
'main.c',
'options.c',
'misc.c',
'tty.c'
]
if tcgets2 != ''
tio_sources += 'setspeed2.c'
endif
executable('tio',
tio_sources,
install: true,
)
subdir('bash-completion')

View file

@ -25,8 +25,8 @@
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "tio/error.h"
#include "tio/print.h"
#include "error.h"
#include "print.h"
// "YYYY-MM-DDThh:mm:ss.sss" (ISO-8601 format).
#define TIME_STRING_SIZE 24
@ -51,7 +51,7 @@ char * current_time(void)
len = snprintf(time_string + len, TIME_STRING_SIZE - len, ".%03ld", (long)tv.tv_usec / 1000);
}
return (len >= 0) && (len < TIME_STRING_SIZE) ? time_string : NULL;
return (len < TIME_STRING_SIZE) ? time_string : NULL;
}
void delay(long ms)

View file

@ -19,10 +19,7 @@
* 02110-1301, USA.
*/
#ifndef TIME_H
#define TIME_H
#pragma once
char * current_time(void);
void delay(long ms);
#endif

View file

@ -30,8 +30,8 @@
#include <getopt.h>
#include <termios.h>
#include <limits.h>
#include "tio/options.h"
#include "tio/error.h"
#include "options.h"
#include "error.h"
/* Default options */
struct option_t option =

View file

@ -38,12 +38,12 @@
#include <time.h>
#include <dirent.h>
#include "config.h"
#include "tio/tty.h"
#include "tio/print.h"
#include "tio/options.h"
#include "tio/time.h"
#include "tio/log.h"
#include "tio/error.h"
#include "tty.h"
#include "print.h"
#include "options.h"
#include "misc.h"
#include "log.h"
#include "error.h"
#ifdef HAVE_TERMIOS2
extern int setspeed2(int fd, int baudrate);
@ -364,9 +364,9 @@ void tty_configure(void)
* Only switch cases for baud rates detected supported by the host
* system are inserted.
*
* To see which baud rates are being probed see configure.ac
* To see which baud rates are being probed see meson.build
*/
AUTOCONF_BAUDRATE_CASES
BAUDRATE_CASES
default:
#ifdef HAVE_TERMIOS2