NCurses 1.9.9e for EMX

Table of contents

Introduction

NCurses is a set of libraries that some programs use to handle terminals that is the screen plus the keyboard (and in a short future the mouse too)- It's well known by the Linux community and I hope it'll be useful for people willing to port programs form Unix to EMX.

What I've done is mainly guessing good parameters for compilation, editing config.h, building a set of makefiles, fixing and important error in hardscroll.c and adding a few of `O_BINARY/O_TEXT'. The result is a set of changed files put together under the name `nc_emx_p.zip', and the compiled sources archived under `nc_emx_b.zip'.

Installing

I've built a minimal distribution that any one can use to build their own programs. I call it binary distribution and it's name, at my site, is NC-EMX-B.ZIP. Currently it contains, under the directory NCurses-1.9.9e
dll/*.dll Dynamic link libraries needed to run programs. Put them in a directory that appeas in LIBPATH
lib/*.lib Import libraries in OMF format. Link your programs with these libraries if you want those programs to use the DLLs
lib/*.a Static libraries in a.out format. Link your programs with them if you don't want the DLLs or need DOS-compatible programs.
include/*.h NCurses, Panel, Menu and Form headers. Compatibility headers (`termcap.h) as well.
bin/*.exe Utilities that compile, convert and dump terminfo databases, among other tasks.
lib/.terminfo/[0-1A-Z] The compiled terminfo descriptions
lib/.terminfo/emx.src A sample set of terminfo description, enough for most systems.
lib/.terminfo/cleantic.cmd A script to `pack' terminfo databases, and clean empty directories

To install the binary distribution, find an empty directory, and unpack it there. Next, move the files to their appropiate places and finally set some required environment variables. Read the following sections for details about where .terminfo should go and important environment variables.

Man pages are in a third archive named NC-EMX-D.ZIP. They're groff sources, so you'll need this program (or a smaller one called `awf') to view them.

Terminal descriptions

The NCurses library needs to know how to handle your keyboard, as well as your terminal screen. This knowledge is gained (at least theoretically) by any of this three ways:

The first one, termcap fallback, means reading and parsing of a `termcap.dat' file when no terminfo database is available. It's currently disabled because, at this stage of development this feature seems to be too error prone. I hope I'll find a fix, as well as I did with some other bugs, but this is just a hope.

The second one, normal fallback, or using built in terminal descriptions, should be possible, but has shown some undesirable effects and, until it proves to be stable, this feature will be disabled in the EMX version.

So, finally, you must have a set of compiled terminfo descriptions. These are binary files, which contain the codes for most important keys, as well as some set of commands that clean the screen, change the text attributes, and so on.

There are two possible places where NCurses will find a compiled terminfo database:

Note: watch out! There's a dot in the name .terminfo.

The second way is, in my opinion, the least painful one: you only need to set the HOME environment variable with a path to an existing directory and move `.terminfo' there. And HOME is already used by many other GNU programs and libraries!

The terminfo database is a set of files collected in a peculiar directory tree. To simplify things a bit, I've put an EMX compatible database in NCurses's binary distribution. Let's say you've unpacked the NC-EMX-B.ZIP archive in the c:\tmp directory. Then you should

The precompiled database is the result of running `emx.src' through the program `tic.exe'. `emx.src' is a sample file that lists a set of terminal descriptions including those from EMX's termcap.dat (and some X-terminal descriptions). It adds capabilities to handle function keys, cursor keys, colors, etc, as DOS and OS/2 handle them. There's a copy of `emx.src' in `NCurses-1.9.9e/lib/terminfo'.

Maybe one day you'll need to recompile the database. The steps needed to recompile `emx.src' are, in a simplified way:

Note: cleantic.cmd is a simple batch file that removes empty directories from the .terminfo structure.

Environment variables

To sum a bit up, remember that the only variables NCurses cares for are:

These variables should be set in CONFIG.SYS, so that all programs have access to them.

Note: probably, you already have TERM set on your system. You may leave it like that as most of the terminal description that EMX's termcap supported are included in NCurses, too.

Requisites for building

Note: make sure the awk program has the name gawk.exe. If not, edit Makefile.inc to suit your system. And if you still have problems, make a copy of that program with the name gawk.exe.

Steps for building

Let's say you've unpacked the original GNU NCurses distribution and now you have a directory named e:\ncurses-1.9.9e...

Installing after building

The makefiles have been designed to install important files under one we'll name $(prefix) in the following unix-like directory scheme (in MAKE's notation):
MAKE's variable default value comments
bindir $(prefix)/bin where programs are installed
dlldir $(prefix)/dll shared dynamic link libraries
libdir $(prefix)/lib static link libraries
mandir $(prefix)/man manuals

To get things installed this way, edit `misc\Makefile.inc' setting an appropiate value for prefix, and then run

make install
from the ncurses base directory (e:\ncurses-1.9.9e in our example).

However, you might choose to install the files manually, which is less risky at this stage of testing. To do so, first build the libraries and the programs (with make all). Next choose a place for programs, libraries and headers. The files you have to install are
./progs/tic.exeimportant utility for terminfo compiling
./misc/emx.srcthe source for the terminfo database
./lib/*.dllthe dynamic link libraries.

These are only needed when compiling programs that use NCurses:
./lib/*.astatic libraries
./lib/*.libimport libraries for programs that use the DLLs
./include/curses.h
./include/unctrl.h
./include/menu.h
./include/eti.h
./include/form.h
./include/panel.h
./include/termcap.h
important header files for C code

Note: I recommend you not installing the headers and libraries in EMX's directories, but using other places and adding them to C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, LIBRARY_PATH as explained in the EMX documentation.

See Terminal descriptions above for important instructions about terminfo compiling.

Using the DLL in programs

In this release, NCurses's DLLs (those with the names ending in 2.dll) have been compiled and linked with the flags


-Zomf -Zdll -Zcrtdll -Zmt -D__ST_MT_ERRNO__

As you probably guessed, they may be used by multithreaded programs and use EMXLIBCM.DLL. So, programs you build and link with NCURSES.LIB, FORMS.LIB, PANELS.LIB or MENU.LIB, must be linked and compiled with the -Zmtd or -Zmt -Zcrtdll flags.

For more information on linking, dynamic link libraries and multithreading, read the EMX documentation.

Note: some time ago I distributed a set of libraries (ncurses.dll, panel.dll, etc) which were compiled without these. They're OK and you may keep them in your system -- in case some program needs them.

To-do

Getting it

Currently this release is thought to be at beta stage and is only available at my site, but if enough people find it stable and useful I might try to upload it to Hobbes and Leo, two excellent sites for OS/2 software.

BTW, this place has only space for 2Mbytes and, as now I seem to have some spare time I'm planning to do BIG things, I might remove the binary and manual distributions and leave only the patches. However, this shouldn't happen in a month or so (And by that time I will have uploaded it to Hobbes)

So that's all, folks.