BuildDefaults.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _BUILDDEFAULTS_H_
00014 #define _BUILDDEFAULTS_H_
00015 
00016 #include <BuildDefines.h>
00017 
00018 // To override build options in a local component, include <BuildDefines.h>
00019 // first, then define switches as need, and then include <PalmTypes.h>.
00020 
00021 // Some projects used to have a local copy of a file called "AppBuildRules.h"
00022 // or "AppBuildRulesMSC.h", which was automatically included by <BuildRules.h>
00023 // to override certain system default compile-time switches.  These local
00024 // "prefix" files can still be used.  The project source files should be changed
00025 // to include <BuildDefines.h>, then "AppBuildRules.MSC.h", then <PalmTypes.h>
00026 // instead of the previous <Pilot.h>
00027 
00028 
00029 /************************************************************
00030  * Settings that can be overriden in the makefile
00031  *************************************************************/
00032 
00033 // Must be defined (-d or prefix file) before using.  See comment in <BuildDefines.h>.
00034 // Since it's really important, we cannot simply use a default value for it.
00035 #if !defined(BUILD_TYPE)
00036 #   error BUILD_TYPE MUST be defined.
00037 #endif
00038 
00039 /*
00040 ERROR_CHECK_LEVEL is now obsolete.
00041 */
00042 #ifdef  ERROR_CHECK_LEVEL
00043     #error "ERROR_CHECK_LEVEL is an obsolete build flag! - See BUILD_TYPE instead"
00044 #endif
00045 
00046 #ifndef DEFAULT_LIB_ENTRIES
00047     #define DEFAULT_LIB_ENTRIES 12          // space for 12 libraries in library table
00048 #endif
00049 
00050 // Default to allow access to internal data structures exposed in system/ui header files.
00051 // If you want to verify that your app does not access data structure internals then define
00052 // DO_NOT_ALLOW_ACCESS_TO_INTERNALS_OF_STRUCTS before including this file.
00053 #ifndef DO_NOT_ALLOW_ACCESS_TO_INTERNALS_OF_STRUCTS
00054 
00055 #   define ALLOW_ACCESS_TO_INTERNALS_OF_CLIPBOARDS
00056 #   define ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS
00057 #   define ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS
00058 #   define ALLOW_ACCESS_TO_INTERNALS_OF_FINDPARAMS
00059 #   define ALLOW_ACCESS_TO_INTERNALS_OF_FORMS
00060 #   define ALLOW_ACCESS_TO_INTERNALS_OF_LISTS
00061 #   define ALLOW_ACCESS_TO_INTERNALS_OF_MENUS
00062 #   define ALLOW_ACCESS_TO_INTERNALS_OF_PROGRESS
00063 #   define ALLOW_ACCESS_TO_INTERNALS_OF_SCROLLBARS
00064 #   define ALLOW_ACCESS_TO_INTERNALS_OF_TABLES
00065 
00066 #   define ALLOW_ACCESS_TO_INTERNALS_OF_BITMAPS
00067 #   define ALLOW_ACCESS_TO_INTERNALS_OF_FONTS
00068 #   define ALLOW_ACCESS_TO_INTERNALS_OF_WINDOWS
00069 
00070 #endif
00071 
00072 /************************************************************
00073  *  The following defines provide a way to use compiler extensions that are
00074  *  implemented on different compilers using different keywords or mechanisms
00075  *  These are automatically defined and must not be changed
00076  *************************************************************/
00077 
00078 #   ifndef CPU_TYPE
00079 #       if defined(__i386__) || defined(_M_IX86)
00080 #           define  CPU_TYPE    CPU_x86
00081 #       elif defined(__POWERPC__) || defined(__powerpc__)
00082 #           define  CPU_TYPE    CPU_PPC
00083 #       elif defined(__arm__) || defined(__arm)
00084 #           define  CPU_TYPE    CPU_ARM
00085 #       else
00086 #           error "Unable to automatically define CPU_TYPE from existing predefined macros."
00087 #       endif
00088 #   endif // CPU_TYPE
00089 
00090 #if CPU_TYPE != CPU_ARM && CPU_TYPE != CPU_x86 && CPU_TYPE != CPU_PPC
00091 #   error "Unsupported CPU_TYPE - Only CPU_ARM and CPU_x86 are supported in this release."
00092 #endif
00093 
00094 #ifndef CPU_ENDIAN
00095 #   if (CPU_TYPE == CPU_x86) || (CPU_TYPE == CPU_ARM)
00096 #       define CPU_ENDIAN   CPU_ENDIAN_LITTLE
00097 #   else
00098 #       define CPU_ENDIAN   CPU_ENDIAN_BIG
00099 #   endif
00100 #endif
00101 
00102 #   ifndef BUS_ALIGN
00103 #       if (CPU_TYPE == CPU_ARM) || (CPU_TYPE == CPU_x86) || (CPU_TYPE == CPU_PPC)
00104 #           define BUS_ALIGN    BUS_ALIGN_32
00105 #       else
00106 #           define BUS_ALIGN    BUS_ALIGN_16
00107 #       endif
00108 #   endif
00109 
00110 
00111 
00112 #   if (BUS_ALIGN == BUS_ALIGN_16)
00113         // if we are on a 16-bit bus, we want the 16-bit
00114         // structures (the 32-bit ones will always be defined
00115         // but not used on the 16-bit devices)
00116 #       define INCLUDE_ALIGN_16_STRUCT
00117 #   endif
00118 
00119 
00120 // Bit field layout
00121 // for MS Visual C++ (used for CPU_x86), BITFIELD_LAYOUT must be set to LSB_TO_MSB
00122 // for the ARM tools, when compiling little endian target, layout is also LSB_TO_MSB
00123 #ifndef BITFIELD_LAYOUT
00124 #   if (CPU_TYPE == CPU_x86) || (CPU_TYPE == CPU_ARM)
00125 #       define BITFIELD_LAYOUT  LSB_TO_MSB
00126 #   else
00127 #       define BITFIELD_LAYOUT  MSB_TO_LSB
00128 #   endif
00129 #endif
00130 
00131 // The macro expansion for the filename is different on the ARM compiler
00132 // The ARM compiler expands __FILE__ to the full path (too much for PalmOS)
00133 // so this define allows us to use the shorter form on the ARM compiler.
00134 #if defined (__CC_ARM)
00135     #define MODULE_NAME             __MODULE__
00136 #else
00137     #define MODULE_NAME             __FILE__
00138 #endif
00139 
00140 // The inline keyword differs from compiler to compiler.
00141 // (or some compilers may not even support inlining)
00142 #ifdef __ARMCC_VERSION
00143     #define INLINE_FNC              __inline
00144 #elif defined (_MSC_VER)
00145     #define INLINE_FNC              __inline
00146 #elif defined (__MWERKS__)
00147     #define INLINE_FNC              inline
00148 #elif defined (_PACC_VER)
00149     #define INLINE_FNC              __inline
00150 #elif defined (__GNUC__)
00151 #  ifdef __cplusplus
00152     #define INLINE_FNC              inline      // C++ syntax
00153 #  else
00154     #define INLINE_FNC              static inline   // C99 syntax
00155 #  endif
00156 #else
00157     // Define it to nothing
00158     #warning No __inline available; linkage errors may arise
00159     #define INLINE_FNC
00160 #endif
00161 #define INLINE_FUNCTION         INLINE_FNC
00162 
00163 // The inline keyword differs from compiler to compiler.
00164 // (or some compilers may not even support inlining)
00165 #ifdef __ARMCC_VERSION
00166     #define PURE_FUNCTION           __pure
00167 #elif defined (_MSC_VER)
00168     #define PURE_FUNCTION
00169 #elif defined (__MWERKS__)
00170     #define PURE_FUNCTION
00171 #elif defined (_PACC_VER)
00172     #define PURE_FUNCTION           __pure
00173 #elif defined (__GNUC__)
00174     #define PURE_FUNCTION
00175 #else
00176     // Define it to nothing
00177     #warning No __pure available; linkage errors may arise
00178     #define PURE_FUNCTION
00179 #endif
00180 
00181 // The method of specifying structure alignment differs from compiler
00182 // to compiler.  This define is used to force 1-byte alignment.
00183 // (note that, when using MSVC, you must also add '#pragma pack(1)'
00184 // to your source file)
00185 #ifdef __ARMCC_VERSION
00186     #define PACKED                      __packed
00187 #elif defined(_MSC_VER)  // MS VC++ Compiler
00188     #define PACKED
00189     #pragma warning( disable : 4103 )  // To remove "used #pragma pack to change alignment" warning
00190 #else
00191     #define PACKED
00192     #if defined (__GNUC__) && defined (__UNIX__)
00193         #pragma pack(1)
00194     #endif
00195 #endif
00196 
00197 // Some PalmOS structs need to be packed on 16-bit boundaries.
00198 // This define/pragma is used to ensure that they are.
00199 #ifdef __ARMCC_VERSION
00200     #define PACKED16                    __packed
00201 #elif defined(_MSC_VER)  // MS VC++ Compiler
00202     #define PACKED16
00203     #pragma warning( disable : 4103 )  // To remove "used #pragma pack to change alignment" warning
00204 #else
00205     #define PACKED16
00206     #if defined (__GNUC__) && defined (__UNIX__)
00207         #pragma pack(2)
00208     #endif
00209 #endif
00210 
00211 // Use this to work around ADS1.1 compiler bugs. For example:
00212 // #ifdef ADS11_COMPILER_BUG
00213 // #pragma Ono_peephole
00214 // #endif
00215 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION / 10000 == 11)
00216 #   define ADS11_COMPILER_BUG   1
00217 #endif
00218 
00219 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION / 10000 == 12)
00220 #   define ADS12_COMPILER_BUG   1
00221 #endif
00222 
00223 #ifndef TARGET_PLATFORM
00224 #   if defined(WIN32)
00225 #       define TARGET_PLATFORM  TARGET_PLATFORM_PALMSIM_WIN32
00226 #   elif defined(__arm__) || defined(__arm) || defined(__ARMCC_VERSION)
00227 #       define TARGET_PLATFORM  TARGET_PLATFORM_DEVICE_ARM
00228 #   elif defined(MACOS)
00229 #       define TARGET_PLATFORM TARGET_PLATFORM_PALMSIM_MACOS
00230 #   elif defined(LINUX)
00231 #       define TARGET_PLATFORM TARGET_PLATFORM_PALMSIM_LINUX
00232 #   endif
00233 #endif
00234 
00235 #ifndef TARGET_PLATFORM
00236 #   error TARGET_PLATFORM "is not specified in your project file and it's not possible to set a default value."
00237 #endif
00238 
00239 #ifndef TARGET_HOST
00240 #define TARGET_HOST TARGET_HOST_PALMOS
00241 #endif
00242 
00243 
00244 /**************************************************************************
00245  * Kernel functions accessed via traps.  In ARM, traps are SWIs and
00246  * the compiler has syntax for giving a SWI a function prototype (useful
00247  * for additional type checking but not really necessary).
00248  * In other compilers, this might not be possible so the KAL might need
00249  * to be different.  In Win32, we just provide these traps as stubs
00250  * that use Win32 SendMessage.
00251  **************************************************************************/
00252 #if !defined(LINUX_DEMO_HACK) && TARGET_PLATFORM == TARGET_PLATFORM_DEVICE_ARM
00253 #   ifdef __ARMCC_VERSION
00254 #       define KERNEL_TRAP(x) __swi(x)
00255 #       define KERNEL_TRAP_INDIRECT(x) __swi_indirect(x)
00256 #       define RETURN_STRUCT __value_in_regs
00257 #   else
00258 #       error Unsupported ARM compiler
00259 #   endif
00260 #else
00261 #   define KERNEL_TRAP(x)
00262 #   define KERNEL_TRAP_INDIRECT(x)
00263 #   define RETURN_STRUCT
00264 #endif
00265 
00266 // If not already specified, try to determine whether we can
00267 // use C++ namespaces with this compiler.
00268 #ifndef _SUPPORTS_NAMESPACE
00269 #if defined(__CC_ARM) || (defined(_MSC_VER) && _MSC_VER < 1300)
00270 // ADS doesn't support namespaces at all.
00271 // MSC 6.0 has broken namespace support.
00272 #define _SUPPORTS_NAMESPACE 0
00273 #else
00274 #define _SUPPORTS_NAMESPACE 1
00275 #endif
00276 #endif
00277 
00278 // GNUC and RVDS requires namespaces for std namespace things (like
00279 // type_info).  We must use namespace without turning on our
00280 // use of namespaces in our own code.
00281 #if defined(__GNUC__) || defined(__EDG_RUNTIME_USES_NAMESPACES)
00282 #define _REQUIRES_NAMESPACE 1
00283 #else
00284 #define _REQUIRES_NAMESPACE 0
00285 #endif
00286 
00287 // Convenience macro for new (nothrow) when nothrow may or may
00288 // not be in a namespace.
00289 #if _SUPPORTS_NAMESPACE || _REQUIRES_NAMESPACE
00290 #define B_NO_THROW (std::nothrow)
00291 #else
00292 #define B_NO_THROW (nothrow)
00293 #endif
00294 
00295 // Convenience macro to conditionalize on whether namespaces
00296 // are supported. (std namespace only)
00297 #if _SUPPORTS_NAMESPACE || _REQUIRES_NAMESPACE
00298 #define B_SNS(x) x
00299 #else
00300 #define B_SNS(x)
00301 #endif
00302 
00303 // Convenience macro to conditionalize on whether namespaces
00304 // are supported.
00305 #if _SUPPORTS_NAMESPACE
00306 #define BNS(x) x
00307 #else
00308 #define BNS(x)
00309 #endif
00310 
00311 // If not already specified, determine whether RTTI is supported
00312 #ifndef _SUPPORTS_RTTI
00313 #if TARGET_HOST == TARGET_HOST_PALMOS
00314 #define _SUPPORTS_RTTI 0
00315 #else
00316 #define _SUPPORTS_RTTI 1
00317 #endif
00318 #endif
00319 
00320 // Convenience macro to conditionalize on whether RTTI is supported.
00321 #if _SUPPORTS_RTTI
00322 #define B_TYPEPTR(x) (&typeid(x))
00323 #define B_TYPENAME(x) typeid(x).name()
00324 #else
00325 #define B_TYPEPTR(x) ((const type_info*)NULL)
00326 #define B_TYPENAME(x) ""
00327 #endif
00328 
00329 // Safety checks. Several people spent a lot of time figuring out this kind of problems...
00330 // A few files does not REQUIRE them so I cannot simply put them as a rule
00331 /*
00332 #ifdef __ARMCC_VERSION
00333 #   if !defined(__APCS_ROPI)
00334 #       error ARM versions must be compiled with compiler option -apcs /ropi.
00335 #   endif
00336 #   if !defined(__APCS_RWPI)
00337 #       error ARM versions must be compiled with compiler option -apcs /rwpi.
00338 #   endif
00339 #   if !defined(__APCS_INTERWORK)
00340 #       error ARM versions must be compiled with compiler option -apcs /interwork.
00341 #   endif
00342 #   if !defined(__APCS_SHL)
00343 #       error ARM versions must be compiled with compiler option -apcs /shl.
00344 #   endif
00345 #endif
00346 */
00347 
00348 
00349 // Provide macro covers for __declspec(), which is needed when performing
00350 // a native Windows build.
00351 #if (TARGET_HOST == TARGET_HOST_WIN32)
00352 #define _EXPORT     __declspec(dllexport)
00353 #define _IMPORT     __declspec(dllimport)
00354 #else
00355 #define _EXPORT
00356 #define _IMPORT
00357 #endif
00358 
00359 
00360 /*
00361 Disable most frequent VS warnings so we can still build in Warning level 4.
00362 
00363 warning C4200: nonstandard extension used : zero-sized array in struct/union
00364 warning C4214: nonstandard extension used : bit field types other than int
00365 warning C4201: nonstandard extension used : nameless struct/union
00366 warning C4100: 'xxx' : unreferenced formal parameter
00367 warning C4152: nonstandard extension, function/data pointer conversion in expression
00368 warning C4218: nonstandard extension used : must specify at least a storage class or a type
00369 warning C4127: conditional expression is constant
00370 warning C4204: nonstandard extension used : non-constant aggregate initializer
00371 warning C4711: function 'BmpFindShadowEntryFor68K' selected for automatic inline expansion
00372 warning C4054: 'type cast' : from function pointer 'void (__cdecl *)(struct EmulStateTag *)' to data pointer 'void *'
00373 warning C4068: unknown pragma
00374 
00375 Warnings 4152 and 4218 are appearing in Startup.c generated by PalmDefComp.
00376 The 4152 could probably be removed by generating an explicit cast to void*
00377 Warning 4127 is caused by the do { } while(0) in ErrFatalError macros
00378 
00379 DO NOT REMOVE: 4244, 4244
00380 These warnings may reveal bugs and SHOULD be fixed anyway
00381 */
00382 #ifdef _MSC_VER
00383 #pragma warning(disable : 4200)
00384 #pragma warning(disable : 4201)
00385 #pragma warning(disable : 4100)
00386 #pragma warning(disable : 4152)
00387 #pragma warning(disable : 4218)
00388 #pragma warning(disable : 4204)
00389 //#pragma warning(disable : 4711)
00390 #pragma warning(disable : 4127)
00391 #pragma warning(disable : 4054)
00392 #pragma warning(disable : 4214)
00393 #pragma warning(disable : 4068)
00394 #endif
00395 
00396 /************************************************************
00397  * Obsolete Options
00398  *************************************************************/
00399 
00400 #ifdef  MEMORY_FORCE_LOCK
00401     #error "MEMORY_FORCE_LOCK is an obsolete build flag!"
00402 #endif
00403 
00404 #ifdef  MODEL
00405     #error "MODEL is an obsolete build flag!"
00406 #endif
00407 
00408 #ifdef  USER_MODE
00409     #error "USER_MODE is an obsolete build flag!"
00410 #endif
00411 
00412 #ifdef  INTERNAL_COMMANDS
00413     #error "INTERNAL_COMMANDS is an obsolete build flag!"
00414 #endif
00415 
00416 #ifdef  INCLUDE_DES
00417     #error "INCLUDE_DES is an obsolete build flag!"
00418 #endif
00419 
00420 #ifdef  RESOURCE_FILE_PREFIX
00421     #error "RESOURCE_FILE_PREFIX is an obsolete build flag!"
00422 #endif
00423 
00424 #ifdef  SHELL_COMMAND_DB
00425     #error "SHELL_COMMAND_DB is an obsolete build flag!"
00426 #endif
00427 
00428 #ifdef  SHELL_COMMAND_UI
00429     #error "SHELL_COMMAND_UI is an obsolete build flag!"
00430 #endif
00431 
00432 #ifdef  SHELL_COMMAND_APP
00433     #error "SHELL_COMMAND_APP is an obsolete build flag!"
00434 #endif
00435 
00436 #ifdef  SHELL_COMMAND_EMULATOR
00437     #error "SHELL_COMMAND_EMULATOR is an obsolete build flag!"
00438 #endif
00439 
00440 #ifdef  CML_ENCODER
00441     #error "CML_ENCODER is an obsolete build flag!"
00442 #endif
00443 
00444 #ifdef  EMULATION_LEVEL
00445     #error "EMULATION_LEVEL is an obsolete build flag!"
00446 #endif
00447 
00448 #ifdef  PLATFORM_TYPE
00449     #error "PLATFORM_TYPE is an obsolete build flag!"
00450 #endif
00451 
00452 #ifdef  USE_TRAPS
00453     #error "USE_TRAPS is an obsolete build flag!"
00454 #endif
00455 
00456 #ifdef ENVIRONMENT
00457     #error "ENVIRONMENT is an obsolete build flag!"
00458 #endif
00459 
00460 #ifdef MODEL
00461     #error "MODEL is an obsolete build flag!"
00462 #endif
00463 
00464 #ifdef  DISABLE_HAL_TRAPS
00465     #error "DISABLE_HAL_TRAPS is an obsolete build flag!"
00466 #endif
00467 
00468 #ifdef  _DONT_USE_FP_TRAPS_
00469     #error "_DONT_USE_FP_TRAPS_ is an obsolete build flag!"
00470 #endif
00471 
00472 #ifdef  _DONT_USE_FP_TRAPSE_
00473     #error "_DONT_USE_FP_TRAPSE_ is an obsolete build flag!"
00474 #endif
00475 
00476 #ifdef  RUNTIME_MODEL
00477     #error "RUNTIME_MODEL is an obsolete build flag!"
00478 #endif
00479 
00480 #ifdef  MEMORY_TYPE
00481     #error "MEMORY_TYPE is an obsolete build flag!"
00482 #endif
00483 
00484 #ifdef  DAL_DEVELOPMENT
00485     #error "DAL_DEVELOPMENT is an obsolete build flag!"
00486 #endif
00487 
00488 #ifdef  DYN_MEM_SIZE_MAX
00489     #error "DYN_MEM_SIZE_MAX is an obsolete build flag!"
00490 #endif
00491 
00492 #ifdef  SMALL_ROM_SIZE
00493     #error "SMALL_ROM_SIZE is an obsolete build flag!"
00494 #endif
00495 
00496 #ifdef  CONSOLE_SERIAL_LIB
00497     #error "CONSOLE_SERIAL_LIB is an obsolete build flag!"
00498 #endif
00499 
00500 #ifdef  PILOT_SERIAL_MGR
00501     #error "PILOT_SERIAL_MGR is an obsolete build flag!"
00502 #endif
00503 
00504 #ifdef  MEMORY_VERSION
00505     #error "MEMORY_VERSION is an obsolete build flag!"
00506 #endif
00507 
00508 #ifdef  GRAPHICS_VERSION
00509     #error "GRAPHICS_VERSION is an obsolete build flag!"
00510 #endif
00511 
00512 #ifdef  HW_TARGET
00513     #error "HW_TARGET is an obsolete build flag!"
00514 #endif
00515 
00516 #ifdef  HW_REV
00517     #error "HW_REV is an obsolete build flag!"
00518 #endif
00519 
00520 #ifdef  RMP_LIB_INCLUDE
00521     #error "RMP_LIB_INCLUDE is an obsolete build flag!"
00522 #endif
00523 
00524 #ifdef  OEM_PRODUCT
00525     #error "OEM_PRODUCT is an obsolete build flag!"
00526 #endif
00527 
00528 #ifdef  LANGUAGE
00529     #error "LANGUAGE is an obsolete build flag!"
00530 #endif
00531 
00532 #ifdef  COUNTRY
00533     #error "COUNTRY is an obsolete build flag!"
00534 #endif
00535 
00536 #ifdef  LOCALE
00537     #error "LOCALE is an obsolete build flag!"
00538 #endif
00539 
00540 
00541 /************************************************************
00542  *  Settings that can be overriden in the makefile
00543  *  These needs to be here because it uses previous section defines
00544  *************************************************************/
00545 // Default Palm Reporter trace policy
00546 #ifndef TRACE_OUTPUT
00547 #   if  BUILD_TYPE == BUILD_TYPE_DEBUG
00548 #       define TRACE_OUTPUT TRACE_OUTPUT_ON
00549 #   endif
00550 #endif
00551 
00552 /* NO_RUNTIME_SHARED_LIBRARIES is defined by the jamfile */
00553 
00554 /************************************************************
00555  *************************************************************/
00556 
00557 #endif // __BUILDDEFAULTS_H__