Porting BSD code from the NetBSD share: 1. Discovered sources for shareware code to ftp over. gopher sources from gatekeeper.dec.com look here first! gatekeeper seems to have almost everything, and it has a nifty indexing and searching mechanism from within ftp "site index ") NetBSD sources from col.hp.com in mirrors/NetBSD/NetBSD-0.9/source/src* gnu sources from prep.ai.mit.edu bootp from lancaster.andrew.cmu.edu (128.2.13.21) 2. Created /bsd directory to contain all BSD specific changes required to compile and run the code. Sources are in /bsd/src and have been kept in the same sub-directories they unpacked in. 3. Copied sources to my workstation, unpacked on the workstation and moved over to the 3K from there. 4. Initial efforts were focused on getting rlogin running on a 5.0 system. Since rlogin is an r-service, the rcmd code had to be located, moved over, compiled and running. 5. rcmd needed some hfiles, so I created /bsd/include and /bsd/makefile.inc to have a standard compile environment. /bsd/makefile.inc is included into all the makefiles and establishes all the necessary flags such as -I/bsd/include and -lbsd. The main change to rcmd is to GETPRIVMODE before attempting to bind to privileged ports. The /bsd/include files need to include the normal include files prior to inserting their own definitions. This helps reduce the conflicts and helps make it obvious what has been changed. As an example, /bsd/include/time.h looks like this: #include "/usr/include/time.h" #define utimes(a, b) utime((a), (b)) It is important to fully qualify the /usr/include files since the /bsd/makefile.inc forces /bsd/include to have precedence and doing something like #include would actually cause an include loop that fails. 6. Since rcmd is a C library function, a new library had to be created. /bsd/src/lib was created to contain library sources that were ported as dependencies cropped up. rcmd was the first entry to the library and /usr/lib/libbsd.a was the location of the library. The -lbsd will find the library in either /lib or /usr/lib. 7. Programs relying on the rcmd library function need to have PM. PM programs may not reside in the HFS. After numerous failed attempts, I discovered the -W option to the c89 command. I standardized this in the /bsd/makefile.inc as LFLAGS = -WL,cap=ph,pm,ia,ba and add it to the c89 for privileged compiles. The makefile takes either a PROG or PRIVPROG "parameter" and compiles differently depending on which one comes in. The PRIVPROG "parameter" specifies the -o name separately from the source names to simplify handling. This allows me to have an rlogin symbolic link to /RLOGIN/PUB/RLOGIN without having to jump through hoops to not clobber things on remakes. In this example, PRIVPROG = /RLOGIN/PUB/RLOGIN and the source is rlogin.c. 8. Getting listings is a royal pain. The c89 command takes the -P option to produce a listing, but chokes if it exists. The LISTFILE "parameter" was created to specify the name of a file for listings and automatically adds -P $(LISTFILE) to the compile options. The /bsd/makefile.inc will -callci purge $(LISTFILE) before calling c89. 9. Several bugs were encountered in make/c89/c. Make wasn't invoking shell scripts automatically since the SHELLMETAS value shipped with the release was incorrect in /etc/startup.mk. It should be: SHELLMETAS := ;*?"<>|()&][$$\#`' c89 was having a terrible time with double quotes. Since c89 is an interpreted script using the callci interface to the CI, its double quotes need to be CI escaped as "". I added code to /etc/c89.ccg to process this: ################################################################## # # Process out the quotes problem with the CI. # temp = CCArgs; CCArgs = ""; for (zz in temp) do if (zz == "\"") CCArgs |= "\"\""; else CCArgs |= zz; fi done The c89 script invokes the C compiler as xeq ccomxl.pub.sys; info="args"; parm=7 but the ccomxl program can only take 279 characters of info this way. Don't bother with the CI variable to pass options, it's appended to the info and the limit is _still_ 279 characters. I've filed an SR to get this fixed. In any case, when the options grow past 279, there's nothing for it but to go modify source files and make sure they all include the #define statements you need. Luckily, _most_ of these sources include a single standard header file of their own where this can be placed. 10. Several functions needed workarounds. These have been placed in /bsd/src/lib/libc, mostly in the gen subdirectory. Examples include a wait3() wrapper function to call waitpid() and translate the results. There are currently about 50+ functions in /usr/lib/libbsd.a. In many cases, the source for these functions came from NetBSD, several others came from Steve Hoogheem's workaround library, some were invented here. 11. The rlogin code compiled and ran after all the preceding stuff, but it still had a problem interacting with the terminal. Since two processes are attempting to share the terminal, one reading and one writing, there is a significant contention issue. The writes won't "pass through" the reads naturally on MPE until the GTI gets implemented. This required special code to call the operating system directly and bypass the read() and write() functions. It was difficult to discover how to make this work, in the end it really didn't work. Pre-emptive writes appears to be broken on MPE/iX since it won't actually pass through the read. I ended up doing SENDIO(), RENDESVOUSIO(), sleep(40ms), loop if not done. Naturally, the performance of this polling mechanism isn't great. On the other hand, I did manage to get the writes to pass through the reads 99.9% of the time. 12. The ranlib command should be aliased to touch e.g. ln /bin/touch /bin/ranlib ----------------------------------------------------------------------------- This document was written quite a while ago now. Since then, there have been a lot of ports put on JAZZ. The libbsd.a library is also available there to make porting much easier, please do not use the old version of the library distributed with LYNX. The MOVER (renamed from RYDER) utility is available to move files around _without_ losing the MPE attributes. The include files have been moved to /usr/include/bsd from /bsd/include. The preferred compile feature-test macro is __mpexl since the compiler will define this for you by default. Many people are still using _MPEXL_SOURCE and there was some discussion about what's best. I don't care what's used, but it's easier if we all use the same thing. Please don't make up any _new_ names!