Hi Thomas,
If everyone followed the "rules," set forth in the MDL
Programmer's Reference Guide, compiling an MDL
application would be the same for all platforms.
Unfortunately, not everyone does this. :( Developers
always manage to find platform specific idiosyncracies
and exploit them (knowingly or not). So, keeping in mind
that "complete and correct" instructions is an impossible
goal when it comes to porting, I can give you a bunch of
pointers to handle common errors:
Pointer
#0:
-
Get your MPW environment set up properly, define the
correct Bentley environment variables, and make sure
you can build a 'proper' Bentley example.
For instance, if you should be able
to build $(MS)/mdl/examples/trumpet/trumpet.mke before
trying to build an mdl application that may have
platform incompatibilities. The
MPW shell available on Select Stream includes an MPW
Startup Script that will instruct you on which
environment variables to set.
Pointer
#1:
-
Remove any platform specific paths in the MDL's
makefile.
These tend to look like:
baseDir =
c:/mdlapps/myapp/
or a relative path using the dos
and unix ".." (parent directory) convention
like:
sourceDir =
$(baseDir)/source/
includeDir = $(sourceDir)/../include/
The best solution to these makefile
path problems is to redefine the "root" macro using a
platform (and location) independent mechanism, and
then redefine the problematic macros in terms of this
root directory.
BMAKE has the builtin macro "_MakeFilePath" to help
you set this root directory.
Bentley makefiles use this macro to define a root
directory for an MDL application's source:
baseDir =
$(_MakeFilePath)
and then define any other macros in
terms of that macro:
sourceDir =
$(baseDir)source/
includeDir = $(baseDir)include/
that way, there are no hardcoded
paths to an absolute location. Also, there are no
platform specific paths in your makefile.
Pointer
#2:
-
Remove any platform specific paths in the MDL's
source.
Occasionally there will be include
statements along the lines of:
#include
"..\include\structs.h"
in a source file. This should be
changed to:
#include
"structs.h"
and the compiler should be
instructed to add the "include" directory to its file
search path.
You need to add this instruction to your makefile
before the dependency line for the source file. For
native C, you can use a special .mki file for adding a
directory to the C compiler's search path:
dirToSearch =
$(baseDir)include
%include
cincapnd.mki
where "cincapnd.mki" stands for "C
Include Append". For MDL, you
can add the like this to the makefile before the
dependency line for your object file:
altIncs +
-i$(baseDir)include
so, when the .MC.MO rule executes
(from mdl.mki):
.(mc,m,c).mo:
$(msg)
>
$(o)make.opt
-c
-o$@
-i${publishInc}
-i${publishIdsInc}
-i${stdlibInc}
%if defined
(privateInc)
-i${privateInc}
%endif
-i${genSrc}
$(platformOpts)
$(altIncs) <--- altIncs macro
$(compOpts)
$(moreMdlCompileOpts)
$<
<
$(MCompCmd) @$(o)make.opt
~time
the "-i$(baseDir)"
is added into the make.opt file for mcomp.
Pointer
#3:
-
Remove platform/compiler specific arguments added to
the command line that cause errors on your
platform.
When a makefile adds an argument to
the C compiler that isn't recognized by your C
compiler, you'll have to change those.
Instead of having a line
like:
cdefs +
/DDEBUG
which may only work for the
Microsoft C compiler, use the Bentley supplied .mki
file to add predefines to the C compiler in a platform
independent manner:
nameToDefine=DEBUG
%include cdefapnd.mki
where "cdefapnd.mki" stands for "C
Define Append".
If you would be interested in
collecting questions or know of other common problems, I
will attempt to answer them (time and knowledge
permitting, of course!). If you want to make a faqomatic,
that'd be cool.
good luck,
mike.mccreavy@bentley.com