From 49973b40e2bf7ce079c5af3ae3fd60bf4b611137 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 7 May 2023 22:30:57 +0200 Subject: [PATCH] fix some issues, add meson.build which i may or may not use later --- libs/argv.c | 3 +- libs/stream.c | 27 +++++++++++++-- meson.build | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ spmenu.c | 4 +++ 4 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 meson.build diff --git a/libs/argv.c b/libs/argv.c index 3bf5d4f..920cb8b 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -62,7 +62,8 @@ void readargs(int argc, char *argv[]) { // no arguments for (i = 1; i < argc; i++) if (!strcmp(argv[i], "-v") || (!strcmp(argv[i], "--version"))) { // prints version information - puts("spmenu-"VERSION); + //puts("spmenu-"VERSION); + puts("spmenu-unknown"); exit(0); } else if (!strcmp(argv[i], "-h") || (!strcmp(argv[i], "--help"))) { // help usage(); diff --git a/libs/stream.c b/libs/stream.c index 1023c2f..f551dc8 100644 --- a/libs/stream.c +++ b/libs/stream.c @@ -33,14 +33,24 @@ void readstdin(void) { if (parsemarkup(i)) { o = 1; } + + #if !USEIMAGE + if (o) { + ; + } + #endif } + #if USEIMAGE if (!o) longestedge = imagegaps = 0; + #endif // clean if (items) { items[i].text = NULL; + #if USEIMAGE items[i].image = NULL; + #endif } inputw = items ? TEXTWM(items[imax].text) : 0; @@ -100,14 +110,23 @@ void readfile(void) { for (i = 0; i < listsize; i++) { items[i].text = list[i]; - if (parsemarkup(i)) + if (parsemarkup(i)) { o = 1; + } + + #if !USEIMAGE + if (o) { + ; + } + #endif } inputw = items ? TEXTWM(items[i].text) : 0; lines = i; + #if USEIMAGE if (!o) longestedge = imagegaps = 0; + #endif if (i == olistcount) { listcount = i; @@ -179,7 +198,7 @@ int parsemarkup(int index) { // spmenu:version if (!strncmp("version", items[index].ex, strlen("version"))) { - fprintf(stdout, "spmenu version %s", VERSION); + fprintf(stdout, "spmenu version %f", VERSION); exit(0); } @@ -196,9 +215,13 @@ int parsemarkup(int index) { } } + #if USEIMAGE if (limg) { return 1; } else { return 0; } + #else + return 0; + #endif } diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..94166b7 --- /dev/null +++ b/meson.build @@ -0,0 +1,92 @@ +project( + 'spmenu', + 'c', + version : '1.1', + default_options : ['warning_level=3'] +) + +imlib2 = true +openssl = true +xresources = true +fribidi = true +libconfig = true +pango = true +pangoxft = true +xinerama = true +opt = '-O2' + +cc = meson.get_compiler('c') +m_dep = cc.find_library('m', required : false) + +project_source_files = [ + 'libs/libdrw/draw.c', + 'spmenu.c', + 'libs/sl/main.c', +] + +project_dependencies = [ + dependency('x11'), + dependency('xrender'), + dependency('freetype2'), + dependency('xft'), + dependency('fontconfig'), + cc.find_library('m', required : false), +] + +build_args = [ + '-DVERSION=' + meson.project_version(), + + '-D_DEFAULT_SOURCE', + '-D_BSD_SOURCE', + '-D_XOPEN_SOURCE=700L', + '-D_POSIX_C_SOURCE=200809L', + + '-std=c99', + '-pedantic', + '-Wall', + '-Wno-deprecated-declarations', + '-Wno-unused-parameter', + '-Wno-sign-compare', + opt, +] + +if imlib2 and openssl + project_dependencies += [ dependency('imlib2') ] + project_dependencies += [ dependency('openssl') ] + build_args += [ '-DIMAGE' ] +endif + +if fribidi + project_dependencies += [ dependency('fribidi') ] + build_args += [ '-DRTL' ] +endif + +if xinerama + project_dependencies += [ dependency('xinerama') ] + build_args += [ '-DXINERAMA' ] +endif + +if pango and pangoxft + project_dependencies += [ dependency('pango') ] + project_dependencies += [ dependency('pangoxft') ] + build_args += [ '-DPANGO' ] +endif + +if libconfig + project_dependencies += [ dependency('libconfig') ] + build_args += [ '-DCONFIG' ] +endif + +if xresources + build_args += [ '-DXRESOURCES' ] +endif + +project_target = executable( + meson.project_name(), + project_source_files, + dependencies: project_dependencies, + install : true, + c_args : build_args, +) + +test('spmenu', project_target) diff --git a/spmenu.c b/spmenu.c index 6fd3e5a..0c1800e 100644 --- a/spmenu.c +++ b/spmenu.c @@ -64,6 +64,10 @@ #define USEXRESOURCES 1 #endif +#ifndef VERSION +#define VERSION "unknown" +#endif + // include fribidi used for right to left language support #if USERTL #include