From 1750721923b266141fd862269f12e4bd834a3ec5 Mon Sep 17 00:00:00 2001
From: Paul <sajattack@gmail.com>
Date: Tue, 21 Nov 2017 19:50:30 -0800
Subject: [PATCH] Add recipe for cmatrix (#108)

* Add recipe for cmatrix

* Add recipe for terminfo

* Fix recipe for cmatrix
---
 recipes/cmatrix/cmatrix.patch | 101 ++++++++++++++++++++++++++++++++++
 recipes/cmatrix/recipe.sh     |  51 +++++++++++++++++
 recipes/terminfo/recipe.sh    |  32 +++++++++++
 3 files changed, 184 insertions(+)
 create mode 100644 recipes/cmatrix/cmatrix.patch
 create mode 100644 recipes/cmatrix/recipe.sh
 create mode 100644 recipes/terminfo/recipe.sh

diff --git a/recipes/cmatrix/cmatrix.patch b/recipes/cmatrix/cmatrix.patch
new file mode 100644
index 000000000..0cb612655
--- /dev/null
+++ b/recipes/cmatrix/cmatrix.patch
@@ -0,0 +1,101 @@
+diff -ru source/cmatrix.c source-new/cmatrix.c
+--- source/cmatrix.c	2017-11-18 13:21:42.992870796 -0800
++++ source-new/cmatrix.c	2017-11-18 13:20:45.446407288 -0800
+@@ -37,7 +37,7 @@
+ #ifdef HAVE_NCURSES_H
+ #include <ncurses.h>
+ #else
+-#include <curses.h>
++#include <ncurses/curses.h>
+ #endif
+ 
+ #ifdef HAVE_SYS_IOCTL_H
+@@ -215,47 +215,49 @@
+ 
+ void handle_sigwinch(int s) {
+ 
+-    char *tty = NULL;
+-    int fd = 0;
+-    int result = 0;
+-    struct winsize win;
+-
+-    tty = ttyname(0);
+-    if (!tty) {
+-        return;
+-    }
+-    fd = open(tty, O_RDWR);
+-    if (fd == -1) {
+-        return;
+-    }
+-    result = ioctl(fd, TIOCGWINSZ, &win);
+-    if (result == -1) {
+-        return;
+-    }
+-
+-    COLS = win.ws_col;
+-    LINES = win.ws_row;
+-
+-    if(LINES <10){
+-        LINES = 10;
+-    }
+-    if(COLS <10){
+-        COLS = 10;
+-    }
+-
+-#ifdef HAVE_RESIZETERM
+-    resizeterm(LINES, COLS);
+-#ifdef HAVE_WRESIZE
+-    if (wresize(stdscr, LINES, COLS) == ERR) {
+-        c_die("Cannot resize window!");
+-    }
+-#endif /* HAVE_WRESIZE */
+-#endif /* HAVE_RESIZETERM */
+-
+-    var_init();
+-    /* Do these because width may have changed... */
+-    clear();
+-    refresh();
++/*
++ *    char *tty = NULL;
++ *    int fd = 0;
++ *    int result = 0;
++ *    struct winsize win;
++ *
++ *    tty = ttyname(0);
++ *    if (!tty) {
++ *        return;
++ *    }
++ *    fd = open(tty, O_RDWR);
++ *    if (fd == -1) {
++ *        return;
++ *    }
++ *    result = ioctl(fd, TIOCGWINSZ, &win);
++ *    if (result == -1) {
++ *        return;
++ *    }
++ *
++ *    COLS = win.ws_col;
++ *    LINES = win.ws_row;
++ *
++ *    if(LINES <10){
++ *        LINES = 10;
++ *    }
++ *    if(COLS <10){
++ *        COLS = 10;
++ *    }
++ *
++ *#ifdef HAVE_RESIZETERM
++ *    resizeterm(LINES, COLS);
++ *#ifdef HAVE_WRESIZE
++ *    if (wresize(stdscr, LINES, COLS) == ERR) {
++ *        c_die("Cannot resize window!");
++ *    }
++ *#endif [> HAVE_WRESIZE <]
++ *#endif [> HAVE_RESIZETERM <]
++ *
++ *    var_init();
++ *    [> Do these because width may have changed... <]
++ *    clear();
++ *    refresh();
++ */
+ }
diff --git a/recipes/cmatrix/recipe.sh b/recipes/cmatrix/recipe.sh
new file mode 100644
index 000000000..171789b34
--- /dev/null
+++ b/recipes/cmatrix/recipe.sh
@@ -0,0 +1,51 @@
+GIT=https://github.com/abishekvashok/cmatrix
+BUILD_DEPENDS=(ncurses)
+DEPENDS=(terminfo)
+
+export AR="${HOST}-ar"
+export AS="${HOST}-as"
+export CC="${HOST}-gcc"
+export CXX="${HOST}-g++"
+export LD="${HOST}-ld"
+export NM="${HOST}-nm"
+export OBJCOPY="${HOST}-objcopy"
+export OBJDUMP="${HOST}-objdump"
+export RANLIB="${HOST}-ranlib"
+export READELF="${HOST}-readelf"
+export STRIP="${HOST}-strip"
+
+function recipe_version {
+    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+    skip=1
+}
+
+function recipe_update {
+    echo "skipping update"
+    skip=1
+}
+
+function recipe_build {
+    sysroot="${PWD}/../sysroot"
+    export LDFLAGS="-L$sysroot/lib"
+    export CPPFLAGS="-I$sysroot/include"
+    ./configure --host=${HOST} --prefix=/ --without-fonts
+    make 
+    skip=1
+}
+
+function recipe_test {
+    echo "skipping test"
+    skip=1
+}
+
+function recipe_clean {
+    make clean
+    skip=1
+}
+
+function recipe_stage {
+    dest="$(realpath $1)"
+    make DESTDIR="$dest" install
+    rm -rf $1/share/man
+    skip=1
+}
diff --git a/recipes/terminfo/recipe.sh b/recipes/terminfo/recipe.sh
new file mode 100644
index 000000000..e45ed9dc9
--- /dev/null
+++ b/recipes/terminfo/recipe.sh
@@ -0,0 +1,32 @@
+GIT=https://github.com/sajattack/terminfo
+
+function recipe_version {
+    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+    skip=1
+}
+
+function recipe_update {
+    echo "skipping update"
+    skip=1
+}
+
+function recipe_build {
+    echo "skipping build"
+    skip=1
+}
+
+function recipe_test {
+    echo "skipping test"
+    skip=1
+}
+
+function recipe_clean {
+    echo "skipping clean" 
+    skip=1
+}
+
+function recipe_stage {
+    mkdir -p ../stage/share/terminfo
+    cp -r  * ../stage/share/terminfo/
+    skip=1
+}
-- 
GitLab