I thought that I would find a sample program to port as an example for this column, but over a weekend, as I downloaded program after program, I was just more and more impressed with the Linux C library as program after program compiled with simple tweaks like changing the Makefile to use gcc instead of cc and changing paths to executables. I finally found a program that might give some people problems porting, an editor called Freyja.
I copied the supplied makefile.unx to Makefile, and edited the Makefile. I changed CFLAGS to -O2 to use the highest level of optimization from GCC, and typed make at the command line. GCC complained that TIOCGETP, TIOCSETP, and RAW were undefined. This means that Freyja is written with BSD in mind. There did not appear to be any #define's that I could make to change Freyja's behavior to SYSV or POSIX, either.
So, following the steps in the GCC-FAQ, I added -I/usr/include/bsd to the CFLAGS line, and -lbsd to the link line (called FXLINK in Freyja for some strange reason; it's usually called LDFLAGS), and ran make again.
That was all that was required to “port” this bsd-oriented program. I had to read the documentation to find out that I needed to call it with the arguments “-kT -s29” to tell it how to write to the screen and read from the keyboard, or that I needed to compile an equivalent change into the resource file that Freyja uses, but it was very simple.
Freyja is written by Craig A. Finseth, and is available via ftp from mail.unet.umn.edu, or if you don't have ftp access, via U.S. mail. Quoting the README:
Diskette: Send the author blank diskettes:
3 1/2" (1.44 MB), or
3 1/2" (720 KB)
and a SASE or enough stamps to cover return postage plus a dollar or so (so that I can buy a diskette mailer). Or you can just send me about US\$5.00 in check, stamp, whatever and I will furnish the diskette(s) and mailer. Non-US people can send me four 1.44 MB 3 1/2" diskettes in lieu of money. (More money is always nice, but please don't feel obligated in any way.)
The address is: Craig Finseth1343 LafondSt. Paul, MN55104, USA
Here's your chance to contribute! If you have difficulties porting a general Un*x application to Linux, please either send email to firstname.lastname@example.org or send snail mail to Programming Tips, Linux Journal, P.O. Box 85867, Seattle, WA 98145-1867, with a description of how to get the program via the internet, or with a copy of the application enclosed on floppy, 150MB QIC tape, or standard DAT, and with a detailed explanation of what you have tried in your attempt to port it, and I may try it myself, especially if it looks like it will make worthwhile material for this column.
|Privacy Is Personal||Jul 02, 2015|
|July 2015 Issue of Linux Journal: Mobile||Jul 01, 2015|
|July 2015 Video Preview||Jul 01, 2015|
|PHP for Non-Developers||Jun 30, 2015|
|A Code Boot Camp for Underprivileged Kids||Jun 30, 2015|
|Comprehensive Identity Management and Audit for Red Hat Enterprise Linux||Jun 29, 2015|
- Privacy Is Personal
- PHP for Non-Developers
- July 2015 Issue of Linux Journal: Mobile
- Linux Kernel 4.1 Released
- Secure Server Deployments in Hostile Territory
- Django Templates
- Comprehensive Identity Management and Audit for Red Hat Enterprise Linux
- A Code Boot Camp for Underprivileged Kids
- Attack of the Drones
- The AtoMiC Toolkit!