Author Topic: Newbie guide to porting software?  (Read 712 times)

jailbird

  • Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
    • View Profile
Newbie guide to porting software?
« on: June 10, 2022, 01:09:37 am »
So I went from being a mostly DOS user to about 30 years of using various flavors of *IX. I'm now playing around with ArcaOS finally. At my $DAYJOB I build a lot of RPM packages (for Linux), so I figured why not try and build some on OS/2 too!

So far, I'm mostly failing though, and I haven't even made it to the .rpm part yet :).

My first attempt was lftp, since the built-in ftp.exe is pretty lacking and the version of NcFTP in the yum repo is pretty old. I managed to get lftp to build, but it has 2 major issues so far: 1) It can't find local files at all (I'm guessing due to / vs \ ?) and  2) The password prompt is echoing the password.

My second attempt was some flavor of vi. I know there are some old versions of vim floating around, but I figured I'd give something a shot. I figured vim was too much to start with, so I started with nvi. The original version of nvi had a pretty old build system and nvi2 seems to have a lot of BSD-specific things, so I tried elvis. Elvis seems to have some OS/2 support, but that support was originally compiled with IBM VisualAge C++ 3.0. So I attempted to just use the POSIX (UNIX) code with gcc and ncurses. That compiled fine and it runs, but when I move around with the h/j/k/l keys, those keys keep printing (eg, it'll print "jjjj") until I hit enter, and then the enter will repaint the screen and get rid of the "j"s. I tried modifying the code to force repaints after every key, but no luck quite yet.

So I'm hoping that these issues are common ones that others have ran into and that maybe it's something that we can put on Wiki somewhere?

To start out with, I had taken some info that I found on these forums and then modified it until I got things mostly working. Most of the posts here assume "ash", but I'm currently using "mksh" as I much prefer it (but I've tried ash too!).  My workflow so far is basically:

C:\> mksh
$ . ./os2.txt
$ mkdir project/build
$ cd project/build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make

Where os2.txt contains:

export LDFLAGS="-Zomf -Zhigh-mem -Zmap -Zbin-files -Zargs-wild -Zargs-resp"
export CFLAGS="-O2 -g -march=pentium4 -pipe"
export CXXFLAGS="-O2 -g -march=pentium4 -pipe"
export LIBS="-lcx"
export CC=gcc
export CXX=g++
export CPP=cpp
export CXXCPP=cpp
export LD=wl
export AR=emxomfld
export exeext=.exe
export SH=/usr/bin/mksh
export SHELL=/usr/bin/mksh
export CONFIG_SHELL=/usr/bin/mksh
export POSIX_SHELL=/usr/bin/mksh
export PREFERABLY_POSIX_SHELL=/usr/bin/mksh
export PATH="C:/USR/SBIN;C:/USR/BIN"

(SH/CONFIG_SHELL/POSIX_SHELL/PREFERABLY_POSIX_SHELL is for autoconf projects)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3633
  • Karma: +77/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #1 on: June 10, 2022, 01:56:37 am »
Well first I see these that need fixed, fixed exports below,
Code: [Select]
export LD=emxomfld
export AR=emxomfar
export RANLIB=echo
The PATH is pretty short too, should have /@unixroot/usr/libexec/bin in the front. They're programs that also have OS/2 equivalents. You still might need something else on the PATH, might be best to just drop it.
You're also missing export MAKESHELL
But the real problem is that our libc is lacking in term support, which is why you're having problems.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3633
  • Karma: +77/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #2 on: June 10, 2022, 07:00:36 am »
Actually, looking again, the export AR and export RANLIB lines shouldn't be there as you don't have -Zomf in your CFLAGS and/or CXXFLAGS, which is probably for the best.
I'd also suggest adding -mtune=generic  and removing -pipe to your CFLAGS/CXXFLAGS. The -mtune=generic will produce better code for everything besides actual Pentium 4 and -pipe can cause problems

Note also that if try to build something with the autotools, they should be rebuilt with autoreconf -sfi to get OS/2 versions of configure and libtool

