Setting up a Unix-like environment for OS/2

From OS2World.com Wiki
Jump to: navigation, search

By Christian Hennecke

This short guide is intended to get your software up and running fast and to prevent you from having to read a lot of documentation files for programs you maybe never will use yourself, but other programs may need. Most of this software can do a lot for you, but to explore the possibilities I'd suggest you get a book about Linux/Unix basics.

Contents

1. Prerequisites

1.1 Preparing the drives

Create a Unix-like directory tree on one partition that is large enough to hold all unixish stuff. You should do this because some - especially older - ported programs are not enhanced to know drive letters and simply won't find files on other drives. If you don't want to do this or simply don't have enough space on one HDD, you can workaround the problem by using the Toronto Virtual File System (TVFS). TVFS allows creating virtual drives and linking directories from other drives into the virtual tree very similar to the Unix filesystems. Note however that you will experience a slight performance hit. If you are using JFS, you can also create a volume that consists of partitions on different drives.

Recommended tree structure

Due to the status quo of available ports, this tree structure differs from the one suggest by the UnixOS2 project.

x:/
+--bin/         (shells)
|
+--emx/         (emx+gcc)
|
+--etc/         (configuration files)
|
+--home/
|    |
|    +-userid/  (your HOME directory, on unixish systems named like your login-ID,
|                the place user-specific configuration files get stored)
|
+--usr/
|    |
|    +--bin/      (executables and shell skripts)
|    |
|    +--doc/      (documentation that's not in the form of man-pages or texinfo files)
|    |
|    +--etc/      (configuration files)
|    |
|    +--include/  (header files, etc., only needed if you're planning to compile
|    |             something yourself)
|    |
|    +--info/     (documentation in the form of texinfo files)
|    |
|    +--lib/      (DLLs and libraries)
|    |
|    +--share/    (things shared by programs, e.g. internationalization support)
|         |
|         +--locale/   (national language support)
|         |
|         +--man/      (the place the man-pages for the man(ual) help system get stored)
|              |
|              +--man1/  (for man-pages matching the *.1* pattern, e.g. bla.1 or
|              |          blah.1.gz)
|              ...
|              |
|              +--man9/
|              |
|              +--mann/
|              |
|              +--cat1/  (for pre-formatted man-pages which are loaded faster)
|              |
|              ...
|              |
|              +--cat9/
|              |
|              +--catn/
|
+--tmp/           (for temporary files)
|
+--var/           (for temporary files)

1.2 Obtaining the necessary software

Get the following packages from os2site.com or Hobbes.

  • emx run-time
  • GNU gawk, gettext (only DLL-version needed), grep, groff, fileutils, findutils, readline (only DLL-version needed), sed, shellutils, textutils
  • less, man, pdksh
  • Perl (You can get the latest distribution available via CPAN or http://www.perl.com. However you may come across older programs relying on the naming convention of the 5.002b implementation that's available on Hobbes and LEO and easier to install. If you don't want to fiddle around then you can install both.)

If you're planning to compile things yourself you'll likely need the following:

  • emx+gcc plus certain contribs, gcc 3.x (version 3.2.x is available from Innotek)
  • GNU autoconf, automake, gettext (full package), libtool, m4, make, perf, readline (full version)

If you want to develop software yourself these might be of interest:

  • GNU bison, CVS, flex, RCS

2. Installation

2.1 Unpacking and placing the files

Get the free Info-Unzip program and place unzip.exe into a directory that's in your PATH environment variable. Place all needed emx archives into one empty temporary directory and issue the command

unzip * -d x:\

All extracted files will be placed into the x:/emx tree.

Ported software packages which understand the UNIXROOT environment variable can simply be unpacked into x:\ most of the time.

For other packages, create a temporary directory and unzip a package into it. Doing this seperately for each package will reduce the risk of overlooking something. Copy or move all files and subdirectories in directories to their corresponding directory on drive x (e.g. /lib/awk/* into x:/usr/lib/awk). DLLs should be placed into x:/usr/lib.

CAUTION: Shell executables have to be placed in x:\bin! Many ported programs won't be able to find the shell otherwise.

In case the archive doesn't contain directories consider the following patterns. Copy *.exe, *.cmd, *.*sh and any other shell scripts to x:/usr/bin. Copy *.dll to x:/usr/lib and *.doc, *.htm*, *.ps, *.tex or *.txt to x:/usr/doc. Files like *.info and *.texi* go into x:/usr/info. Put man-pages (e.g. files like *.1 or *.1.gz or *.1.bz2) into the corresponding subdirectories of x:/usr/share/man.

Some files or directory trees have to be placed in special directories. E.g. language dependent messages go into x:/usr/share/locale/<country_code>/LC_MESSAGES with <country_code> being something like de for German or en for English. Simply copy *.mo files and rename *.gpo to *.mo.

The recent port of Perl has an own installation program. However, don't forget to customize the config.pm file and check the environment variables! (See Perl README.)

Most packages come with the source code or diffs you can apply to the original source. If you don't want to recompile the packages you can safely delete the src/ or diffs/ directories.

2.2 Setting the required environment variables

Note: Note the difference between Unix-style "/" and OS/2-style "\" path seperators!

Add x:\bin, x:\usr\bin, and x:\emx\bin to your PATH, x:\usr\lib, and x:\emx\dll to your LIBPATH statement in CONFIG.SYS. Consider placing x:\usr\bin before bootdrive:\OS2 since OS/2 also has commands like sort and find, but with less functionality so you will run into problems if some program uses them to process files otherwise.

Add the following variables to CONFIG.SYS or add the paths if they already exist. Try copy & paste and replacing x: with the driveletter you have chosen!

Note: Some programs like e.g. certain commercial compilers may use some of the variables (LANGUAGE, TEMP, TMPDIR, TMP, ...) and will change them without notice upon installation. So check your CONFIG.SYS! Root directory:

SET UNIXROOT=X:       (tells many packages where to find their files)

Directory for temporary files:

SET TEMP=anydrive:\TMP     (the filesystem on anydrive: must support long filenames!)
SET TMP=anydrive:\TMP      (HPFS and ext2fs are a good choice)
SET TMPDIR=anydrive:/TMP   (NFS is possible, but will cause problems if the network goes down!)

Internationalization:

SET LOCALEDIR=x:/usr/share/locale      (add x:/usr/X11R6/lib/X11/locale if you are running XFree86/OS2 v4)
SET GNULOCALEDIR=x:/usr/share/locale   (add this if you are using the new ports from Japan)
SET LANGUAGE=<country_code>        (e.g. jp for Japan, en for English)

GNU awk:

SET AWK=x:/usr/bin/gawk.exe
SET AWKPATH=x:/usr/share/awk   (or x:/lib/awk)

Copy gawk32.exe (old port) to gawk.exe and awk.exe, or gawk.exe (new port) to awk.exe. Not everybody uses the AWK variable.

GNU autoconf:

SET AC_PREFIX=x:   (your drive)

GNU Groff:

SET GROFF_FONT_PATH=x:/usr/lib/groff/font
SET GROFF_TMAC_PATH=x:/usr/lib/groff/tmac
SET REFER=x:/usr/lib/groff/dict/papers/int
SET GROFF_TYPESETTER=cp850               (Or cp437 respectively. These devices don't exist in the port from Jun Sawataishi, so choose another!)
SET NROFF=GROFF -Tascii -mandoc          (Or -Tlatin1 if your're living in Europe.)

Manual system:

SET MAN_CONF=x:/etc/man.conf
SET MANPAGER=less
SET MANPATH=x:/usr/share/man;x:/emx/man   (add x:/usr/X11R6/man if you're running XFree86/OS2 v4)

Perl:

SET PERL5LIB=x:/perl5/lib                          (only for Perl 5.002b)
SET PERL_BADLANG=0                                 (for recent Perl ports)
SET PERLLIB_PREFIX=L:/perllib/lib;x:\PERLLIB\LIB   (the L: part is hardcoded depening on the version)
SET PERL_SH_DIR=x:\bin

Something about you:

SET HOME=x:\home\<login-ID>
SET USER=<login-ID>
SET LOGNAME=<login-ID>

The login-ID is best set to the one you use to access your ISP or email account, since some programs automatically will use it for these purposes.

emx:

SET TERM=ansi
SET TERMCAP=x:/emx/etc/termcap.dat                       (or x:/usr/X11R6/lib/X11/etc/xterm.termcap if you're running XFree86/OS2)
SET EMXOPT=-h512                                         (this increases the limit of open files, you may want to set it even higher)
SET HELPNDX=EMXBOOK.NDX                                  (settings for the OS/2 online help)
SET EMXBOOK=EMXDEV.INF+EMXLIB.INF+EMXGNU.INF+EMXBSD.INF
SET INFOPATH=x:/emx/info;x:/usr/info                     (searchpath for the texinfo documentation system)

Miscellaneous:

SET PAGER=less   (something like 'more' or 'less', less has more functionality)

Note: There are some versions of less out there that don't work under XFree86/OS2!

SET EDITOR=your_favourite_editor

Note: It may be a good idea to set this variable to a PM or VIO program in CONFIG.SYS and a X program in a special script that sets variables for use in XFree86/OS2. As far as I know Emacs, ViM and FTE are available in both PM/VIO and X versions so you can use a familiar user interface.

The following is only needed if you want to compile/port programs with emx yourself. Also have a look at Alexander Mai's Porting FAQ.

SET C_INCLUDE_PATH=x:/emx/include;x:/usr/X11R6/include;x:/usr/include
SET CPLUS_INCLUDE_PATH=x:/emx/include/cpp;x:/emx/include;x:/usr/X11R6/include;x:/usr/include
SET GCCLOAD=5
SET GCCOPT=-pipe
SET LIBRARY_PATH=x:/emx/lib;x:/emx/lib/mt;x:/usr/X11R6/lib
SET OBJC_INCLUDE_PATH=x:/emx/include
SET PROTODIR=x:/emx/include/cpp/gen
SET HOSTTYPE=i386
SET MACHTYPE=i386-pc-os2

That's it!