www.delorie.com/djgpp/doc/ug/compiling/portgnu.html   search  
Porting GNU software and Unix programs to DJGPP

Porting Unix packages to DOS would have been a nightmare if it wasn't for DJGPP. Fortuntely, DJGPP provides replacements for many UNIXish functions making life much easier ;-). The rest of this document focusses mainly on GNU packages. That's where DJGPP came from, anyway...

The first step in porting a GNU package is to get the configure scripts working. Generally, most configure scripts run without problems under Win 9x so it's a good idea to start off the port under a Windows environment. To make the configure script run on DOS, you'll need to keep in mind some of the limitations:
 

Keeping these in mind, you'll need to play around with the configure script so that it runs on DOS. Changing the configure scripts manually is a pain and isn't recommended for good reasons. So you'll most probably want to write an sed script that changes the offending filenames into 8.3 format. For example, if you had config.h.in, you'd want to change that to config.h-in to make it compatible. Also, there exists certain rules which are generally followed while renaming a file. A quick scan through some of the ports in v2gnu directory of your local djgpp mirror should help. Since symlinks aren't fully supported, at least in v2.03, you'll have to replace all occurences of "ln -s" to "cp -pf". Any file beginning with a dot example .emacs) would be changed to an underscore followed by the name. In this case, .emacs would be changed to _emacs.

A good place to start would be to have a look at the sources of the "indent" package which is rather simple. If you want something more complex, you could try looking into textutils or Sh-utils.

The next step is to modify the sources. Generally, most packages will simply compile without any problems. But that doesn't mean they are bug-free. You'll need to test them out with respect to the functionality and make the necessary changes. Keep in mind the GNU coding standards.  It would also be useful if you had a look at the autoconf manual. It's a bad practice to merely "#ifdef __MSDOS__" all the code. Some maintainers will simply refuse to accept these changes (assuming you want to add DJGPP support to build it out of the box). You'll have to use feature "#ifdef"S to do the necessary work and ask the maintainer to add a suitable configure time test. Macros that are specific to MSDOS should be put into system.h if the file exists within the sources.

Now, you're almost half done. Make sure it builds correctly from all directories and drives. Note that when you configure, any files created must also go into the right directory. The sources you are trying to configure might reside on a read-only device such as a CDROM, so you may not be able to write anything into the source directories. If this works, you're almost done. If you need more help, you could post to the DJGPP Workers list or the DJGPP list. But make sure you give enough details about the problem.

Also, most packages (which are of moderate size) will have test-suites which may need some modificationin order to run. If such a case exists, you can modify the sources directly without worrying about the red-only devices, etc. Sources distributed on CDROMs should then contain the modified test-suite. This completes it!

It would be a good idea to distribute the sources configured; so make sure you do it before you send them to DJ Delorie for uploading to the DJGPP mirrors.

Well, that was just a short note on porting GNU software! If you think there can be some additional stuff here, you can E-Mail me. Special thanks to Eli Zaretskii for most of the ideas on porting.

Enjoy,
Prashant TR
http://www.midpec.com/

  webmaster     delorie software   privacy  
  Copyright © 2003     Updated Jul 2003