diff --git a/meson.build b/meson.build index 3d46232..5ae53b6 100644 --- a/meson.build +++ b/meson.build @@ -2,6 +2,10 @@ project('psxavenc', 'c', default_options: ['c_std=c11']) add_project_arguments('-D_POSIX_C_SOURCE=201112L', language : 'c') +conf_data = configuration_data() +conf_data.set('VERSION', '"' + run_command('git', 'describe', '--tags', '--match=v*', check: true).stdout().strip() + '"') +configure_file(output: 'config.h', configuration: conf_data) + libm_dep = meson.get_compiler('c').find_library('m') ffmpeg = [ diff --git a/psxavenc/psxavenc.c b/psxavenc/psxavenc.c index 3e58729..5c96d30 100644 --- a/psxavenc/psxavenc.c +++ b/psxavenc/psxavenc.c @@ -23,6 +23,7 @@ freely, subject to the following restrictions: */ #include "common.h" +#include "config.h" const char *format_names[NUM_FORMATS] = { "xa", "xacd", @@ -42,6 +43,7 @@ void print_help(void) { " psxavenc -t [-f freq] [-c 1-24] [-L] [-i size] [-a size] \n" "\nTool options:\n" " -h Show this help message and exit\n" + " -V Show version information and exit\n" " -q Suppress all non-error messages\n" "\n" "Output options:\n" @@ -100,16 +102,24 @@ void print_help(void) { ); } +void print_version(void) { + printf("psxavenc " VERSION "\n"); +} + int parse_args(settings_t* settings, int argc, char** argv) { int c, i; char *next; - while ((c = getopt(argc, argv, "?hqt:F:C:f:b:c:LR:i:a:s:IS:r:x:")) != -1) { + while ((c = getopt(argc, argv, "?hVqt:F:C:f:b:c:LR:i:a:s:IS:r:x:")) != -1) { switch (c) { case '?': case 'h': { print_help(); return -1; } break; + case 'V': { + print_version(); + return -1; + } break; case 'q': { settings->quiet = true; settings->show_progress = false;