We help IT Professionals succeed at work.

Porting UNIX apps with makefiles

thalen asked
Medium Priority
Last Modified: 2013-12-26
Yes, you guessed it.  I'm trying to figure out how the heck
to port a UNIX app (actually a library) to the Mac, Code
Warrior style.  I'm a moderately-experienced UNIX programmer
but I don't know make terribly well (most of my coding was
done with pre-set-up makefiles or I made very simple, straightforward makefiles.).  I'm a very beginning Mac
programmer, but I've got good books, so I'm not having too
much trouble on that end of things.

I realize this is rather a large question for this venue.
Therefore, any kind of documentation (books, web pages,
heiroglyphics on the walls of ancient Egyptian temples) that
someone could point me towards would be wonderful.  If not,
perhaps a brief description of the process, along with such
specifics as would be necessary in order to keep me from
having to pull all of my hair out repeatedly as I am doing
right now.

In case you're wondering, the library is SSLeay, the free
secure-sockets library.  I'm trying to compile it using
GUSI, the Mac sockets implementation.  If by some bizarre
wild coincidence someone has already ported it, send it my
way! :)
Watch Question

Well, Code Warrior's IDE does not use Makefiles like is typically
used with UNIX.  Code Warrior uses a "Project File".  Actually it
is much like your "pre-set-up makefiles".  They have various files called "stationary", which are generic style project files.

You find a stationary file that is much like what your project is, such as a "MacOS 68K Library" or a "PowerPC Application", etc. And load this into the IDE and then modify it by adding in
your source files (C, C++, assembler, resources, etc.) and adjust
the path info and so on in the Preferences section.

I am in the process of porting a UNIX shareware app to the Mac and it is not too hard.  The main gotcha is you need separate project files for 68K and PowerPC and there is no easy way to make sure both project files contain all of the source files -- I got bit by that problem -- with Makefiles you can use one makefile for multiple targets, so this sort of problem can be avoided.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


I know what a project file is.  So what you're saying is 'just
set up the Mac end with a project file and add all of the files
in the source code into the project file and make it and everything should work'?  That sounds suspiciously utopian.

(I say that, having tried exactly that approach and having come
up with ~3500 compiler errors.  I'm looking for some general
pointers on the porting.  You know, the 'okay it doesn't compile
let's see why not' kind of stuff.  )

Ok, your question was vauge, sorry.  If I knew what sort of compiler errors you are getting I might be able to offer more specific help.  *I* don't know of any magic documentation for Project files.  All I can say is make sure things are sane with your project file's preferences. Things like the path to the include files and make sure you are building the right sort of thing (application, library, etc.)

You should only add the true source files -- ones that get compiled -- .c & .cc, assembler source, and resource files (the resources only make sense for applications).  The header files don't get added, but your preferences need to have the path(s) to the includes setup properly (make sure you DON'T remove the path to the system include files).  There is also a preference for how to deal with "#include <foo.h>", where foo.h is one of your include files.  You need to look closely at your project's preferences, important parts are the language settings (Require Function Prototypes is normally on -- if the code is old style K&R C, you will likely get tons of errors), and look at the settings under the "Project" setting -- make sure your Project Type is what you expect (Library, Application, etc.),  your access paths are what you expect -- check the state of the "Treat #include <...> as #include "..." -- by default this is off.  Most UNIX C compilers merge all of the include search paths together (i.e. system ones (/usr/include/...) and user ones (-Ipath)) and will search for #include <...> under this combined set of paths. Code Warrior does not.  Instead, #include <...> are only searched for in the system paths and #include "..." are searched in the user paths.  If your code is typical UNIX C, it is probably expecting -I<path> flags being passed to the compiler and is doing #include <...>, without the Treat ... check box on, these include files are not being found, so what they define is no happening.  Also check in the target section to be sure Code Warrior knows how to properly process your files.  

Note: MacOS uses case insensitive file name matching.  UNIX is case sensitive.  Under UNIX, some people use a capital C for C++ as in foo.C.  On the Mac, this is no different from foo.c, a plain C file.  Code Warrior will pass this to the C compiler, not the C++ compiler.  All of your C++-isms will fail. Opps.  Rename the file to foo.cc and replace foo.C with foo.cc in the project file list.

If you use some odd extension for source files, you need to add this extension to the list of known extensions.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.