Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Porting UNIX apps with makefiles

Posted on 1997-04-24
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! :)
Question by:thalen
  • 2

Accepted Solution

heller earned 400 total points
ID: 1291440
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.

Author Comment

ID: 1291441
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.  )


Expert Comment

ID: 1291442
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.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question