#~ Copyright 2004-2005 Rene Rivera. #~ Distributed under the Boost Software License, Version 1.0. #~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) # The following #// line will be used by the regression test table generation # program as the column heading for HTML tables. Must not include version number. #//Metrowerks
CodeWarrior
# For adding framwork libraries; like Python, Carbon, etc. free-feature framework ; # singleton variables... set-as-singleton CW_ROOT CWFOLDER CWFolder CWINSTALL ; flags cw cw-version : $(CW_VERSION) ; flags cw cw-root : $(CW_ROOT) ; cw-root ?= $(CWFolder) ; cw-root ?= $(CWFOLDER) ; if $(NT) { for local v in 9.0 8.0 7.0 6.0 { cw-root-$(v) ?= [ W32_GETREG "HKEY_LOCAL_MACHINE\\SOFTWARE\\Metrowerks\\CodeWarrior for Windows\\$(v)" : "PATH" ] ; cw-version ?= [ conditional $(cw-root-$(v)) : $(v) ] ; } } cw-root ?= $(cw-root-$(cw-version)) ; flags cw CFLAGS ; flags cw C++FLAGS ; flags cw DEFINES ; flags cw UNDEFS ; flags cw HDRS ; flags cw SYSHDRS ; flags cw LINKFLAGS ; flags cw ARFLAGS ; flags cw LIBPATH ; flags cw NEEDLIBS ; flags cw FINDLIBS ; flags cw PREFIX ; if $(OS) = MACOSX { flags cw FRAMEWORKS ; } flags cw cw-errors ; flags cw cw-warnings ; # Debug information flags cw CFLAGS on : -g ; flags cw LINKFLAGS on : -g ; # Optimizations flags cw CFLAGS off : -O0 ; flags cw CFLAGS speed : -opt full ; flags cw CFLAGS space : -O4,s "-opt intrinsics" ; flags cw CFLAGS off : -inline off ; flags cw CFLAGS on : -inline on ; flags cw CFLAGS full : -inline auto -inline level=8 ; # Target type flags cw LINKFLAGS $(SHARED_TYPES) : -shared ; if $(NT) { flags cw LINKFLAGS $(SHARED_TYPES) : "-export dllexport" ; } # Some language related options flags cw CFLAGS msvc : -exc ms ; flags cw CFLAGS directory : "-cwd proj" ; flags cw CFLAGS source : "-cwd source" ; flags cw CFLAGS paths : "-cwd explicit" ; flags cw CFLAGS relative : "-cwd include" ; flags cw C++FLAGS off : "-RTTI off" ; flags cw C++FLAGS on : "-RTTI on" ; # CodeWarrior on MacOS defaults to wchar_t support off, contrary # to what it does on Windows. So "fix" this discrepancy. Don't # bother with OS type just set this to on for all. After all it's # standard! flags cw CFLAGS : "-wchar_t on" ; # OS subsystem target if $(NT) { flags cw LINKFLAGS console : "-subsystem console" ; flags cw LINKFLAGS gui : "-subsystem windows" ; flags cw LINKFLAGS wince : "-subsystem wince" ; flags cw LINKFLAGS native : "-subsystem native" ; flags cw LINKFLAGS auto : "-subsystem auto" ; } # Errors, default to maximum 5 errors flags cw FLAGS : [ conditional $(cw-errors) : "-maxerrors $(cw-errors[1])" : "-maxerrors 5" ] ; # Warnings, default to maximum 20 warnings if off in $(cw-warnings) { flags cw FLAGS : "-warnings off" ; } else if error in $(cw-warnings) { flags cw FLAGS : "-warnings error" ; } else { flags cw FLAGS : "-warnings on" ; } if ! ( off in $(cw-warnings) ) { if [ MATCH "^([0-9]+)" : $(cw-warnings) ] { local cw-maxwarnings = [ MATCH "^([0-9]+)" : $(cw-warnings) ] ; cw-warnings = [ difference $(cw-warnings) : $(cw-maxwarnings) ] ; flags cw FLAGS : "-maxwarnings $(cw-maxwarnings[1])" ; } else { flags cw FLAGS : "-maxwarnings 20" ; } } cw-warnings = [ difference $(cw-warnings) : on off error ] ; if $(cw-warnings) { flags cw CFLAGS no-illegal-pragmas : "-warnings nopragmas" ; flags cw CFLAGS illegal-pragmas : "-warnings pragmas" ; flags cw CFLAGS no-empty-declarations : "-warnings noempty" ; flags cw CFLAGS empty-declarations : "-warnings empty" ; flags cw CFLAGS no-empty-declarations : "-warnings noempty" ; flags cw CFLAGS empty-declarations : "-warnings empty" ; flags cw CFLAGS no-unwanted-effect : "-warnings nounwanted" ; flags cw CFLAGS unwanted-effect : "-warnings unwanted" ; flags cw CFLAGS no-unused-arg : "-warnings nounusedarg" ; flags cw CFLAGS unused-arg : "-warnings unsedarg" ; flags cw CFLAGS no-unused-var : "-warnings nounusedvar" ; flags cw CFLAGS unused-var : "-warnings unsedvar" ; flags cw CFLAGS no-extra-comma : "-warnings nocomma" ; flags cw CFLAGS extra-comma : "-warnings comma" ; flags cw CFLAGS no-pedantic : "-warnings nopedantic" ; flags cw CFLAGS pedantic : "-warnings pedantic" ; flags cw CFLAGS no-hidden-virtual : "-warnings nohidden" ; flags cw CFLAGS hidden-virtual : "-warnings hidden" ; flags cw CFLAGS no-implicit-convert : "-warnings noimplicit" ; flags cw CFLAGS implicit-convert : "-warnings implicit" ; flags cw CFLAGS no-not-inlined : "-warnings nonotinlined" ; flags cw CFLAGS not-inlined : "-warnings notinlined" ; flags cw CFLAGS no-inconsistent-class : "-warnings nostructclass" ; flags cw CFLAGS inconsistent-class : "-warnings structclass" ; if $(NT) { flags cw CFLAGS no-unused-expresssion : "-warnings nounusedexpr" ; flags cw CFLAGS unused-expresssion : "-warnings unsedexpr" ; flags cw CFLAGS no-structure-pad : "-warnings nopadding" ; flags cw CFLAGS structure-pad : "-warnings padding" ; flags cw CFLAGS no-unused-return : "-warnings nonotused" ; flags cw CFLAGS unused-return : "-warnings notused" ; flags cw CFLAGS no-pointer-conversion : "-warnings noptrintconv" ; flags cw CFLAGS pointer-conversion : "-warnings ptrintconv" ; } } else { if $(NT) { flags cw CFLAGS : "-warnings nounusedexpr,nounused" ; } else { flags cw CFLAGS : "-warnings nounused" ; } } # Search for files in search paths flags cw LINKFLAGS : -search ; flags cw ARFLAGS : -search ; # Version specific options if $(cw-version) in 8.0 9.0 { # Use latest ISO conforming templates flags cw C++FLAGS : -iso_templates on ; if $(NT) { # The runtime libraries flags cw CFLAGS static/single/release : -runtime ss ; flags cw CFLAGS static/single/debug : -runtime ssd ; flags cw CFLAGS static/multi/release : -runtime sm ; flags cw CFLAGS static/multi/debug : -runtime smd ; flags cw CFLAGS dynamic/release : -runtime dm ; flags cw CFLAGS dynamic/debug : -runtime dmd ; } } if $(NT) && $(cw-version) in 6.0 7.0 8.0 { flags cw PREFIX console/dynamic : UseDLLPrefix.h ; } if $(NT) && $(cw-version) in 7.0 { # The runtime libraries flags cw STDLIBS static/release : MSL_C_x86.lib MSL_Runtime_x86.lib msl_c++_x86.lib gdi32.lib user32.lib kernel32.lib ; flags cw STDLIBS dynamic/release : MSL_All-DLL_x86.lib gdi32.lib user32.lib kernel32.lib ; flags cw STDLIBS static/debug : MSL_C_x86_D.lib MSL_Runtime_x86_D.lib msl_c++_x86_D.lib gdi32.lib user32.lib kernel32.lib ; flags cw STDLIBS dynamic/debug : MSL_All-DLL_x86_D.lib gdi32.lib user32.lib kernel32.lib ; } if $(NT) && $(cw-version) in 6.0 { # The runtime libraries flags cw STDLIBS static : ansicx86.lib mwcrtl.lib ansicppx86.lib gdi32.lib user32.lib kernel32.lib ; flags cw STDLIBS dynamic : mwcrtldll.lib gdi32.lib user32.lib kernel32.lib ; } # The paths to system and runtime libraries if $(NT) { flags cw CW_SETUP : "call \"$(cw-root)\\Other Metrowerks Tools\\Command Line Tools\\cwenv.bat\" -quiet" ; # This is needed after the setup because the CW-9 setup erronously sets the # ERRORLEVEL pseudo-var directly overriding the real value. The aregument is # quoted to prevent the value from getting set to " " because bjam insertes # extra spaces at the end of action commands. flags cw CW_CLEAR_ERROR : "set \"ERRORLEVEL=\"" ; flags cw CW_LINK_SETUP : "set MWWinx86LibraryFiles=" ; flags cw CW_IMPLIB_COMMAND : "-implib " ; flags cw CW_RUN_PATH : "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime" "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs\\MSL_All-DLLs" ; flags cw STDLIBPATH : "$(cw-root)\\Win32-x86 Support\\Libraries\\Win32 SDK" ; flags cw STDLIBPATH static : "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs" ; flags cw STDLIBPATH dynamic : "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs\\MSL_All-DLLs" ; } # Don't wrap tool messages, they just confuse everyone :-) flags cw FLAGS : -nowraplines ; flags cw CW_PREFIX : "-prefix " ; # CodeWarrior has it's own set of standard headers, so ignore the default. flags cw STDHDRS : ; # MacOSX.. only the MSL/Carbon/Mach-O combination is working. if $(OS) = MACOSX { # We use the compiler for both compiles and link, because we may need # to compile the console stubs source. The compiler passes all options # down to the linker anyway. flags cw MWCC : mwcc ; flags cw MWLD : mwcc ; # For Carbon we need this prefix file to tell CW that's what we are targetting. flags cw PREFIX : MSLCarbonPrefix.h ; # We need to add the framework, as it's not added automatically. flags cw FRAMEWORKS : Carbon ; # For comsole apps we need to compile in the MSL functions that will # talk to the MacOSX console. flags cw LINKFLAGS console : "-prefix MSLCarbonPrefix.h" "\"$(CWINSTALL)/MSL/MSL_C/MSL_MacOS/Src/console_OS_X.c\"" ; } if $(NT) { flags cw MWCC : mwcc ; flags cw MWLD : mwld ; } #~ flags cw CFLAGS : -verbose ; #~ flags cw LINKFLAGS : -verbose ; #### Link #### rule Link-action { _ on $(<) = " " ; gRUN_PATH($(<)) += $(CW_RUN_PATH) ; if $(NT) { # We can't have the mixture of the same libs going in NEEDLIBS and FINDLIBS. # So remove the extras from FINDLIBS. local find-libs = [ difference [ on $(<[1]) return $(FINDLIBS) ] : $(gTARGET_BASENAME($(gTARGET_SUBVARIANT($(NEEDLIBS))))) ] ; FINDLIBS on $(<) = $(find-libs)$(SUFLIB) ; CMD on $(<) = "@" ; with-command-file cw-Link-action $(<) : $(>) $(NEEDLIBS) $(NEEDIMPS) ; } else if $(OS) = MACOSX { local find-libs = [ on $(<[1]) return $(FINDLIBS) ] ; FINDLIBS on $(<) = -l$(find-libs) ; CMD on $(<) = "" ; cw-Link-action $(<) : $(>) $(NEEDLIBS) $(NEEDIMPS) ; } } actions cw-Link-action { $(CW_SETUP) $(CW_CLEAR_ERROR) $(CW_LINK_SETUP)$(STDLIBS:J=;) $(MWLD) $(FLAGS) $(LINKFLAGS) "-L$(LIBPATH)" "-L$(STDLIBPATH)" -framework$(_)"$(FRAMEWORKS)" $(CW_IMPLIB_COMMAND)"$(<[2])" -o "$(<[1])" $(CMD)"$(>)" "$(FINDLIBS)" } #### Cc ##### rule Cc-action { _ on $(<) = " " ; cw-Cc-action $(<) : $(>) ; } actions cw-Cc-action { $(CW_SETUP) $(CW_CLEAR_ERROR) $(MWCC) -c -lang c -U$(UNDEFS) -D$(DEFINES) $(FLAGS) $(CFLAGS) "-I$(HDRS)" -I-$(_)"-I$(STDHDRS)" -I-$(_)"-I$(SYSHDRS)" $(CW_PREFIX)"$(PREFIX)" -o "$(<)" "$(>)" } #### C++ #### rule C++-action { _ on $(<) = " " ; cw-C++-action $(<) : $(>) ; } actions cw-C++-action { $(CW_SETUP) $(CW_CLEAR_ERROR) $(MWCC) -c -lang c++ -U$(UNDEFS) -D$(DEFINES) $(FLAGS) $(CFLAGS) $(C++FLAGS) "-I$(HDRS)" -I-$(_)"-I$(STDHDRS)" -I-$(_)"-I$(SYSHDRS)" $(CW_PREFIX)"$(PREFIX)" -o "$(<)" "$(>)" } #### Archive #### rule Archive-action { _ on $(<) = " " ; if $(NT) { local find-libs = [ on $(<[1]) return $(FINDLIBS) ] ; FINDLIBS on $(<) = $(find-libs)$(SUFLIB) ; CMD on $(<) = "@" ; with-command-file cw-Archive-action $(<) : $(>) [ on $(<) return $(NEEDLIBS) ] ; } else if $(OS) = MACOSX { local find-libs = [ on $(<[1]) return $(FINDLIBS) ] ; FINDLIBS on $(<) = -l$(find-libs) ; CMD on $(<) = "" ; cw-Archive-action $(<) : $(>) [ on $(<) return $(NEEDLIBS) ] ; } } ## CW in general doesn't produce archive that ranlib is intereted in. So ## don't run ranlib. rule Ranlib-action { } actions together cw-Archive-action { $(CW_SETUP) $(CW_CLEAR_ERROR) $(MWLD) -library $(FLAGS) $(ARFLAGS) "-L$(LIBPATH)" "-L$(STDLIBPATH)" -o "$(<)" $(CMD)"$(>)" "$(FINDLIBS)" }