Well
I quite like OS/2 and spend much of my free time tweaking Linux
programs to work with it. And sometimes I even get it!
What I've found that makes porting more difficult is sometimes
building all those makefiles and configuration headers. Under Linux
and most *nix like O.S. you would run a configure script that guesses
most of your system peculiarities (Name of the C/C++ compiler, which
headers and libraries are present, whether a function is
broken...). But OS/2 is not Unix --nor even similar--- and there
are enough differences to break up those configuration scripts, even
if you already have a sh-like shell.
OK, it was the state of the question until now. This port of
Autoconf introduces a set of scripts and macro files able to build
scripts that work well under OS/2 with EMX using all those wonderful
ports of GNU utilities.
First you must already have the EMX ports of this set of programs
which you can find in Leo and Hobbes:
- GNU file, text and shell utilitities
- GNU m4 macro processor
- Korn Shell 5.2.13 or newer --watch the number!!-- or Ash
--available at this site--. If you use Ash, make sure you have
the latest release (>= ash-0.2-4).
- Most of the times you'll need AWK. Get a standard one (Maybe
GNU's)
- GNU make. Make sure it is <= 3.74. You can also use XfreeOS/2
x11make.exe which is nothing but GNU Make 3.71, but
never use make.cmd, the wrapper for
x11make.exe.
And you must also be working on a filesystem that allows long file
names. This happens under OS/2 with HPFS --and RSX+Win95/NT would
do, too, but I haven't got any of them, so I could not test it--.
Most Linux programs come with a configure script that has the purpose
of guessing important system defaults. Currently, most of those
scripts are built with a tool named Autoconf, from the FSF, which
takes in one or two macro files (configure.in &
aclocal.m4) and using the M4 macro processor and another
internal set of macro files (mainly acgeneral.m4 &
acspecific.m4) creates a third one, named
configure. What I've done is tweaking the internal macro
files, so that the code they produce is well suited to run under EMX
with a filesystem that allows long file names. The most important
changes are:
- When looking for executable programs, check not only for
program files, but also for program.exe and
program.cmd
- Avoid looking for executable files in OS/2 & Window's
directories (the reason for doing this is that the GNU install utility
has the same name as the install program from OS/2 & Win).
- When splitting PATH use semicolon ";" as a separator, not
a double colon ":".
- Instead of manipulating PATH, save its value in FPATH, translate
"\" into "/" and work with this last one.
- Add some important defaults at the begining of every script, such
as the name of the compiler and other important options needed to
compile programs with EMX.
- Add rules for undestanding unit names.
- Make a directory for Autoconf. Let's say it is
c:\apps\autoconf
- Unpack the binary distribution packet (autoconf*emxbin.zip) there.
- Add that directory to PATH or either move the script
files autoconf, autoreconf, autoheader, autoscan, autoupdate and
ifnames to some other directory which *is* listed in
PATH.
- Define an environment variable named AC_MACRODIR that
points to the place where you unpacked aconf*b.zip. For instance, if
it was c:\apps\autoconf, add the following line to your
config.sys:
SET AC_MACRODIR=c:/apps/autoconf Beware with
slashes: you must use `/', not `\'.
- You're free to move the documentation (*.info* files) to any place
which is listed in INFOPATH. (Note: *.info* files may not be
in the package if this is a test release)
- If you ever happen to need AWK to run Autoconf, make sure
you have an executable named `awk.exe' or either set the AWK
environment variable: for instance, in my system it would be
set AWK=e:/usr/bin/gawk.exe
Requisites
The same as Requisites for running plus...
- GNU make up to 3.74 (The newest make is not case sensitive and may
cause conflicts with some makefiles). If you have the XFreeOS/2
Toolkit for Programmers, make sure you always invoke make.exe
or x11make.exe and not the make.cmd script that
comes with XFreeOS/2 (At home, I renamed make.exe as
gmake.exe and use this last one).
Steps
- Move into autoconf's directory.
- Start an system shell and type "build --clean". This
should remove any file from configure config.cache config.status
config.log. (Note: autoconf's options are case sensitive, that
is, use always lowercase for them) Alternatively, you can remove those
files by hand.
- Now simply type build and you'll get a configure
script about 32K's long.
- Create a unix-like directory structure. My system has the
following one
e:/usr
e:/usr/bin
e:/usr/info
...
e:/usr/local
e:/usr/local/bin
e:/usr/local/info
...
and /usr/bin and /usr/local/bin are in the
PATH. When installing, Autoconf chooses the root directory
you tell it (in my system it could be either e:/usr or e:/usr/local),
builds several directories inside it uses them to stores scripts, info
and macro files. Suppose the `root' is e:/usr/local then
- e:/usr/local/bin should be in PATH
- e:/usr/local/bin is where scripts will be stored
- e:/usr/local/info is where the documentation will be stored
- e:/usr/local/share/autoconf is where the macro files will be
- At the command prompt type something like "sh configure
--prefix=your_root_directory" where sh is the name of your
unix-like shell. This will tipically find m4, awk
--and perl.exe in case you have it-- and create customized
makefiles for autoconf.
For example, in my system (described above, I would use) sh
configure --prefix=e:/usr/local
- Invoke GNU make. You can either use make.exe, or even
call x11make.exe if you have the XFreeOS/2 programmer's
toolkit. But never use a simple make as the XFreeOS/2
make.cmd could pop up and mess the deal. This builds the
customized scripts autoconf, autoheader, autoreconf, autoupdate,
and ifnames.
- If everything went right, type "make.exe install", and
you'll have the scripts, the macro files and the info files installed.
- IMPORTANT: Save a copy of config.sub, config.guess, install-sh
and mkinstalldirs as you might need them to port your program.
- Move into the directory which has the code you want to port.
- The configure file must be already there: rename it to
configure.bak.
- Copy Autoconf's config.sub, config.guess &
install-sh, there, before it's too late :)
- You should also replace mkinstalldirs with the one that
comes in Autoconf for EMX, as this last one understands drive unit
names.
- Type sh -c "autoconf --clean" to remove configure's
auxiliary files: this should be done every time configure is
rebuilt or after anything in your system changed (new programs installed,
new PATH, etc) so that configure cares for those changes.
- Type sh -c autoconf to get a brand new configure.
- If you know your program is going to need some special flags, such as
-Zmt, -D__ST_MT_ERRNO__, etc, then edit the lines in
configure for CCFLAGS (C compiling flags),
CXXFLAGS (C++ compiling flags), LDFLAGS (Flags for linking).
Alternatively, you can export environment variables prior to using
configure overriding the checks it could do. For instance, a
set MAKE=gmake.exe
set CFLAGS=-O -Zmt
set CXXFLAGS=-O -Zmt
set LDFLAGS=-Zexe -Zmtd -Zsysv-signals
would choose the appropiate name for the MAKE utility and the appropiate
flags for compiling an XFreeOS/2 program.
- Run sh ./configure with any other options you wish. Usually
sh ./configure --help
would inform you about the available options (programs to build, extensions,
checks to avoid or include, etc), whereas
sh ./configure --prefix=d:/usr
would configure using default settings and defining the root directory to be
d:/usr.
- Watch the output: if the script can't find a program, library or
file you DO have; or if some strange error comes out, please e-mail me
but don't abuse the author (See Bug reports)
- Check all the files that have been updated (configure shows their
names). They're usually makefiles and a config.h. If you see
a path messed (i.e. /usr/../c:/usr/bin/sh.exe) and you cannot
figure out why configure failed, tell me. (See Bug
reports)
- Now do the real port: check the code and fix it. Here I cannot help
you ;)
Autoconf does not port programs. Most unix C/C++ code has
some... let's call them peculiarities, that should be fixed before
compiling. For instance:
- The use of fork and exec is not recommended if
you want your program to run under DOS. And even under OS/2 it wastes
a lot of resources and slows programs a lot.
- Unix programs don't understand disk units names, such as
'C:'. This can be a real drawback in many ports.
- Unix text files use simple newline characters, while DOS and OS/2
use newline plus carriage return. This implies that files have to be
opened with special flags (O_BINARY, "b", O_TEXT, "t") that
distinguish between text and binary files.
So, what you'll get is a set of makefiles and configuration headers
that have to be revised.
- We move up to version 2.12
- Checks for X are fixed --now they understand X11ROOT--.
- Flag `-g' removed and `-Zcrtdll' added to reduce
the size of programs.
- Added some patches that simplify the load on the shell and let you
use this Autoconf with NCurses-4.1 (Contribution of T.E.Dickey)
- Added flags for building bug reports.
- Hey, this is work in progress, don't expect miracles!!!
- All usual disclaimers apply
- Read the GNU license that comes with the packages
- Read the file ChangesLog.os2 for important changes, features and
maybe bugs.
If you miss a feature in autoconf, or find something doesn't work,
please e-mail me.
When reporting bugs, follow these steps:
I would like to thank Alexander Mai for his many comments on the
project, and T.E.Dickey for pointing out some bugs.
So... here are
GNU Autoconf 2.12 for EMX, sources (400k long) and
GNU Autoconf 2.12 for EMX, precompiled (236k long)