sup

A curses threads-with-tags style email client

ncursesw-ruby.git

git clone https://supmua.dev/git/ncursesw-ruby/

extconf.rb (5109B) - raw

      1 #!/usr/bin/env ruby
      2 
      3 # ncurses-ruby is a ruby module for accessing the FSF's ncurses library
      4 # (C) 2002, 2004 Tobias Peters <t-peters@users.berlios.de>
      5 # (C) 2005, 2009, 2011 Tobias Herzke
      6 # (C) 2013 Gaute Hope <eg@gaute.vetsj.com>
      7 #
      8 # This module is free software; you can redistribute it and/or
      9 # modify it under the terms of the GNU Lesser General Public
     10 # License as published by the Free Software Foundation; either
     11 # version 2 of the License, or (at your option) any later version.
     12 #
     13 # This module is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     16 # Lesser General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU Lesser General Public
     19 # License along with this module; if not, write to the Free Software
     20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
     21 
     22 # $Id: extconf_ncursesw.rb,v 1.1 2011-05-30 23:05:50 t-peters Exp $
     23 
     24 require "mkmf"
     25 
     26 $CFLAGS  += " -g -Wformat -Werror=format-security -Waddress"
     27 
     28 if find_executable('pkg-config')
     29   $CFLAGS  += ' ' + `pkg-config --cflags ncursesw`.strip
     30   $LDFLAGS += ' ' + `pkg-config --libs ncursesw`.strip
     31 end
     32 
     33 dir_config("ncurses")
     34 
     35 have_header("unistd.h")
     36 have_header("locale.h")
     37 
     38 if have_header ("ncursesw/curses.h") # ubuntu 13
     39   curses_header = "ncursesw/curses.h"
     40 elsif have_header("ncurses.h")
     41   curses_header = "ncurses.h"
     42 elsif have_header("ncurses/curses.h")
     43   curses_header = "ncurses/curses.h"
     44 elsif have_header("curses.h")
     45   curses_header = "curses.h"
     46 else
     47   raise "ncurses header file not found"
     48 end
     49 
     50 if have_library("ncursesw", "wmove")
     51   curses_lib = "ncursesw"
     52 elsif have_library("ncurses", "add_wch")
     53   curses_lib = "ncurses"
     54   curses_is_wide = true
     55 elsif have_library("pdcurses", "wmove")
     56   curses_lib = "pdcurses"
     57 else
     58   raise "ncurses library not found"
     59 end
     60 
     61 have_func("newscr")
     62 have_func("TABSIZE")
     63 have_func("ESCDELAY")
     64 have_func("keybound")
     65 have_func("curses_version")
     66 have_func("tigetstr")
     67 have_func("getwin")
     68 have_func("putwin")
     69 have_func("ungetmouse")
     70 have_func("mousemask")
     71 have_func("wenclose")
     72 have_func("mouseinterval")
     73 have_func("wmouse_trafo")
     74 have_func("mcprint")
     75 have_func("has_key")
     76 
     77 have_func("delscreen")
     78 have_func("define_key")
     79 have_func("keyok")
     80 have_func("resizeterm")
     81 have_func("use_default_colors")
     82 have_func("use_extended_names")
     83 have_func("wresize")
     84 have_func("attr_on")
     85 have_func("attr_off")
     86 have_func("attr_set")
     87 have_func("chgat")
     88 have_func("color_set")
     89 have_func("filter")
     90 have_func("intrflush")
     91 have_func("mvchgat")
     92 have_func("mvhline")
     93 have_func("mvvline")
     94 have_func("mvwchgat")
     95 have_func("mvwhline")
     96 have_func("mvwvline")
     97 have_func("noqiflush")
     98 have_func("putp")
     99 have_func("qiflush")
    100 have_func("scr_dump")
    101 have_func("scr_init")
    102 have_func("scr_restore")
    103 have_func("scr_set")
    104 have_func("slk_attr_off")
    105 have_func("slk_attr_on")
    106 have_func("slk_attr")
    107 have_func("slk_attr_set")
    108 have_func("slk_color")
    109 have_func("tigetflag")
    110 have_func("tigetnum")
    111 have_func("use_env")
    112 have_func("vidattr")
    113 have_func("vid_attr")
    114 have_func("wattr_on")
    115 have_func("wattr_off")
    116 have_func("wattr_set")
    117 have_func("wchgat")
    118 have_func("wcolor_set")
    119 have_func("getattrs")
    120 
    121 puts "checking for ncursesw (wide char) functions..."
    122 if not (have_func("wget_wch") and
    123         have_func("add_wch") and
    124         have_func("get_wch"))
    125   raise "no wget_wch, add_wch and/or get_wch found."
    126 end
    127 
    128 
    129 puts "checking which debugging functions to wrap..."
    130 have_func("_tracef")
    131 have_func("_tracedump")
    132 have_func("_nc_tracebits")
    133 have_func("_traceattr")
    134 have_func("_traceattr2")
    135 have_func("_tracechar")
    136 have_func("_tracechtype")
    137 have_func("_tracechtype2")
    138 have_func("_tracemouse")
    139 
    140 puts "checking for other functions that appeared after ncurses version 5.0..."
    141 have_func("assume_default_colors")
    142 have_func("attr_get")
    143 
    144 puts "checking for the panel library..."
    145 if have_header("panel.h") or have_header("ncursesw/panel.h")
    146   have_library("panelw", "panel_hidden")
    147 else
    148   raise "panel library not found"
    149 end
    150 
    151 puts "checking for the form library..."
    152 if have_header("form.h") or have_header("ncursesw/form.h")
    153   if not have_library("formw", "new_form") ||
    154       (curses_is_wide && have_library("form", "new_form"))
    155     raise "formw library not found"
    156   end
    157 else
    158   raise "form library not found."
    159 end
    160 
    161 if have_library("formw", "form_driver_w")
    162   $CFLAGS += " -DHAVE_FORM_DRIVER_W"
    163 end
    164 
    165 puts "checking for the menu library..."
    166 if have_header("menu.h") or have_header("ncursesw/menu.h")
    167   have_library("menu", "new_menu")
    168 else
    169   raise "menu library not found."
    170 end
    171 
    172 puts "checking for various ruby and standard functions.."
    173 if have_func("rb_thread_fd_select")
    174   $CFLAGS  += " -DHAVE_RB_THREAD_FD_SELECT"
    175 end
    176 
    177 if have_func("clock_gettime")
    178   $CFLAGS += " -DHAVE_CLOCK_GETTIME"
    179 end
    180 
    181 # check if we have sys/time.h, should increase portability
    182 # https://github.com/sup-heliotrope/ncursesw-ruby/issues/25
    183 # http://stackoverflow.com/questions/7889678/how-can-adding-a-header-increase-portability-sys-time-h
    184 have_header("sys/time.h")
    185 
    186 $CXXFLAGS  = $CFLAGS
    187 
    188 create_makefile('ncursesw_bin')