Name Date Size

..29-Nov-20194 KiB

.gitignoreH A D29-Aug-2017228

COPYINGH A D29-Aug-20172.9 KiB

genpcH A D29-Aug-2017101

GNUmakefileH A D20-Sep-201718.2 KiB

infocmp/H20-Sep-20174 KiB

install.shH A D29-Aug-2017924

libcurses/H02-Apr-201916 KiB

libform/H02-Mar-20194 KiB

libmenu/H02-Mar-20194 KiB

libpanel/H29-Aug-20174 KiB

libterminfo/H02-Mar-20194 KiB

nbperf/H29-Aug-20174 KiB

netbsd_sys/H17-Apr-20194 KiB

README.mdH A D04-Nov-20189.2 KiB

tabs/H02-Mar-20194 KiB

terminfo/H13-Nov-20174 KiB

tic/H12-Oct-20184 KiB

tput/H29-Aug-20174 KiB

tset/H20-Sep-20174 KiB

README.md

1netbsd-libcurses portable edition
2=================================
3
4this is a port of netbsd's curses library for usage on Linux systems
5(tested and developed on sabotage linux, based on musl libc).
6It should be possible to use on other POSIX platforms as well with minor
7changes.
8
9it supports widechar (like the ncursesw build variant) and is close to being
10a 100% feature-complete drop-in replacement for ncurses.
11
12to this date, there are only 3 implementations of the curses API:
13
14- the ubiquitous ncurses library, which is used on almost every UNIX system
15  (Linux, Mac OS X, FreeBSD, OpenBSD and others).
16- netbsd curses, previously used on netbsd only.
17- pdcurses, targetting the windows terminal, SDL and X11 (unusable on UNIX
18  terminals).
19
20Why do we need an ncurses replacement ?
21---------------------------------------
22- Competition is good.
23- Ncurses is one of the most used libraries in the linux ecosystem and
24  therefore it's usually one of the first libraries built in a source-based
25  distro.
26  There's basically no way around it, unless you're building a single-purpose
27  appliance.
28- Readability/Hacking.
29  even though ncurses is free software, it is very hard to change its source
30  code:
31  - extremely complicated build process with several layers of preprocessing
32    using tools like awk, sed and the output of the C preprocessor with reliance
33    on implementation details, [as shown by the recent breakage when distros
34    updated to GCC 5][0].
35  - heavy use of macros, making the code hard to read.
36  - very much code (bloat).
37- Usability.
38  the default configuration of ncurses is usually not what one wants, and it
39  features several dozens of configure options to customize the build,
40  for example making it split up in several smaller libraries, with or without
41  widechar support, etc.
42
43  this makes it hard to guess which files to link against and which headers to
44  use when building a package against ncurses.
45  `-lncurses`? `-lncursesw -lterminfo -ltic`? `curses.h`? `ncurses/ncursesw.h`?
46  this filename chaos [is often fixed in a distro-specific manner][1].
47
48  to accomodate for this, ncurses ships its own config tool ncurses(w)5-config
49  instead of a standardized pkg-config description file (disabled by default)
50  to query the necessary CFLAGS and LDFLAGS.
51  unfortunately like every other homebrewed pkg-config replacement, this config
52  utility was designed without cross-compilation in mind, so many packages
53  using ncurses and autoconf fail to cross-compile when unpatched.
54- Size and build time.
55
56Table 1: Comparison between ncurses and netbsd curses
57-----------------------------------------------------
58|                             | NCURSES      | NETBSD CURSES |
59|:----------------------------|:------------:|:-------------:|
60| Size of extracted source    | 15.8 MB      | 3.3 MB        |
61| Installed size              | 15.9 MB      | 1.3 MB        |
62| Installed size w/debuginfo  | 128.3 MB     | 19.9 MB       |
63| Build time (make -j2)       | 59 sec       | 9 sec         |
64| size of libncursesw.so      | 346 KB       | 150 KB        |
65| size of static linked nano  | 334 KB       | 288 KB        |
66
67  
68  when scaling up to more build jobs, it is expected that netbsd curses fares a
69  lot better since its Makefile is fully parallelizable, while ncurses spends a
70  lot of time in a single process executing the configure script.
71
72Differences from ncurses
73------------------------
74- the structures used differ. some programs access ncurses structure members directly,
75  they must be patched to use a portable approach.
76- mouse handling is lacking. ncurses mouse handling routines are provided as no-op
77  macros, so software using it builds without having to patch it.
78- some rarely used functions like vidputs() are missing. users must be patched.
79- the terminfo database is compiled (via tic) into a binary database in CDB format.
80- "only" 510 color pairs are supported.
81- some functionality like tgetent() lives in libterminfo rather than in libcurses.
82  it may be necessary to add -lterminfo to LDFLAGS for packages using those functions.
83
84TODO
85----
86- installation of global terminfo db
87  (rather than just a small built-in, handpicked set)
88
89Compilation
90-----------
91netbsd-curses ships without a configure script, and requires GNU make.
92variables for compilation can be passed directly to make, or be saved into config.mak.
93recognized variables are:
94
95- CC - the C compiler
96- HOSTCC - the C compiler used for host programs when crosscompiling.
97  if set, and different from CC, cross-compilation is assumed.
98- CFLAGS - flags for the compiler
99- CPPFLAGS - flags for the preprocessor
100- LDFLAGS - flags for the linker
101- PREFIX - filesystem prefix used for hardcoded paths and installation
102- DESTDIR - staging directory for installation
103
104examples:
105
106    make CFLAGS="-Os -Wall -fPIC" PREFIX=/usr/local -j4 all install
107    make CFLAGS=-O2 LDFLAGS=-static PREFIX=/usr all-static install-static
108
109example config.mak:
110
111    CFLAGS = -O3 -Wall
112    PREFIX = /usr
113    DESTDIR = foo
114
115if you're using config.mak, you can just run `make && make install` and the
116variables will be picked up automatically.
117
118the `all` and `install` Makefile targets will build/install all programs,
119shared and static libs, and headers.
120the `all-static` and `install-static` targets will build/install all programs,
121static libs, and headers.
122the `all-dynamic` and `install-dynamic` targets will build/install all programs
123shared libs, and headers.
124
125the `all` build can be sped up by putting `-fPIC` in CFLAGS.
126this has the effect that the same object files will be used for the dynamic and
127static libs; otherwise they will be compiled twice with different CFLAGS.
128
129Compiled-in terminal database
130-----------------------------
131support for about a dozen common TERMs is built-in already. if you need one
132that's not included, you can either add yours to `libterminfo/genterms` or
133`make terminfo/terminfo.cdb` and install the result to either
134`$PREFIX/share/terminfo.cdb` or `$HOME/.terminfo.cdb`.
135
136Compiling software against netbsd-curses
137----------------------------------------
138the functionality that ncurses offers is usually (if not configured to split
139into several separate libs) available in a single `libncurses` library.
140netbsd-curses on the other hand has it always split into `libcurses` and
141`libterminfo`.
142this difference requires to give the build system a hint that it needs to
143link to both libcurses and libterminfo.
144
145- programs using pkg-config(1) automatically get the right options
146  due to the supplied .pc files.
147
148- for autoconf based software (using a configure script) it is usually
149  sufficient to invoke configure like this:
150
151    LIBS="-lcurses -lterminfo" ./configure ...
152
153- for Makefile-only based build systems, it should be sufficient to add
154  the libs to LDFLAGS:
155
156    make LDFLAGS="-lcurses -lterminfo" ...
157
158with these instructions it is easy to compile the majority of ncurses apps
159without problems against netbsd-curses.
160
161a small percentage of apps written for ncurses poke at internals and need
162light patching:
163
164- [patch for midnight commander][2] - merged upstream as rev 38d4c655d
165- [patch for python 2.7.x and 3.6][3]
166
167if you have trouble compiling a specific package, first look at the
168[sabotage linux build recipes][4].
169if you still can't get the package to compile, feel free to open an issue
170[at the netbsd-curses issue tracker][5].
171
172License
173-------
174libcurses, tset and tput are (C) 1980-1994
175"The Regents of the University of California" licensed under the 3-clause BSD
176license.
177Everything else is (C) 1999-2016 The NetBSD Foundation, Inc. and Contributors,
178licensed under the 2-clause BSD license.
179see COPYING for the full text, and in doubt, consult the copyright clauses in
180the respective .c files. Files without copyright clauses in the file header
181are explicitly released under the terms of the 2-clause BSD license as well.
182
183
184APPENDIX A: Test Setup used for comparison in Table 1
185-----------------------------------------------------
186All tests were done on a dual core x86_64 sabotage linux system, with the following
187features:
188installation of shared and static libs, headers, etc,
189i.e. make -j2 all install.
190ncurses and netbsd curses were both configured with support for widechars, and
191built-in terminfo database for a handful of terminals.
192
193    CFLAGS (optimized for size):
194    -g0 -fdata-sections -ffunction-sections -Os -fno-unwind-tables
195    -fno-asynchronous-unwind-tables -Wa,--noexecstack
196
197    LDFLAGS:
198    -s -Wl,--gc-sections -Wl,-z,relro,-z,now
199
200netbsd curses was installed without manpages (ncurses: 1.1 MB) and terminfo
201database (ncurses: 6.4MB).
202the debug info build was created with -g3 and debuginfo stripped into external
203files via objcopy.
204
205APPENDIX B: History of NetBSD curses
206------------------------------------
207
208Thomas Dickey did a [thorough investigation][6] on the history of NetBSD curses.
209
210
211[0]:http://trac.sagemath.org/ticket/18301
212[1]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/scripts/kconfig/lxdialog/check-lxdialog.sh
213[2]:https://github.com/MidnightCommander/mc/commit/38d4c655d322837574e957b4a824f4a0d1bb3b86
214[3]:https://github.com/sabotage-linux/sabotage/blob/06a4a815/KEEP/python2710-curses.patch
215[4]:https://github.com/sabotage-linux/sabotage/tree/master/pkg
216[5]:https://github.com/sabotage-linux/netbsd-curses/issues
217[6]:http://invisible-island.net/ncurses/ncurses-netbsd.html
218
219