Next: , Previous: PC Binary Installation, Up: PC Installation



B.3.3.2 Compiling gawk for PC Operating Systems

gawk can be compiled for MS-DOS, Windows32, and OS/2 using the GNU development tools from DJ Delorie (DJGPP; MS-DOS only) or Eberhard Mattes (EMX; MS-DOS, Windows32 and OS/2). Microsoft Visual C/C++ can be used to build a Windows32 version, and Microsoft C/C++ can be used to build 16-bit versions for MS-DOS and OS/2. (As of gawk 3.1.2, the MSC version doesn't work. However, the maintainer is working on fixing it.) The file README_d/README.pc in the gawk distribution contains additional notes, and pc/Makefile contains important information on compilation options.

To build gawk for MS-DOS, Windows32, and OS/2 (16 bit only; for 32 bit (EMX) you can use the configure script and skip the following paragraphs; for details see below), copy the files in the pc directory (except for ChangeLog) to the directory with the rest of the gawk sources. The Makefile contains a configuration section with comments and may need to be edited in order to work with your make utility.

The Makefile contains a number of targets for building various MS-DOS, Windows32, and OS/2 versions. A list of targets is printed if the make command is given without a target. As an example, to build gawk using the DJGPP tools, enter `make djgpp'. (The DJGPP tools may be found at ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/.)

Using make to run the standard tests and to install gawk requires additional Unix-like tools, including sh, sed, and cp. In order to run the tests, the test/*.ok files may need to be converted so that they have the usual DOS-style end-of-line markers. Most of the tests work properly with Stewartson's shell along with the companion utilities or appropriate GNU utilities. However, some editing of test/Makefile is required. It is recommended that you copy the file pc/Makefile.tst over the file test/Makefile as a replacement. Details can be found in README_d/README.pc and in the file pc/Makefile.tst.

The 32 bit EMX version of gawk works “out of the box” under OS/2. In principle, it is possible to compile gawk the following way:

     $ ./configure
     $ make

This is not recommended, though. To get an OMF executable you should use the following commands at your sh prompt:

     $ CPPFLAGS="-D__ST_MT_ERRNO__"
     $ export CPPFLAGS
     $ CFLAGS="-O2 -Zomf -Zmt"
     $ export CFLAGS
     $ LDFLAGS="-s -Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack 0x8000"
     $ export LDFLAGS
     $ RANLIB="echo"
     $ export RANLIB
     $ ./configure --prefix=c:/usr --without-included-gettext
     $ make AR=emxomfar

These are just suggestions. You may use any other set of (self-consistent) environment variables and compiler flags.

To get an FHS-compliant file hierarchy it is recommended to use the additional configure options --infodir=c:/usr/share/info, --mandir=c:/usr/share/man and --libexecdir=c:/usr/lib.

The internal gettext library tends to be problematic. It is therefore recommended to use either an external one (--without-included-gettext) or to disable NLS entirely (--disable-nls).

If you use GCC 2.95 or newer it is recommended to use also:

     $ LIBS="-lgcc"
     $ export LIBS

You can also get an a.out executable if you prefer:

     $ CPPFLAGS="-D__ST_MT_ERRNO__"
     $ export CPPFLAGS
     $ CFLAGS="-O2 -Zmt"
     $ export CFLAGS
     $ LDFLAGS="-s -Zstack 0x8000"
     $ LIBS="-lgcc"
     $ unset RANLIB
     $ ./configure --prefix=c:/usr --without-included-gettext
     $ make
NOTE: Even if the compiled gawk.exe (a.out) executable contains a DOS header, it does not work under DOS. To compile an executable that runs under DOS, "-DPIPES_SIMULATED" must be added to CPPFLAGS. But then some nonstandard extensions of gawk (e.g., `|&') do not work!

After compilation the internal tests can be performed. Enter `make check CMP="diff -a"' at your command prompt. All tests but the pid test are expected to work properly. The pid test fails because child processes are not started by fork().

`make install' works as expected.

NOTE: Most OS/2 ports of GNU make are not able to handle the Makefiles of this package. If you encounter any problems with make try GNU Make 3.79.1 or later versions. You should find the latest version on http://www.unixos2.org/sw/pub/binary/make/ or on ftp://hobbes.nmsu.edu/pub/os2/.