In the last post I showed you that vamos is already able to call the SAS C Compiler 6.58 and compile some example source files. In the last few days I added the missing parts to vamos to support smake, too. Namely, calling sub processes with SystemTagList() was added and lots of bugs fixed. With smake at hand I am able to compile some real SAS C projects with an smakefile describing the build.
In this post I will show you how you can build the magPLIP network driver I used in my plip2slip project directly on your Mac without using an Amiga machine emulator like P-UAE…
1. Setup Build Environment
- I assume that you have installed the SAS C compiler ready to use for vamos as described in my last post
- The netword driver we will compile needs the Amiga Network Driver Includes (i.e. SANA-II headers)
- Download the AmiTCP-SDK-4.3.lha from aminet
- You can unpack it on your Mac with the lha command available in MacPorts (call: sudo port install lha if the tool is still missing on your machine):
> cd ~/amiga/src > lha x ~/Downloads/AmiTCP-SDK-4.3.lha
- Now we need to setup assigns in vamos so the build can reach the new network includes. My ~/.vamosrc config file looks like this:
[volumes] wb310=~/amiga/wb310 sc=~/amiga/shared/sc net=~/amiga/src/AmiTCP-SDK-4.3 [assigns] include=sc:include lib=sc:lib t=root:tmp c=wb310:c netinclude=net:netinclude netlib=net:netlib includeasm=sc:include [path] path=sc:c,wb310:c [vamos] quiet=True ram_size=2048
What’s new here?
- First I added a new volume in vamos called net: where the SANA-II includes reside. It points to the native path we just unpacked.
- Some new assigns were added: netinclude and netlib point inside our new net: volume
- Another assign called includeasm: was necessary as the following build requires it. It simply points directly to the include directory in the SAS C installation.
- Finally, a new section called vamos was introduced. This section holds defaults for common option that were currently only available via command line:
- The quiet switch is similar to the -q command line option and suppresses information about un-implemented Amiga OS calls in vamos
- The ram_size sets the RAM for the AmigaOS emulation of vamos to 2 MiB. Similar to the -m command line option. This ensures that we do not run out of memory during compilation.
2. Grab the Source
- Next we download the source for magPLIP from aminet
- I unpacked the source in a build directory:
> mkdir ~/build > cd build > lha x ~/magPLIP38.1.lha > ls magplip/Â Â Â Â Â magplip.info
- I also downloaded the plip2slip-0.1 source archive because it contains a patch for the driver we are going to build
- Unpack this, too:
> unzip ~/Downloads/plip2slip-0.1.zip > ls magplip/      magplip.info  plip2slip-0.1/
- Next, we patch the source:
> patch -p0 < plip2slip-0.1/contrib/magplip/magplip.patch patching file magplip/source/magplip_rev.h patching file magplip/source/magplip_rev.i patching file magplip/source/magport.asm patching file magplip/source/server.c patching file magplip/source/smakefile
- That’s it, now the source is ready to be compiled!
3. Perform the Build
- The build itself is now rather unspectacular… It simply works 🙂
> cd magplip/source > vamos smake all_opt SAS/C_SMAKE 6.58 (27.12.96) Copyright (c) 1988-1995 SAS Institute, Inc. sc:c/sc INCDIR="INCLUDEASM:" INCDIR="include:" INCDIR="netinclude:" VERBOSE DEFINE MAGPLIP=1 OBJECTNAME MAGrt.o rt.asm No default scoptions file found SAS/C Amiga Compiler 6.58 Copyright (c) 1988-1995 SAS Institute Inc. asm "-dMAGPLIP=1" -iINCLUDEASM: -iinclude: -inetinclude: -oMAGrt.o rt.asm ... SLINK Complete - Maximum code size = 8824 ($00002278) bytes Final output file size = 8940 ($000022ec) bytes
- If everything went fine then the resulting binary resides in the magplip/devs/networks folder:
> ls ../devs/networks/magplip.device.000 -rwxr-xr-x 1 chris staff 8940 18 Dez 18:16 ../devs/networks/magplip.device.000*
- Ah! A fresh build of the driver… Now let’s create a 68020 version, too:
> vamos smake CPUSUFFIX=020 all_opt ... > ls ../devs/networks/magplip.device.020 -rwxr-xr-x 1 chris staff 8872 18 Dez 18:21 ../devs/networks/magplip.device.020*
- Finally, you can compare your new builds with the reference compiles I did on P-UAE and that are available in the plip2slip release:
> cmp ../devs/networks/magplip.device.000 ../../plip2slip-0.1/contrib/magplip/magplip.device.000 > cmp ../devs/networks/magplip.device.020 ../../plip2slip-0.1/contrib/magplip/magplip.device.020
- It really works! Same output generated on vamos!!
- Now its time to read the plip2slip docs on how to actually use the driver on your real machine…
4. Some additional Notes
- While vamos now supports the typical builds on SAS C even with smakefiles, there are still things missing. Most notably, the internal Shell commands like Echo are not emulated yet. So the default/help rule in our project’s smakefile does not work. But the internal Shell commands and a more complete support for the typical CLI commands will be the next on my TODO list…
- Compared to last vamos versions I optimized the loading of native libraries (most notably sc1.library and sc2.library of sc) and that gave a real speed boost when calling the compiler.
- To better judge where the bottlenecks in the vamos emulation are, I added profiling support for the library calls. You can use the new -P switch and give the libraries you want to get detailed information for:
> vamos smake clean # first clean our build again ... > vamos -v -P exec,dos smake all_opt # now build with profiling on ... 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â 'dos.library' Function Call Profile 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Close: #Â Â Â Â 251Â total=Â Â Â 0.0115Â per call=Â Â Â 0.0000 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â CurrentDir: #Â Â Â Â Â 45Â total=Â Â Â 0.0009Â per call=Â Â Â 0.0000 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â DateStamp: #Â Â Â Â Â Â 9Â total=Â Â Â 0.0005Â per call=Â Â Â 0.0001 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â DeleteFile: #Â Â Â Â Â 12Â total=Â Â Â 0.0033Â per call=Â Â Â 0.0003 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â DupLock: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0003Â per call=Â Â Â 0.0001 18:34:09.103Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Examine: #Â Â Â Â Â 85Â total=Â Â Â 0.0158Â per call=Â Â Â 0.0002 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FilePart: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0002Â per call=Â Â Â 0.0001 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FreeArgs: #Â Â Â Â Â Â 6Â total=Â Â Â 0.0017Â per call=Â Â Â 0.0003 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â FreeDeviceProc: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0005Â per call=Â Â Â 0.0002 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â GetDeviceProc: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0008Â per call=Â Â Â 0.0003 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Input: #Â Â Â Â Â 20Â total=Â Â Â 0.0001Â per call=Â Â Â 0.0000 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IoErr: #Â Â Â Â Â 94Â total=Â Â Â 0.0006Â per call=Â Â Â 0.0000 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Lock: #Â Â Â Â Â 77Â total=Â Â Â 0.0163Â per call=Â Â Â 0.0002 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â MatchEnd: #Â Â Â Â Â Â 6Â total=Â Â Â 0.0019Â per call=Â Â Â 0.0003 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â MatchFirst: #Â Â Â Â Â Â 6Â total=Â Â Â 0.0055Â per call=Â Â Â 0.0009 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â MatchNext: #Â Â Â Â Â Â 6Â total=Â Â Â 0.0002Â per call=Â Â Â 0.0000 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Open: #Â Â Â Â 352Â total=Â Â Â 0.0850Â per call=Â Â Â 0.0002 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Output: #Â Â Â Â Â 37Â total=Â Â Â 0.0003Â per call=Â Â Â 0.0000 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â ParentDir: #Â Â Â Â Â 62Â total=Â Â Â 0.0061Â per call=Â Â Â 0.0001 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â ParsePattern: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0006Â per call=Â Â Â 0.0002 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â PutStr: #Â Â Â Â Â Â 9Â total=Â Â Â 0.0005Â per call=Â Â Â 0.0001 18:34:09.104Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Read: #Â Â Â Â 617Â total=Â Â Â 0.0273Â per call=Â Â Â 0.0000 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ReadArgs: #Â Â Â Â Â Â 6Â total=Â Â Â 0.0038Â per call=Â Â Â 0.0006 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Rename: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0013Â per call=Â Â Â 0.0004 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Seek: #Â Â Â Â 155Â total=Â Â Â 0.0048Â per call=Â Â Â 0.0000 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â SetIoErr: #Â Â Â Â Â Â 3Â total=Â Â Â 0.0000Â per call=Â Â Â 0.0000 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â SetProtection: #Â Â Â Â Â Â 4Â total=Â Â Â 0.0009Â per call=Â Â Â 0.0002 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â SystemTagList: #Â Â Â Â Â 16Â total=Â Â Â 0.0486Â per call=Â Â Â 0.0030 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â UnLock: #Â Â Â Â 108Â total=Â Â Â 0.0026Â per call=Â Â Â 0.0000 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Write: #Â Â Â Â 277Â total=Â Â Â 0.0152Â per call=Â Â Â 0.0001 18:34:09.105Â Â Â Â Â Â prof:Â Â INFO:Â sum total=0.2570 18:34:09.105Â Â Â Â Â Â main:Â Â INFO:Â done 3218549052 cycles in host time 14.9556s -> 174.60 MHz m68k CPU 18:34:09.106Â Â Â Â Â Â main:Â Â INFO:Â code time 14.9556s (81.13 %), trap time 3.4781s (18.87 %) -> total time 18.4337s 18:34:09.106Â Â Â Â Â Â main:Â Â INFO:Â exit code=0 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â 'exec.library' Function Call Profile 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â AllocMem: #Â Â Â 1266Â total=Â Â Â 0.1440Â per call=Â Â Â 0.0001 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â AllocVec: #Â Â Â Â Â 39Â total=Â Â Â 0.0024Â per call=Â Â Â 0.0001 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â CloseLibrary: #Â Â Â Â Â 85Â total=Â Â Â 0.0129Â per call=Â Â Â 0.0002 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FindTask: #Â Â Â Â 137Â total=Â Â Â 0.0024Â per call=Â Â Â 0.0000 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Forbid: #Â Â Â Â 137Â total=Â Â Â 0.0004Â per call=Â Â Â 0.0000 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FreeMem: #Â Â Â 1318Â total=Â Â Â 0.4038Â per call=Â Â Â 0.0003 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FreeVec: #Â Â Â Â Â 39Â total=Â Â Â 0.0059Â per call=Â Â Â 0.0002 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â GetMsg: #Â Â Â Â 650Â total=Â Â Â 0.0082Â per call=Â Â Â 0.0000 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â OpenLibrary: #Â Â Â Â Â 85Â total=Â Â Â 0.1304Â per call=Â Â Â 0.0015 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Permit: #Â Â Â Â 137Â total=Â Â Â 0.0004Â per call=Â Â Â 0.0000 18:34:09.107Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â PutMsg: #Â Â Â Â 650Â total=Â Â Â 0.0794Â per call=Â Â Â 0.0001 18:34:09.108Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â RawDoFmt: #Â Â Â Â Â 11Â total=Â Â Â 0.0006Â per call=Â Â Â 0.0001 18:34:09.108Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â SetSignal: #Â 103942Â total=Â Â Â 0.9651Â per call=Â Â Â 0.0000 18:34:09.108Â Â Â Â Â Â prof:Â Â INFO:Â Â Â Â Â Â Â Â Â Â Â Â Â Â StackSwap: #Â Â Â Â Â 34Â total=Â Â Â 0.0030Â per call=Â Â Â 0.0001 18:34:09.108Â Â Â Â Â Â prof:Â Â INFO:Â sum total=1.7587
- That’s it for today! Enjoy vamos and if you already use it for doing your own “cross”-compiles then I’d really like to hear from your projects…
Very cool! Looking forward to see how this develops.
Good work!