jailbird

  • Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #3 on: June 10, 2022, 07:22:28 am »
Ah-ha! Thanks

I think I had RANLIB=echo at one point but ran into problems with it. Probably because I didn't have LD/AR set correctly? Thanks for the pointers.

Same with PATH, using the stock PATH I was running into some weird issues, so I went minimal. I'll try again. Thanks for the pointers!

jailbird

  • Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #4 on: June 10, 2022, 09:03:29 am »
Trying to debug the lftp issue with it not finding local files. What's the way to see what calls the application is making without resorting to gdb? Eg, something like strace on Linux, or truss on Solaris, or ktrace on BSD, or dtruss on macOS, or... :)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3633
  • Karma: +77/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #5 on: June 10, 2022, 04:52:46 pm »
Hi jailbird,
For the PATH, make sure you install os2-base-unixtools-base and perhaps os2-base-fhs so the *nix tools come before x:\os2
For tracing, I'm not sure if we have any tools to do that, perhaps someone else knows. Should be able to use the operating system trace but I've never done it.
Also we don't have a current gdb port, have to use an IBM debugger.
Always a good idea to grep for win32 as often Windows workarounds are similar to ones we need, especially things like making sure we're in binary mode.

jailbird

  • Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #6 on: June 14, 2022, 03:12:47 am »
Dave,

AH-HA! That's probably exactly the cause of my issue then. I wonder if netlabs would accept a 'build-essentials' RPM metapackage that would install all of the needed packages (gcc, etc).

As for things that are lacking in the terminal handling, does anybody know which layer they're lacking at? Eg, is it the termcap/terminfo layer, the ncurses/termlib layer, or the old 16-bit Vio layer?

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3633
  • Karma: +77/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #7 on: June 14, 2022, 04:01:08 am »
Dave,

AH-HA! That's probably exactly the cause of my issue then. I wonder if netlabs would accept a 'build-essentials' RPM metapackage that would install all of the needed packages (gcc, etc).

I don't see why not, they might have some ideas about what it should contain.

Quote
As for things that are lacking in the terminal handling, does anybody know which layer they're lacking at? Eg, is it the termcap/terminfo layer, the ncurses/termlib layer, or the old 16-bit Vio layer?

Mostly the termcap/terminfo layer I beleive. There is a ncurses port. There is always the option of falling back to native API, at that I recently discovered some of the 16 bit VIO layer is in libc complete with thunking and taking care of segments, see for example this thread, https://www.os2world.com/forum/index.php?topic=3066.
Handy having the libc source to find things like KbdCharIn()
If using the OS/2 API, pretty much required for some multimedia stuff like needing a foucc, libc includes its own version of os2.h which normally calls os2emx.h but can call the toolkit version. Or you can directly use the toolkits h files by doing something like "-dirafter /@unixroot/usr/include/os2tk45/h", need the -dirafter to avoid the toolkits ancient libc, then #include <os2me.h> for example will work.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 783
  • Karma: +13/-0
    • View Profile
Re: Newbie guide to porting software?
« Reply #8 on: June 14, 2022, 08:20:47 pm »
AH-HA! That's probably exactly the cause of my issue then. I wonder if netlabs would accept a 'build-essentials' RPM metapackage that would install all of the needed packages (gcc, etc).

I don't see why not, they might have some ideas about what it should contain.

netlabs.org consisists of the developers that use Adrian's facility to host projects. For to address someone, you should better address the maintainers of the netlabs.org .rpm repository. That's bww, not Adrian. (BTW: My project is on netlabs.org, too and I am not involved in any .rpm project, but I endorse that.)

In case of the .rpm files I have to say that bww uses the netlabs.org repository only for providing new packages. The sources, including bug tracker etc. were copied to GitHub long time ago.

I recommend the following: If you want to create a new SVN project with Trac, address Adrian. If you want to add something else or have the need of GitHub, contact Martin. If you want to have something added to the .rpm repository, contact bww.
« Last Edit: June 14, 2022, 08:33:20 pm by Andreas Schnellbacher »