This file explains how to compile wcd for DOS, Windows, and OS/2
with GNU C compiler (GCC, DJGPP/MinGW/EMX).

For Unix/Linux/Cygwin compile instructions see file UNIX.txt

For how to install the program on DOS, Windows, OS/2 see file INST_DOS.txt.


Prerequisites
=============

* gcc       : GNU C compiler
* make      : GNU make
* sh        : POSIX type shell
* coreutils : GNU core utilities package

Optional:

* perl         : Practical Extraction and Report Language (perlpod)
* gettext      : Framework to help GNU packages produce multi-lingual messages.
* libiconv     : Character set conversion library.
* pdcurses     : CRT screen handling and optimization package
* ncurses      : A free software emulation of curses in System V Release 4.0 (SVr4), and more.
* libunistring : Library with functions for manipulating Unicode strings.


If you want to generate PostScript or PDF versions of the manual:

* groff       : GNU troff text formatting system.
* ghostscript : An interpreter for the PostScript language and for PDF (ps2pdf)

Needed for building packages:

* zip         : compressor-archiver


gcc
===

DOS     : DJGPP     : http://www.delorie.com/djgpp/
Windows : MinGW     : http://www.mingw.org/
Windows : MinGW-w64 : https://mingw-w64.org/
Windows : MSYS2     : http://www.msys2.org/
OS/2    : EMX       : http://www.edm2.com/index.php/The_EMX_Project

DJGPP 2.03 gcc >= 4.6 seems to cause problems. Crashes of gcc itself, or crashing
wcd binaries. Use DJGPP 2.03 gcc <= 4.5.3.
DJGPP 2.05 gcc seems to work OK (I tried gcc 5.3.0).

Wcd compiles with mingw.org and mingw-w64. I recommend using mingw-w64 in the MSYS2 project.

The MSYS2 project includes the MinGW-w64 compiler <https://mingw-w64.org/>
for both 32 and 64 bit. Plus it includes a complete building environment. A
POSIX shell, and many libraries and utilities.
See also http://www.msys2.org/

On OS/2 don't add gcc flag -Zargs-wild, because we want wcd to see the literal
arguments.  Wild argument expansion may lead to unexpected behaviour when an
argument matches a file in the current directory.

sh
==

A POSIX type shell. A copy of Bash or Zsh will do.

GNU make may not work as expected if you don't have a proper shell installed.
You can choose a shell for GNU Make by setting the environment variable SHELL.
See also the GNU make manual:

http://www.gnu.org/software/make/manual/make.html#Choosing-the-Shell

DJGPP     : Includes bash
MinGW-w64 : Use MSYS2

In DJGPP it is certain that you get problems if you don't make the SHELL
variable point to bash (c:/djgpp/bin/bash.exe).


make, coreutils
===============

make and coreutils can be found as packages on the web site of the gcc compiler.

