Building OpenSSL with OpenWatcom on ArcaOS: First Porting Effort

I have previously written about my OpenSSL port to OS/2. Here I go over the first C code changes that make it compile with OpenWatcom 1.9.

As previously mentioned, I’m doing this on ArcaOS; so some Unix-ism will be present in the build system. This is apparently unavoidable, and fortunately, ArcaOS already comes with a lot of Unix ports; both out of the box and installed through yum (or the Arca Noae Package Manager).

The following changes leave us with a port that builds for the most part. Some parts will need more changes before they are strictly “correct” and we’ll return to those later.


First we revert

$rm='rm -f';

because DEL doesn’t return zero when the file doesn’t exist, and we have the rm.exe file in \usr\bin on ArcaOS.

We set

$mklib='wlib -n -q';

because even though we’re building static libraries, the build system picks up $shlibp instead of $libp as far as I can tell. The -n tells wlib to always create a new library, and -q tells it not to display the banner on every invocation.

We also comment out the third command for the library target,

#$ret.="\t\$(RANLIB) $target\n\n";

and fix the linker line for executables to properly fit the wlink syntax.

$ret.="\t\$(LINK_CMD) name $target file { $files } library { $libs }\n\n";

This takes care of the build system for now.


We add

#  define OPENSSL_USE_IPV6 0
#  define NO_SYSLOG

to the OS/2 section because it has neither IPv6 nor syslog.

For some reason there’s no consistency here; we have OPENSSL_ prefix for IPv6, but no prefix for syslog.

On a second thought, these changes are maybe better off in e_os.h but at the moment they work for me, so I’m sticking to them.


We unconditionally

# include <nerrno.h>

to pull in the definitions of the network error codes, such as EADDRINUSE and friends.


We unconditionally

# include <fcntl.h>

to include the O_TEXT and O_BINARY definitions.


We unconditionally

#include <types.h>

to pull in the type definitions for long_int, u_int, caddr_t and friends.


This file needs some special considerations. It appears it has an obsolete hack from, presumably, the previous century.

Apparently two of the functions the original OS/2 porters wanted to use were unavailable to the GCC and/or EMX runtime. Using OpenWatcom 1.9, we don’t have this problem. So all we do is wrap an #if 0 around the offending code blocks. Currently, the people who build OpenSSL for OS/2 are using the Klibc, so this code should probably be ejected from OpenSSL altogether; but that’s a different argument. Right now, we just unconditionally remove it.

Lines 67 through 88.

# if 0
# define   CMD_KI_RDCNT    (0x63)

typedef struct _CPUUTIL {
    ULONG ulTimeLow;            /* Low 32 bits of time stamp */
    ULONG ulTimeHigh;           /* High 32 bits of time stamp */
    ULONG ulIdleLow;            /* Low 32 bits of idle time */
    ULONG ulIdleHigh;           /* High 32 bits of idle time */
    ULONG ulBusyLow;            /* Low 32 bits of busy time */
    ULONG ulBusyHigh;           /* High 32 bits of busy time */
    ULONG ulIntrLow;            /* Low 32 bits of interrupt time */
    ULONG ulIntrHigh;           /* High 32 bits of interrupt time */

# ifndef __KLIBC__
APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1,
                                  ULONG ulParm2, ULONG ulParm3) = NULL;
APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, PID pid,
                                    TID _res_, PVOID buf, ULONG bufsz) =
# endif

Lines 102 to 118.

#if 0
# ifndef __KLIBC__
        if (rc == 0) {
            rc = DosQueryProcAddr(hDoscalls, 976, NULL,
                                  (PFN *) & DosPerfSysCall);

            if (rc)
                DosPerfSysCall = (unsigned long) NULL;

            rc = DosQueryProcAddr(hDoscalls, 368, NULL,
                                  (PFN *) & DosQuerySysState);

            if (rc)
                DosQuerySysState =NULL;
# endif

Lines 142 through 146.

#if 0
# ifndef __KLIBC__
            DosPerfSysCall = NULL;
# endif


This file needs some serious cleanup. For now, we just make two minor changes to make it compile on OS/2.

Add OS/2 to the list of “other” systems.

 * We know that VMS, MSDOS, VXWORKS, NETWARE use entirely other mechanisms.
 * MAC_OS_GUSI_SOURCE should probably go away, but that needs to be confirmed.
# elif !defined(OPENSSL_SYS_VMS) \
	&& !defined(OPENSSL_SYS_MSDOS) \
	&& !defined(MAC_OS_GUSI_SOURCE)	\
	&& !defined(OPENSSL_SYS_VXWORKS) \
	&& !defined(OPENSSL_SYS_NETWARE) \
        && !defined(OPENSSL_SYS_OS2)
#  define TERMIOS
#  undef  TERMIO
#  undef  SGTTY
# endif

And also to the list of systems without TTY_STRUCT.

 * This one needs work. As a matter of fact the code is unoperational
 * and this is only a trick to get it compiled.
# define TTY_STRUCT int

Final Words

We’re now at the stage where both crypto.lib and ssl.lib build sucessfully, and most applications are having some linking errors. More on that next time.

Do you need professional help with OS/2? Write to

4 thoughts on “Building OpenSSL with OpenWatcom on ArcaOS: First Porting Effort

  1. In the past I did OpenSSL port to OW too but for all platforms.
    There was problem with calling convention for assembler parts.
    It was necessary define prototypes for these function as __cdecl in C code and switch of name mangling for these function.
    Anyway Open Watcom V2.0 fork exists and could help you because it has improved cross-platform feature in tools (wmake, wcl, owcc)

    1. Hi and thank you for reading. Sorry about the late reply.

      If it’s important to you, it’s best you send me an email.

Leave a Reply to Jiri Malak Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: