Tonight, I investigated how to fix the issue of the Main code segment being too large for a normal build/link without using
--model far which may be causing compatibility problems. There is a
#pragma segment segname directive that I thought could work to break up the segments. However, every function needs a directive before it to put it in a segment! That would require way too many code edits. After some research, I found out that MPW's compiler will also take a
-seg segname option to assign the object code to the specified segment name. This is the way to specify a segment for an entire source file.
After reading a bit of
Building and Managing Programs in MPW, I realized my Makefile is not using any of the complex features available in MPW. So, I incorporated some path constants and Directory Based Dependency Rules, and eliminated a lot of the hard-coded paths and dependencies in my make file.
I figured out that the key to using Directory Based Dependency Rules and code segments in the Makefile is to add a modified extension to the list of object files you want to put in a separate code segment. Then, add a new default build rule for that extension. Code segments are way easy now! I can now remove the
--model far option which seems like it might be incompatible with older Macintosh System versions. The main segment with the PPP interface comes in about 31K and the rest of lwip is just 28K, each fitting nicely in a code segment.
Here is an example section of an MPW Makefile (new extension in yellow and segment name option in blue):
ObjFiles-68K = "{SrcDir}ip_frag.c.o" ∂
"{NetISrc}etharp.c.n.o"
### Default Rules ###
{NetISrc} ƒ {NetISrc} {PPPISrc}
{SrcDir} ƒ {CoreSrc} {IPV4Src} {APISrc}
.c.o ƒ .c {•MondoBuild•}
{C} {depDir}{default}.c -o {targDir}{default}.c.o {COptions}
.c.n.o ƒ .c {•MondoBuild•}
{C} {depDir}{default}.c -o {targDir}{default}.c.n.o {COptions} -seg NetIf