diff --git a/CMakeLists.txt b/CMakeLists.txt index fba6fed..0397d71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ include(GNUInstallDirs) # These are relative to CMAKE_INSTALL_PREFIX # which by default is "/usr/local" -set(CONSOLE_FONTS_DIRS "share/consolefonts" "lib/kbd/consolefonts") +set(CONSOLE_FONTS_DIRS "share/consolefonts" "lib/kbd/consolefonts" "share/kbd/consolefonts") set(X_FONTS_DIRS "lib/X11/fonts/misc" "X11R6/lib/X11/fonts/misc" "share/fonts/X11/misc") set(MKFONTDIR "/usr/bin/mkfontdir") diff --git a/Makefile.am b/Makefile.am index be482b4..0716c26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,6 +26,11 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/matrix.fnt $(DESTDIR)/usr/lib/kbd/consolefonts; \ $(INSTALL_DATA) $(srcdir)/matrix.psf.gz $(DESTDIR)/usr/lib/kbd/consolefonts; \ fi; \ + if test -d /usr/share/kbd/consolefonts; then \ + echo " Installing matrix fonts in /usr/share/kbd/consolefonts..."; \ + $(INSTALL_DATA) $(srcdir)/matrix.fnt $(DESTDIR)/usr/share/kbd/consolefonts; \ + $(INSTALL_DATA) $(srcdir)/matrix.psf.gz $(DESTDIR)/usr/share/kbd/consolefonts; \ + fi; \ if test -d /usr/share/fonts/misc; then \ echo " Installing X window matrix fonts in /usr/share/fonts/misc..."; \ echo " Running mkfontdir /usr/share/fonts/misc..."; \ diff --git a/cmatrix.c b/cmatrix.c index 7d8ca39..03f5b91 100644 --- a/cmatrix.c +++ b/cmatrix.c @@ -47,6 +47,9 @@ #include #endif +#ifdef HAVE_NCURSESW +#include +#else #ifdef HAVE_NCURSES_H #include #else @@ -56,7 +59,7 @@ #include #endif #endif - +#endif #ifdef HAVE_SYS_IOCTL_H #include #endif @@ -261,8 +264,11 @@ void resize_screen(void) { char *tty; int fd = 0; int result = 0; + int cols = 0; + int lines = 0; struct winsize win; + tty = ttyname(0); if (!tty) { return; @@ -271,8 +277,8 @@ void resize_screen(void) { result = GetConsoleScreenBufferInfo(hStdHandle, &csbiInfo); if (!result) return; - LINES = csbiInfo.dwSize.Y; - COLS = csbiInfo.dwSize.X; + lines = csbiInfo.dwSize.Y; + cols = csbiInfo.dwSize.X; #else } fd = open(tty, O_RDWR); @@ -284,21 +290,21 @@ void resize_screen(void) { return; } - COLS = win.ws_col; - LINES = win.ws_row; + cols = win.ws_col; + lines = win.ws_row; #endif - if (LINES < 10) { - LINES = 10; + if (lines < 10) { + lines = 10; } - if (COLS < 10) { - COLS = 10; + if (cols < 10) { + cols = 10; } #ifdef HAVE_RESIZETERM - resizeterm(LINES, COLS); + resizeterm(lines, cols); #ifdef HAVE_WRESIZE - if (wresize(stdscr, LINES, COLS) == ERR) { + if (wresize(stdscr, lines, cols) == ERR) { c_die("Cannot resize window!"); } #endif /* HAVE_WRESIZE */ diff --git a/configure.ac b/configure.ac index 0565a52..27b5550 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([cmatrix], [2.0], [abishekvashok@gmail.com]) +AC_INIT([cmatrix],[2.0],[abishekvashok@gmail.com]) AC_CONFIG_SRCDIR([cmatrix.c]) -AM_CONFIG_HEADER(config.h) +AC_CONFIG_HEADERS(config.h) AM_INIT_AUTOMAKE AC_CANONICAL_HOST @@ -19,52 +19,88 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_MAKE_SET -dnl Checks for libraries. -dnl Replace `main' with a function in -lncurses: -AC_CHECK_LIB(ncurses, main) dnl Checks for header files. -AC_HEADER_STDC +AC_PROG_EGREP AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h termios.h termio.h getopt.h) dnl Checks for library functions. -AC_TYPE_SIGNAL +m4_warn([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. +Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl +AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE( +[AC_LANG_PROGRAM([#include +#include +], + [return *(signal (0, 0)) (0) == 1;])], + [ac_cv_type_signal=int], + [ac_cv_type_signal=void])]) +AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers + (`int' or `void').]) + AC_CHECK_FUNCS(putenv) dnl Checks for libraries. AC_CHECK_HEADERS(curses.h ncurses.h) -CURSES_LIB_NAME="" -AC_CHECK_LIB(ncurses, tgetent, CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses) -if eval "test x$CURSES_LIB_NAME = x" +TERMCAP_LIB_NAME="" +AC_CHECK_LIB(ncursesw, tgetent, TERMCAP_LIB="-lncursesw" TERMCAP_LIB_NAME=ncursesw) + +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(curses, tgetent, CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses) + AC_CHECK_LIB(ncurses, tgetent, TERMCAP_LIB="-lncurses" TERMCAP_LIB_NAME=ncurses) fi -if eval "test x$CURSES_LIB_NAME = x" +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(pdcurses, initscr, CURSES_LIB="-lpdcurses" CURSES_LIB_NAME=pdcurses) + AC_CHECK_LIB(curses, tgetent, TERMCAP_LIB="-lcurses" TERMCAP_LIB_NAME=curses) fi -if eval "test x$CURSES_LIB_NAME = x" +if eval "test x$TERMCAP_LIB_NAME = x" +then + AC_CHECK_LIB(pdcurses, initscr, TERMCAP_LIB="-lpdcurses" TERMCAP_LIB_NAME=pdcurses) +fi + +if eval "test x$TERMCAP_LIB_NAME = x" +then + AC_CHECK_LIB(termcap, tgetent, TERMCAP_LIB="-ltermcap" TERMCAP_LIB_NAME=termcap) +fi + +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap) + AC_CHECK_LIB(tinfo, tgetent, TERMCAP_LIB="-ltinfo" TERMCAP_LIB_NAME=tinfo) fi +if eval "test x$TERMCAP_LIB_NAME = x" +then + AC_MSG_WARN([ +*** No termcap lib available, consider getting the official ncurses +*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get +*** errors compiling cmatrix.]) +else + AC_MSG_RESULT(Using $TERMCAP_LIB_NAME as the termcap library) +fi + +CURSES_LIB_NAME="" +AC_CHECK_LIB(ncursesw, addwstr, CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw) + if eval "test x$CURSES_LIB_NAME = x" then - AC_CHECK_LIB(tinfo, tgetent, CURSES_LIB="-ltinfo" CURSES_LIB_NAME=tinfo) + AC_CHECK_LIB(ncurses, addwstr, CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses) fi if eval "test x$CURSES_LIB_NAME = x" then AC_MSG_WARN([ -*** No termcap lib available, consider getting the official ncurses +*** No curses lib available, consider getting the official ncurses *** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get *** errors compiling cmatrix.]) else - AC_MSG_RESULT("Using $CURSES_LIB_NAME as the termcap library") + AC_MSG_RESULT(Using $CURSES_LIB_NAME as the ncurses library) + if eval "test $CURSES_LIB_NAME = ncursesw" + then + AC_CHECK_LIB([$CURSES_LIB_NAME], addwstr, [AC_DEFINE(HAVE_NCURSESW)]) + fi fi AC_CHECK_LIB($CURSES_LIB_NAME, use_default_colors, @@ -72,7 +108,6 @@ AC_CHECK_LIB($CURSES_LIB_NAME, use_default_colors, AC_CHECK_LIB($CURSES_LIB_NAME, resizeterm, [AC_DEFINE(HAVE_RESIZETERM)]) AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, [AC_DEFINE(HAVE_WRESIZE)]) - dnl Only change gcc options if we are using gcc. if test "$ac_cv_prog_CC" = gcc -o "$ac_cv_prog_CC" = g++; then CFLAGS="$CFLAGS -Wall -Wno-comment" @@ -115,10 +150,11 @@ if test "x$enable_fonts" != xfalse; then if test x$SETFONT != x -o x$SETFONT != x'"$SETFONT"'; then dnl Now look for the console fonts directory - AC_CHECK_FILES([/usr/lib/kbd/consolefonts /usr/share/consolefonts]) + AC_CHECK_FILES([/usr/lib/kbd/consolefonts /usr/share/consolefonts /usr/share/kbd/consolefonts]) if test "x$ac_cv_file__usr_lib_kbd_consolefonts" = "xno"; then if test "x$ac_cv_file__usr_share_consolefonts" = "xno"; then + if test "x$ac_cv_file__usr_share_kbd_consolefonts" = "xno"; then AC_MSG_WARN([ *** You do not appear to have a consolefonts directory in a standard location @@ -128,6 +164,7 @@ if test "x$enable_fonts" != xfalse; then *** matrix console font (and the -l command line switch) unless the font *** is located in your current directory when you run CMatrix. ]) + fi fi fi fi @@ -152,7 +189,7 @@ fi dnl Parse any configure options -LIBS="$LIBS $CURSES_LIB" +LIBS="$LIBS $CURSES_LIB $TERMCAP_LIB" AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging (def disabled)],) AM_CONDITIONAL([MATRIX_FONTS], [test x$enable_fonts = xtrue]) @@ -168,5 +205,7 @@ AH_TEMPLATE([HAVE_SETFONT], [Define this if you have the linux setfont program]) AH_TEMPLATE([HAVE_WRESIZE], [Define this if you have the wresize function in your ncurses-type library]) AH_TEMPLATE([HAVE_RESIZETERM], [Define this if you have the resizeterm function in your ncurses-type library]) AH_TEMPLATE([USE_TIOCSTI], [Define this if you want a character you pressed in the screensaver mode to retain in the terminal]) +AH_TEMPLATE([HAVE_NCURSESW], [Define this if you have the ncursesw library]) -AC_OUTPUT(Makefile cmatrix.spec) +AC_CONFIG_FILES([Makefile cmatrix.spec]) +AC_OUTPUT