commit b458cbdaf712bcd78909f821b20fb355e3b738f7
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date: Fri, 4 Sep 2020 14:51:39 +1000
Initial commit.
Diffstat:
5 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/config.h.in b/config.h.in
@@ -0,0 +1 @@
+#include <@CURSES_HEADER@>
diff --git a/meson.build b/meson.build
@@ -0,0 +1,26 @@
+project(
+ 'ncurses-test',
+ 'c',
+ version : '1.0',
+ default_options : [
+ 'warning_level=2'
+ ],
+)
+
+cc = meson.get_compiler('c')
+conf = configuration_data()
+
+subdir('ncurses')
+
+configure_file(
+ input: 'config.h.in',
+ output: 'config.h',
+ configuration: conf,
+)
+
+exe = executable(
+ 'ncurses_test',
+ 'ncurses_test.c',
+ dependencies: curses,
+ install : true
+)
diff --git a/ncurses/meson.build b/ncurses/meson.build
@@ -0,0 +1,66 @@
+# Ultimate ncurses detection 100% real no fake
+nc_libs = [
+ 'ncursesw',
+ 'ncurses',
+ 'curses'
+]
+nc_headers = [
+ 'ncursesw/ncurses.h',
+ 'ncursesw.h',
+ 'ncurses/ncurses.h',
+ 'ncurses/curses.h',
+ 'ncurses.h',
+ 'curses.h',
+]
+nc_progs = [
+ 'ncursesw6-config',
+ 'ncursesw5-config',
+ 'ncurses6-config',
+ 'ncurses5-config',
+]
+wide_incantations = [
+ '-D_XOPEN_SOURCE_EXTENDED',
+ '-DNCURSES_WIDECHAR',
+]
+
+found = false
+foreach h : nc_headers
+ if cc.has_header(h)
+ found = true
+ conf.set('CURSES_HEADER', h)
+ break
+ endif
+endforeach
+if not found
+ error('ncurses header not found')
+endif
+
+foreach l : nc_libs
+ curses = dependency(l, required: false)
+ if curses.found()
+ subdir_done()
+ endif
+endforeach
+foreach p : nc_progs
+ prog = find_program(p, '/bin', '/usr/bin', '/usr/local/bin', required: false)
+ if not prog.found()
+ continue
+ endif
+ libs = run_command(prog, '--libs-only-l').stdout().strip()
+ cflags = run_command(prog, '--cflags').stdout().strip()
+ version = run_command(prog, '--version').stdout().strip()
+
+ curses = declare_dependency(
+ 'curses',
+ compile_args: [cflags, wide_incantations],
+ link_args: libs,
+ version: version,
+ )
+ subdir_done()
+endforeach
+foreach l : nc_libs
+ curses = cc.find_library(p, required: false)
+ if curses.found()
+ subdir_done()
+ endif
+endforeach
diff --git a/ncurses_test.c b/ncurses_test.c
@@ -0,0 +1,13 @@
+#include "config.h"
+
+int
+main(int argc, char **argv)
+{
+ initscr(); /* Start curses mode */
+ printw("Hello World!"); /* Print Hello World */
+ refresh(); /* Print it on to the real screen */
+ getch(); /* Wait for user input */
+ endwin(); /* End curses mode */
+
+ return 0;
+}