Coreutiles is needed for `chmod', `install', `mkdir', `mv', `rm', and `uname'.
install   : copy files and set their attributes (part of GNU `coreutils' package).

For DJGPP compiler use package `fileutils' instead of `coreutils'. Coreutils is
not (yet) available for DJGPP.


perl
====

Perl packages are distributed with the DJGPP, MinGW, MSYS2, and EMX environment.


gettext (libintl) and libiconv
==============================

gettext and libiconv can be found as packages on the web site of the gcc compiler.

Until wcd version 5.1.1 I used GnuWin32's gettext/libiconv instead of MinGW's,
because the GnuWin32 port of libintl (part of gettext) has builtin relocation
support. From wcd version 5.1.2 I use MinGW's gettext/libiconv. Wcd win32
binaries are packed with a patched version of MinGW's libintl-8.dll that also
supports relocation. See also http://waterlan.home.xs4all.nl/libintl.html and
http://sourceforge.net/p/mingw/bugs/1808/

The patch was not accepted by MinGW.org, but the MSYS2 project has included
the patch for both 32 and 64 bit.


groff and ghostscript
=====================

These packages are needed if you want to create PostScript and PDF versions of
the wcd manual page.

Groff and ghostscript are available in the Cygwin environment (http://cygwin.com).


Problems on Windows VISTA and higher
====================================

DOS programs can only run on 32 bit versions of Windows,
not on 64 bit Windows versions.

Permissions
-----------

    To be able to run `gmake install' you may need adminstrator rights. You
    can get a Command Prompt with administrator rights if you right click on
    the Command Prompt icon and select `run as administrator'.

DJGPP Out of memory
-------------------

    Since Windows Vista SP1 DOS programs are by default limited by Windows to
    use a maximum amount of 32 MB memory.  When you compile wcd with DJGPP
    2.05 gcc will run out of memory with this message:

    cc1.exe: out of memory allocating 39408 bytes after a total of 9774416 bytes

    Use a registry editor (such as REGEDIT) to create the new (REG_DWORD)
    registry value DpmiLimit under the key

    Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WOW

    Now edit the value to reflect the maximum amount of memory (in bytes)
    that you wish to make available to console applications (DOS command boxes).
    E.g. 8000000 (hexadecimal) to make 128 MB available.

    See also http://www.trnicely.net/misc/vista.html

DJGPP on Windows 8.1 and higher
-------------------------------

DJGPP is not running anymore on the latest 32 bit Windows 8.1 and 10.
The last 32 bit Windows version on which DJGPP runs OK is Windows 7.

My solution for Windows 8.1 and higher is to run DJGPP in DOSBox.


Basic Installation
==================

dos32    : DOS 32 bit
dos32bsh : DOS 32 bit for BASH
win32    : Windows 32 bit console version.
win32psh : Windows 32 bit PowerShell version.
win32zsh : Windows 32 bit MSYS and ZSH version.
win64    : Windows 64 bit console version.
win64psh : Windows 64 bit PowerShell version.
win64zsh : Windows 64 bit MSYS and ZSH version.
os2      : OS/2 32 bit console version.
os2bash  : OS/2 32 bit bash version.

Change to the appropriate directory `dos32', `dos32bsh', `win32', `win32psh',
`win32zsh', `win64', `win64psh', `win64zsh', `os2', `os2bash'.


Build wcd:

  Type `make' to compile the package.

Install wcd:

  Type `make install' to install the package.

  `make install' will also compile the package if it wasn't done yet.

To start clean:

  Type `make clean'


Native Language Support (NLS)
=============================

NLS is by default disabled. To enable NLS set the ENABLE_NLS variable to 1:

  make ENABLE_NLS=1


Curses interface
================

The default interface is curses.

To disable CURSES and compile with stdio interface, reset the CURSES variable:

  make CURSES=


PDCurses
--------

The DOS and Windows versions of Wcd use by default PDCurses.

To build wcd with PDCurses interface you need to have the PDCurses
library installed. Get PDCurses at http://sourceforge.net/projects/pdcurses/
Compile it and copy the library file into the \lib directory of your
compiler and the curses.h file in the \include directory.

Build PDCurses for Windows with wide-character (Unicode) support (WIDE=Y),
and install it as libpdcursesw.a. Also the non-Unicode version of wcd requires
PDCurses with wide-character support.

Support for resizing of ConEmu or Windows 10 console requires PDCurses version
3.7 or higher.

The DJGPP and MinGW project also provide ready-to-use binary PDCurses packages.

The DOS versions use the library with narrow character support (CURSES=pdcurses).
The Windows versions (Wcd with and without Unicode support) use the library with
wide (Unicode) character support (CURSES=pdcursesw).


Ncurses
-------

The OS/2 EMX (gcc) versions of Wcd use by default ncurses (CURSES=ncurses).

You can also build the Windows version of wcd with Ncurses. Mingw.org and MSYS2
provide ncurses(w) libraries.
See also whatsnew.txt for issues with Ncurses that have been solved.
To compile for ncurses add CURSES=ncursesw (wide Unicode characters support)
to the make command line for Windows.

* By default the Ncurses interface does not work in Console (also known as
  Console2) <https://sourceforge.net/projects/console/> and ConsoleZ
  <https://chocolatey.org/packages/ConsoleZ>. Set environment variable
  NCURSES_CONSOLE2 to 1 to make it work.
* The ncurses interface vibrates while moving around in the tree.
  It is very visible in a standard Windows Command Prompt. In ConEmu
  <https://conemu.github.io/> there is less vibration.
  The vibration can be solved by using werase() instead of wclear(), but when werase()
  is used, the screen gets filled with garbage when an East-Asian CJK legacy font
  is used.
* The ncurses interface has better support for Unicode than PDCurses, because Ncurses
  supports combining characters, while PDCurses doesn't.

Both Ncurses and PDCurses have misalignment at the highlighted directory in the
graphical tree with true type CJK font. E.g. the Chinese Simsun font.

PDCurses is still the default on Windows, because it gives a more stable screen.


Conio interface (DOS only)
==========================

To enable the conio interface instead of curses add CONIO=1:


  make CONIO=1


Graphical tree
==============

By default the graphical tree is drawn with line drawing
characters. If these are not available on your system you
can set ASCII_TREE=1 so that ASCII characters are used instead.

  make ASCII_TREE=1



Unicode support
===============

Unicode support is by default enabled on Windows and disabled on DOS
and OS/2. To disable add UCS= to the make command:

  make UCS=

Unicode support requires a (pd/n)curses installation with wide character support.
Not supported for DOS versions of wcd.

Unicode works only in Windows PowerShell, and Command Prompt
on Windows 7 or higher. On older versions of Windows you need
Take Command or TCC/LE made by JP Software be able to change to
Unicode paths.


Enable Unicode normalization with UNINORM=1. This implies UCS=1.

  make UNINORM=1


Unicode normalization requires libunistring, see
  http://www.gnu.org/s/libunistring/
  http://en.wikipedia.org/wiki/Unicode_normalization

  libunistring packages are provided by Mingw.org and MSYS2.


Installation Names
==================

By default `make install' will install the program in /usr/bin, the
language files in /usr/share/locale and the man file in
/usr/share/man. You can specify an installation prefix other than
`/usr' by giving `make' the option `prefix=PATH'.


Example:

  make clean
  make prefix=c:/Users/waterlan
  make install prefix=c:/Users/waterlan


dos32    : The default PREFIX is c:/dos32
dos32bsh : The default PREFIX is c:/dos32
win32    : The default PREFIX is c:/usr/local
win32psh : The default PREFIX is c:/usr/local
win32zsh : The default PREFIX is c:/usr/local
win64    : The default PREFIX is c:/usr/local64
win64psh : The default PREFIX is c:/usr/local64
win64zsh : The default PREFIX is c:/usr/local64
os2      : The default PREFIX is c:/usr
os2bash  : The default PREFIX is c:/usr


distribution package
====================

After installation a ready-to-run binary distribution package can be created.

  Type `make dist' to create the package.
