Ticket #1957: 0001-patches-for-AIX-with-ncurses-support.patch

File 0001-patches-for-AIX-with-ncurses-support.patch, 14.1 KB (added by tammer, 14 years ago)

second patch version

  • doc/INSTALL

    From 918646020df0298f54c50a081f54d6167f8bda04 Mon Sep 17 00:00:00 2001
    From: Rainer Tammer <tammer@tammer.net>
    Date: Sun, 17 Jan 2010 13:51:07 +0100
    Subject: [PATCH] patches for AIX with ncurses support
    
    ---
     doc/INSTALL                  |   49 ++++++++++++-
     m4.include/mc-cflags.m4      |    9 ++-
     m4.include/mc-with-screen.m4 |  173 +++++++++++++++++++++++++++++++++---------
     src/tty/tty-ncurses.c        |    7 ++
     src/tty/tty-ncurses.h        |    4 +
     src/unixcompat.h             |    4 +
     vfs/direntry.c               |    3 +-
     vfs/vfs.c                    |    4 +
     8 files changed, 215 insertions(+), 38 deletions(-)
    
    diff --git a/doc/INSTALL b/doc/INSTALL
    index 5a39d6a..7b5959b 100644
    a b ncurses): 
    224224     by default if found, otherwise the included S-Lang library is 
    225225     used. 
    226226 
     227`--with-slang-includes=[DIR]' 
     228     Set path to SLANG includes [default=/usr/include]; make sense 
     229     only if --with-screen=slang is used. 
     230 
     231`--with-slang-libs=[DIR]' 
     232     Set path to SLANG library [default=/usr/lib]; mke sense only 
     233     if --with-screen=slang is used. 
     234 
    227235`--with-termcap' 
    228236     If the included S-Lang library is used, this option forces it to 
    229237     use the termcap database, as opposed to the default terminfo 
    230238     database. 
    231239 
     240`--with-ncurses-includes=[DIR]' 
     241     Set path to ncurses includes [default=/usr/include]; make 
     242     sense only if --with-screen=ncurses is used; 
     243     for /usr/local/include/ncurses specify /usr/local/include. 
     244 
     245`--with-ncurses-libs=[DIR]' 
     246     Set path to ncurses library [default=/usr/lib]; make sense 
     247     only if --with-screen=ncurses is used. 
     248 
    232249Compiler options: 
    233250- - - - - - - - - 
    234251 
    mips-dec-ultrix4.3 
    320337mips-dec-{open,net}bsd1.0 
    321338mips-sgi-irix5.2 
    322339mips-sgi-irix5.3 
    323 rs6000-ibm-aix3.2.5 
     340powerpc-ibm-aix5.3.0.0 (IBM XL C, IBM XL C/C++) 
    324341sparc-sun-sunos4.1 
    325342sparc-sun-netbsd1.0 
    326343sparc-sun-solaris2.3 
    team. Sometimes there is no solution than upgrading to a modern and 
    435452free compiler - GCC (Compiler Collection): 
    436453 
    437454http://gcc.gnu.org/ 
     455 
     456AIX 
     457--- 
     458Currently you can not use gcc 4.2.4 (and probably other versions) on 
     459AIX to compiler the S-Lang version. Please use IBM XL C or IBM XL C/C++ 
     460instead. 
     461 
     462If you compile a ncurses version you need to set TERM=dtterm to get 
     463working color support. Furthermore it is important to specify the 
     464--with-ncurses-includes/--with-ncurses-lib parameters because otherwise 
     465mc will pick up term.h from AIX which does not work with the ncurses 
     466library. 
     467 
     468The AIX S-Lang build was tested with S-Lang 2.0.7. Later versions may 
     469also work but are not tested yet. 
     470 
     471Here is an example for S-Lang, it is assumed that the S-Lang library 
     472is installed under /user/local and that you also want want to install 
     473to /usr/local: 
     474 
     475  export CC=cc_r 
     476  export CXX=xlC_r 
     477  export CONFIG_SHELL=/usr/bin/bash (if installed) 
     478  export SHELL=/usr/bin/bash        (if installed) 
     479 
     480  ./configure \ 
     481     --prefix=/usr/local \ 
     482     --with-screen=slang \ 
     483     --with-slang-includes=/usr/local/include \ 
     484     --with-slang-libs=/usr/local/lib 
  • m4.include/mc-cflags.m4

    diff --git a/m4.include/mc-cflags.m4 b/m4.include/mc-cflags.m4
    index d7d4c0b..754ef21 100644
    a b dnl @copyright Free Software Foundation, Inc. 
    99 
    1010AC_DEFUN([MC_CHECK_ONE_CFLAG],[ 
    1111 
    12     AC_MSG_CHECKING([if gcc accepts $1]) 
     12  AC_MSG_CHECKING([if gcc accepts $1]) 
    1313 
    1414  safe_CFLAGS=$CFLAGS 
    1515  CFLAGS="$1" 
    AC_DEFUN([MC_CHECK_CFLAGS],[ 
    3737    mc_configured_cflags="" 
    3838 
    3939dnl Sorted -f options: 
     40dnl AC_MSG_CHECKING([CC is $CC]) 
     41case "$CC" in 
     42  gcc*) 
    4043    MC_CHECK_ONE_CFLAG([-fdiagnostics-show-option]) 
    4144dnl    MC_CHECK_ONE_CFLAG([-fno-stack-protector]) 
     45    ;; 
     46  *) 
     47    ;; 
     48esac 
    4249 
    4350dnl Sorted -W options: 
    4451    MC_CHECK_ONE_CFLAG([-Wcomment]) 
  • m4.include/mc-with-screen.m4

    diff --git a/m4.include/mc-with-screen.m4 b/m4.include/mc-with-screen.m4
    index e130975..f22f68a 100644
    a b  
    11dnl 
    22dnl Check if the system S-Lang library can be used. 
    3 dnl If not, and $1 is "strict", exit, otherwise fall back to mcslang. 
     3dnl If not, and $1 is "strict", exit. 
    44dnl 
    55AC_DEFUN([MC_CHECK_SLANG_BY_PATH], [ 
    66 
    int main (void) 
    146146            [Define to use S-Lang library for screen management]) 
    147147 
    148148        MCLIBS="$MCLIBS $ac_slang_lib_path -lslang" 
     149        CFLAGS="$saved_CFLAGS" 
     150        dnl do not reset CPPFLAGS 
     151        dnl - if CPPFLAGS are resetted then cpp does not find the specified header 
     152        LDFLAGS="$saved_LDFLAGS" 
     153    else 
     154        CFLAGS="$saved_CFLAGS" 
     155        CPPFLAGS="$saved_CPPFLAGS" 
     156        LDFLAGS="$saved_LDFLAGS" 
    149157    fi 
    150     CFLAGS="$saved_CFLAGS" 
    151     CPPFLAGS="$saved_CPPFLAGS" 
    152     LDFLAGS="$saved_LDFLAGS" 
    153158]) 
    154159 
    155160dnl 
    AC_DEFUN([MC_WITH_SLANG], [ 
    162167 
    163168    AC_ARG_WITH([slang-includes], 
    164169        AC_HELP_STRING([--with-slang-includes=@<:@DIR@:>@], 
    165             [set path to SLANG includes @<:@default=/usr/include@:>@; may sense only if --with-screen=slang] 
     170            [set path to SLANG includes @<:@default=/usr/include@:>@; make sense only if --with-screen=slang] 
    166171        ), 
    167172        [ac_slang_inc_path="$withval"], 
    168173        [ac_slang_inc_path=""] 
    AC_DEFUN([MC_WITH_SLANG], [ 
    170175 
    171176    AC_ARG_WITH([slang-libs], 
    172177        AC_HELP_STRING([--with-slang-libs=@<:@DIR@:>@], 
    173             [set path to SLANG library @<:@default=/usr/lib@:>@; may sense only if --with-screen=slang] 
     178            [set path to SLANG library @<:@default=/usr/lib@:>@; make sense only if --with-screen=slang] 
    174179        ), 
    175180        [ac_slang_lib_path="$withval"], 
    176181        [ac_slang_lib_path=""] 
    AC_DEFUN([MC_WITH_SLANG], [ 
    197202 
    198203]) 
    199204 
     205dnl check for ncurses in user supplied path 
     206AC_DEFUN([MC_CHECK_NCURSES_BY_PATH], [ 
     207 
     208    ac_ncurses_inc_path=[$1] 
     209    ac_ncurses_lib_path=[$2] 
     210 
     211    if test x"$ac_ncurses_inc_path" != x; then 
     212        ac_ncurses_inc_path="-I"$ac_ncurses_inc_path 
     213    fi 
     214 
     215    if test x"$ac_ncurses_lib_path" != x; then 
     216        ac_ncurses_lib_path="-L"$ac_ncurses_lib_path 
     217    fi 
     218 
     219    saved_CPPFLAGS="$CPPFLAGS" 
     220    CPPFLAGS="$CPPFLAGS $ac_ncurses_inc_path" 
     221 
     222    dnl Check for the headers 
     223    dnl Both headers should be in the same directory 
     224    dnl AIX term.h is unusable for mc 
     225    AC_MSG_CHECKING([for ncurses/ncurses.h and ncurses/term.h]) 
     226    AC_PREPROC_IFELSE( 
     227        [ 
     228            AC_LANG_PROGRAM([[#include <ncurses/ncurses.h> 
     229                              #include <ncurses/term.h> 
     230                            ]],[[return 0;]]) 
     231        ], 
     232        [ 
     233            AC_MSG_RESULT(yes) 
     234            if test x"$ac_ncurses_inc_path" = x; then 
     235                ac_ncurses_inc_path="-I/usr/include" 
     236            fi 
     237            if test x"$ac_ncurses_lib_path" = x; then 
     238              ac_ncurses_lib_path="-L/usr/lib" 
     239            fi 
     240            found_ncurses=yes 
     241            AC_DEFINE(HAVE_NCURSES_NCURSES_H, 1, 
     242                      [Define to 1 if you have the <ncurses/ncurses.h> header file.]) 
     243            AC_DEFINE(HAVE_NCURSES_TERM_H, 1, 
     244                      [Define to 1 if you have the <ncurses/term.h> header file.]) 
     245        ], 
     246        [ 
     247            AC_MSG_RESULT(no) 
     248            found_ncurses=no 
     249            error_msg_ncurses="ncurses header not found" 
     250        ], 
     251    ) 
     252 
     253    if test x"$found_ncurses" = x"yes"; then 
     254        screen_type=ncurses 
     255        screen_msg="ncurses library (installed on the system)" 
     256 
     257        AC_DEFINE(HAVE_NCURSES, 1, 
     258                  [Define to use ncurses library for screen management]) 
     259 
     260        MCLIBS="$MCLIBS $ac_ncurses_lib_path" 
     261    else 
     262        CPPFLAGS="$saved_CPPFLAGS" 
     263        AC_MSG_ERROR([$error_msg_ncurses]) 
     264    fi 
     265]) 
     266 
    200267dnl 
    201268dnl Use the ncurses library.  It can only be requested explicitly, 
    202269dnl so just fail if anything goes wrong. 
    AC_DEFUN([MC_WITH_NCURSES], [ 
    208275    dnl has_colors() is specific to ncurses, it's not in the old curses 
    209276    save_LIBS="$LIBS" 
    210277    ncursesw_found= 
    211     LIBS= 
    212     AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes], 
    213                    [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])]) 
    214278 
    215     if test x"$ncursesw_found" = "x"; then 
    216     LIBS= 
    217     AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"], 
    218                    [AC_MSG_ERROR([Cannot find ncurses library])]) 
    219     fi 
     279    dnl get the user supplied include path 
     280    AC_ARG_WITH([ncurses-includes], 
     281        AC_HELP_STRING([--with-ncurses-includes=@<:@DIR@:>@], 
     282            [set path to ncurses includes @<:@default=/usr/include@:>@; make sense only if --with-screen=ncurses; for /usr/local/include/ncurses specify /usr/local/include] 
     283        ), 
     284        [ac_ncurses_inc_path="$withval"], 
     285        [ac_ncurses_inc_path=""] 
     286    ) 
    220287 
    221     dnl Check the header 
    222     ncurses_h_found= 
    223     AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h], 
    224                      [ncurses_h_found=yes; break]) 
     288    dnl get the user supplied lib path 
     289    AC_ARG_WITH([ncurses-libs], 
     290        AC_HELP_STRING([--with-ncurses-libs=@<:@DIR@:>@], 
     291            [set path to ncurses library @<:@default=/usr/lib@:>@; make sense only if --with-screen=ncurses] 
     292        ), 
     293        [ac_ncurses_lib_path="$withval"], 
     294        [ac_ncurses_lib_path=""] 
     295    ) 
    225296 
    226     if test x"$ncurses_h_found" = "x"; then 
    227         AC_MSG_ERROR([Cannot find ncurses header file]) 
    228     fi 
     297    dnl we need at least the inc path, the lib may be in a std location 
     298    if test x"$ac_ncurses_inc_path" != x; then 
     299        dnl check the user supplied location 
     300        MC_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path]) 
     301 
     302        LIBS= 
     303        AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"],  
     304                       [AC_MSG_ERROR([Cannot find ncurses library])]) 
     305 
     306        screen_type=ncurses 
     307        screen_msg="ncurses library" 
     308        AC_DEFINE(USE_NCURSES, 1,  
     309                  [Define to use ncurses for screen management]) 
     310    else 
     311        LIBS= 
     312        AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes], 
     313                       [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])]) 
     314 
     315        if test x"$ncursesw_found" = "x"; then 
     316            LIBS= 
     317            AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],  
     318                           [AC_MSG_ERROR([Cannot find ncurses library])]) 
     319        fi 
    229320 
    230     screen_type=ncurses 
    231     screen_msg="ncurses library" 
    232     AC_DEFINE(USE_NCURSES, 1, 
    233               [Define to use ncurses for screen management]) 
     321        dnl Check the header 
     322        ncurses_h_found= 
     323        AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],  
     324                         [ncurses_h_found=yes; break]) 
    234325 
     326        if test x"$ncurses_h_found" = "x"; then 
     327            AC_MSG_ERROR([Cannot find ncurses header file]) 
     328        fi 
     329 
     330        screen_type=ncurses 
     331        screen_msg="ncurses library" 
     332        AC_DEFINE(USE_NCURSES, 1,  
     333                  [Define to use ncurses for screen management]) 
     334    fi 
     335 
     336    dnl check for ESCDELAY 
    235337    AC_CACHE_CHECK([for ESCDELAY variable], 
    236                    [mc_cv_ncurses_escdelay], 
    237                    [AC_TRY_LINK([], [ 
    238                         extern int ESCDELAY; 
    239                         ESCDELAY = 0; 
    240                         ], 
    241                         [mc_cv_ncurses_escdelay=yes], 
    242                         [mc_cv_ncurses_escdelay=no]) 
     338                   [mc_cv_ncurses_escdelay], 
     339                   [AC_TRY_LINK([], [ 
     340                        extern int ESCDELAY; 
     341                        ESCDELAY = 0; 
     342                        ], 
     343                        [mc_cv_ncurses_escdelay=yes], 
     344                        [mc_cv_ncurses_escdelay=no]) 
    243345    ]) 
    244346    if test x"$mc_cv_ncurses_escdelay" = xyes; then 
    245         AC_DEFINE(HAVE_ESCDELAY, 1, 
    246                   [Define if ncurses has ESCDELAY variable]) 
     347        AC_DEFINE(HAVE_ESCDELAY, 1,  
     348                  [Define if ncurses has ESCDELAY variable]) 
    247349    fi 
    248350 
     351    dnl check for resizeterm 
    249352    AC_CHECK_FUNCS(resizeterm) 
    250353    LIBS="$save_LIBS" 
    251354]) 
  • src/tty/tty-ncurses.c

    diff --git a/src/tty/tty-ncurses.c b/src/tty/tty-ncurses.c
    index 76b0f5f..810bdc4 100644
    a b  
    5252 
    5353/* include at last !!! */ 
    5454#ifdef WANT_TERM_H 
     55#ifdef HAVE_NCURSES_TERM_H 
     56#   include <ncurses/term.h> 
     57#else 
    5558#   include <term.h> 
     59#endif /* HAVE_NCURSES_TERM_H */ 
    5660#endif /* WANT_TERM_H */ 
    5761 
    5862/*** global variables **************************************************/ 
    5963 
    6064/*** file scope macro definitions **************************************/ 
     65#if defined(_AIX) && !defined(CTRL) 
     66#   define CTRL(x) ((x) & 0x1f) 
     67#endif 
    6168 
    6269/*** global variables **************************************************/ 
    6370 
  • src/tty/tty-ncurses.h

    diff --git a/src/tty/tty-ncurses.h b/src/tty/tty-ncurses.h
    index 6363a69..c45141a 100644
    a b  
    55#ifdef USE_NCURSES 
    66#    ifdef HAVE_NCURSES_CURSES_H 
    77#        include <ncurses/curses.h> 
     8#    elif HAVE_NCURSES_NCURSES_H 
     9#        include <ncurses/ncurses.h> 
    810#    elif HAVE_NCURSESW_CURSES_H 
    911#        include <ncursesw/curses.h> 
     12#    elif HAVE_NCURSES_HCURSES_H 
     13#        include <ncurses.h> 
    1014#    elif HAVE_NCURSES_H 
    1115#        include <ncurses.h> 
    1216#    else 
  • src/unixcompat.h

    diff --git a/src/unixcompat.h b/src/unixcompat.h
    index e71332f..9ad6e31 100644
    a b  
    2020# include <sys/sysmacros.h>     /* AIX */ 
    2121#endif 
    2222 
     23#if defined(_AIX) 
     24# include <time.h>              /* AIX for tm */ 
     25#endif 
     26 
    2327#ifndef major 
    2428# warning major() is undefined. Device numbers will not be shown correctly. 
    2529# define major(devnum) (((devnum) >> 8) & 0xff) 
  • vfs/direntry.c

    diff --git a/vfs/direntry.c b/vfs/direntry.c
    index 9a41aa9..bcd4ccd 100644
    a b  
    3131#include <config.h> 
    3232 
    3333#include <errno.h> 
    34 #include <sys/fcntl.h> 
     34#include <fcntl.h>              /* include fcntl.h -> sys/fcntl.h only       */ 
     35                                /* includes fcntl.h see IEEE Std 1003.1-2008 */ 
    3536#include <time.h> 
    3637#include <sys/time.h>           /* gettimeofday() */ 
    3738 
  • vfs/vfs.c

    diff --git a/vfs/vfs.c b/vfs/vfs.c
    index 6ca2c75..d16f45b 100644
    a b  
    6767#include "smbfs.h" 
    6868#include "local.h" 
    6969 
     70#if defined(_AIX) && !defined(NAME_MAX) 
     71#  define NAME_MAX FILENAME_MAX 
     72#endif 
     73 
    7074/** They keep track of the current directory */ 
    7175static struct vfs_class *current_vfs; 
    7276static char *current_dir;