Building platform-specific programs from the same source files

When a program needs to work on multiple hardware platforms, often times the source files are identical except for one or more assembly language routines that vary from processor to processor. In cases like this, you can create Select One subprojects that contain the processor-specific files so you can build the same program for multiple target processors.

Consider the following example. Suppose a program for SH processors depends on the following files:

indprogram.c
indprogram.h
traps.sh ;SH assembly language file

Suppose the same program compiled for Alpha depends on these files:

indprogram.c
indprogram.h
traps.alp ; Alpha assembly language file

You can use a Select One subproject, traps.bld, to build a program that uses only the processor-specific file, traps.sh or traps.alp, for the specified target processor.

If you have multiple files that are specific to a single processor, create multiple Select One subprojects. Suppose the program in the above example also uses bdriver.sh and bdriver.alp. In this case, you would need another Select One subproject, bdriver.bld.

To define your project for multiple platforms

  1. Create the program that gets compiled and linked.
  2. Add to the program all of the source files except the processor-specific assembly files.
  3. Add to the program a Select One subproject that contains the processor-specific assembly files:
    1. Create a build file for the subproject. For example, create traps.bld.
    2. With the new build file highlighted, choose Project > Options for Selected Files... .
    3. Go to the General tab.
    4. In the Type: field, select Select One.
    5. In the Source Window, add to this new Select One build file the various processor-specific assembly files for the program. In the example above, traps.bld contains two files: traps.sh and traps.alp

To build a platform-specific program

Once you have defined your project for multiple platforms using a Select One subproject:

  1. Set the Builder's Target: field to specify the target processor for the current build. For details about setting the target, see "To set your target".
  2. With the program as the base project and highlighted, choose Project > Options for Selected Files... .
  3. Go to the Configuration tab.
  4. In the Select: field, enter one or more of the file extensions needed when building for this particular target. That is, enter the extensions of the files that apply specifically to the target processor. In the example above, if you are building your program for SH, enter sh in the Select: field. If you are building your program for Alpha, enter alp in the Select: field.
  5. Start the build.

When you start the build and each time the Builder reaches a Select One subproject, it chooses the first file in the list that matches one of the extensions specified in the Select: field of the program. The other files in the Select One subproject are ignored.

Related topic:


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.