Author Topic: Compiling PM Samples with OpenWatcom  (Read 4456 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4997
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Compiling PM Samples with OpenWatcom
« on: June 10, 2024, 03:16:58 am »
Hello

I want to learn to use a the OpenWatcom compiler as an alternative to gcc for some PM samples, but I need to understand the commands and have some example of the make file.

My desire is to compile some thing simple like: https://github.com/OS2World/UTIL-WPS-Scale
I have installed OpenWatcom C for OS/2 v2.0.x  offered from the David Azarewicz website. I'm using make and wlink too.

Please give me hand with the makefile, should I make a makefile.wcc ?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5040
  • Karma: +114/-1
    • View Profile
Re: Compiling PM Samples with OpenWatcom
« Reply #1 on: June 10, 2024, 04:50:48 am »
I just used the IDE to compile Util-WPS-Scale with the defaults plus PM program chosen. Here's the log.
Code: [Select]
cd H:\tmp\UTIL-WPS-Scale
wmake -f H:\tmp\UTIL-WPS-Scale\Util-WPS-Scale.mk -h -e
wcc386 SCALE.C -i="G:\WATCOM/h;G:\WATCOM/h/os2" -w4 -e25 -zq -od -d2 -6r -bt=os2 -fo=.obj -mf
wlink name Util-WPS-Scale d all sys os2v2 pm op m op maxe=25 op q op symf @Util-WPS-Scale.lk1
Execution complete

The IDE also left the makefiles. Works a bit different then GNU make, includes mk files and lnk files etc, directory listing afterwards,
Code: [Select]
Directory of H:\tmp\UTIL-WPS-Scale

 6-09-24  7:39p         <DIR>    124 ----  .
 6-09-24  7:38p         <DIR>      0 ----  ..
 6-09-24  7:26p           169    124 a---  compile.cmd
 6-09-24  7:39p           262      0 a---  dir.out
 6-09-24  7:26p           114    124 a---  FOO.CMD
 6-09-24  7:26p           146    124 a---  IBMC.CMD
 6-09-24  7:26p           145    124 a---  LINKUP.CMD
 6-09-24  7:26p           298    124 a---  makefile
 6-09-24  7:26p           351    124 a---  README.md
 6-09-24  7:26p         7,408    124 a---  SCALE.C
 6-09-24  7:26p           176    124 a---  SCALE.DEF
 6-09-24  7:26p        59,844    124 a---  scale.ico
 6-09-24  7:30p         8,111      0 a---  SCALE.obj
 6-09-24  7:26p         4,495    124 a---  SCALE.txt
 6-09-24  7:30p         7,140      0 a---  Util-WPS-Scale.exe
 6-09-24  7:30p            17      0 a---  Util-WPS-Scale.lk1
 6-09-24  7:30p         9,648      0 a---  Util-WPS-Scale.map
 6-09-24  7:30p           115      0 a---  Util-WPS-Scale.mk
 6-09-24  7:30p           737      0 a---  Util-WPS-Scale.mk1
 6-09-24  7:30p         7,897      0 a---  Util-WPS-Scale.sym
 6-09-24  7:30p           418      0 a---  Util-WPS-Scale.tgt
 6-09-24  7:31p           292      0 a---  Util-WPS-Scale.txt
 6-09-24  7:30p           254      0 a---  Util-WPS-Scale.wpj
 6-09-24  7:26p           236    124 a---  WAT.CMD
 6-09-24  7:26p         <DIR>    124 ----  wiki
       25 file(s)     108,273 bytes used

Try it using the IDE, File-->New Project, name it, then Sources-->New Source and browse to SCALE.C.
Then Targets-->New Target, and choose PM app etc, then press F5.
This will give you the basic commands to build.
If you want to use GnuMake, you can see the needed commands from the log to adapt the makefile. You could have multiple targets in the makefile, one for GCC and one for OW or two makefiles.
From the IDE you can also adjust the build flags etc, or read the documentation.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5040
  • Karma: +114/-1
    • View Profile
Re: Compiling PM Samples with OpenWatcom
« Reply #2 on: June 10, 2024, 05:05:32 am »
Quick adaption of the log to GnuMake,
Code: [Select]
# nmake makefile
#
# Tools used:
#  Compile::Watcom Resource Compiler
#  Compile::GNU C
#  Make: GNU make
all : scale.exe

scale.exe : scale.obj
wlink name Util-WPS-Scale d all sys os2v2 pm op m op maxe=25 op q op symf FIL SCALE.obj

scale.obj : scale.c
wcc386 SCALE.C -i="G:\WATCOM\h;G:\WATCOM\h\os2" -w4 -e25 -zq -od -d2 -6r -bt=os2 -fo=.obj -mf

clean :
rm -rf *exe *res *obj

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4997
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM Samples with OpenWatcom
« Reply #3 on: June 10, 2024, 11:12:54 pm »
Thanks Dave, it compiled (and it runs) with the makefile you posted here.

Just one question, any idea how do you add the "bldlevel information" that is on "SCALE.DEF" to be included on the .exe ?

I will keep testing the OpenWatcom IDE too.

Regards

Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5040
  • Karma: +114/-1
    • View Profile
Re: Compiling PM Samples with OpenWatcom
« Reply #4 on: June 11, 2024, 01:23:41 am »
This is sort of how I did with the screensaver. You need https://88watts.net/download/addtofile-1.03.zip, on your path or use the full pathname. With wmake there is a .before to run shell commands at the beginning of the build, have to look better at Gnu Make for similar. For now I adjusted compile.cmd like so,
Code: [Select]
rm -rf description.lnk
call AddToFile.cmd description.lnk,option description,BLDLEVEL,OS2World,1,Util-WPS-Scale
make -f makefile.wcc 2>&1 |tee make.out

and added @description to the wlink line in the makefile, not sure if it matters where, I added it just before the FIL SCALE.obj directive.
Code: [Select]
wlink name Util-WPS-Scale d all sys os2v2 pm op m op maxe=25 op q op symf @description FIL SCALE.obj

Code: [Select]
H:\tmp\UTIL-WPS-Scale>bldlevel Util-WPS-Scale.exe
Build Level Display Facility Version 6.12.675 Sep 25 2001
(C) Copyright IBM Corporation 1993-2001
Signature:       @#OS2World:1#@##1## 10 Jun 2024 16:07:17     ARCAOS-444::::::@@Util-WPS-Scale
Vendor:          OS2World
Revision:        1.00
Date/Time:       10 Jun 2024 16:07:17
Build Machine:   ARCAOS-444
File Version:    1.0
Description:     Util-WPS-Scale

The line in compile.cmd can be adjusted of course, see addtofile.cmd. You could also directly add something like the contents of description.lnk to the makefile too, just that addtofile.cmd gets the date, time and machine dynamically.


Andi B.

  • Hero Member
  • *****
  • Posts: 867
  • Karma: +13/-2
    • View Profile
Re: Compiling PM Samples with OpenWatcom
« Reply #5 on: June 11, 2024, 09:31:31 am »
Just one question, any idea how do you add the "bldlevel information" that is on "SCALE.DEF" to be included on the .exe ?
IMO the usual way is to add the description (bldlevel string) in the .def file and link this with the linker call. Or define in directly with the linker call (option description).

F.i. a line in .def looks like 'option    description @buildlevel.txt' where buildlevel.txt holds the current information (usually updated with a script to add current build date/time). One watcom project come to my mind - 4os2. I would compile it and look at the output to see how it exactly works. (quick copy paste from master.mif there wlink $(lflags) @xxxx.def file { $(4os2objs) }. Unfortunately 4os2 build files are a bit strange and hard to read.

wlink ... option description @..\buildlevel.txt file xx.obj or
wlink ... option description 'My buildlevel in proper format' ...  should work