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 email@example.com 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.
|September 2015 Issue of Linux Journal: HOW-TOs||Sep 01, 2015|
|September 2015 Video Preview||Sep 01, 2015|
|Using tshark to Watch and Inspect Network Traffic||Aug 31, 2015|
|Where's That Pesky Hidden Word?||Aug 28, 2015|
|A Project to Guarantee Better Security for Open-Source Projects||Aug 27, 2015|
|Concerning Containers' Connections: on Docker Networking||Aug 26, 2015|
- Optimization in GCC
- Using tshark to Watch and Inspect Network Traffic
- September 2015 Issue of Linux Journal: HOW-TOs
- Problems with Ubuntu's Software Center and How Canonical Plans to Fix Them
- Concerning Containers' Connections: on Docker Networking
- A Project to Guarantee Better Security for Open-Source Projects
- Firefox Security Exploit Targets Linux Users and Web Developers
- Where's That Pesky Hidden Word?
- My Network Go-Bag
- Doing Astronomy with Python