Browse Source

new installer build system

cxgeorge 23 years ago
parent
commit
d6f92fe62b

+ 17 - 15
dtool/Config.pp

@@ -32,7 +32,7 @@
 // syntax used in the various ppremake system configure files; it's
 // designed to be easy to use as a macro language to generate
 // makefiles and their ilk.
-// 
+//
 
 // Some of the variables below are defined using the #define command,
 // and others are defined using #defer.  The two are very similar in
@@ -191,7 +191,7 @@
 // necessary if the default include and link lines that come with the
 // compiler don't provide adequate STL support.  At least some form of
 // STL is absolutely required in order to build Panda.
-#define STL_IPATH 
+#define STL_IPATH
 #define STL_LPATH
 #define STL_CFLAGS
 #define STL_LIBS
@@ -266,7 +266,7 @@
 #if $[WINDOWS_PLATFORM]
   #defer GL_IPATH
   #defer GL_LPATH
-  #define GL_LIBS opengl32.lib glu32.lib 
+  #define GL_LIBS opengl32.lib glu32.lib
 #else
   #defer GL_IPATH
   #defer GL_LPATH /usr/X11R6/lib
@@ -356,9 +356,9 @@
 #defer NOTIFY_DEBUG $[< $[OPTIMIZE], 4]
 
 // Do you want to build the audio interface?
-#define HAVE_AUDIO 1     
+#define HAVE_AUDIO 1
 
-// Info for the RAD game tools, Miles Sound System 
+// Info for the RAD game tools, Miles Sound System
 // note this may be overwritten in wintools Config.pp
 #define RAD_MSS_IPATH /usr/include/Miles6/include
 #define RAD_MSS_LPATH /usr/lib/Miles6/lib/win
@@ -412,7 +412,7 @@
 //#define LINK_IN_EGG yes
 //#define LINK_IN_PHYSICS yes
 
-// Define USE_COMPILER to switch the particular compiler that should 
+// Define USE_COMPILER to switch the particular compiler that should
 // be used.  A handful of tokens are recognized, depending on BUILD_TYPE.
 // This may also be further customized within Global.$[BUILD_TYPE].pp.
 
@@ -429,7 +429,7 @@
 #if $[WINDOWS_PLATFORM]
   #if $[eq $[USE_COMPILER],]
     #define USE_COMPILER MSVC7
-  #endif    
+  #endif
 #elif $[eq $[PLATFORM], Irix]
   #define USE_COMPILER MIPS
 #elif $[eq $[PLATFORM], Linux]
@@ -443,7 +443,7 @@
 // need to have these programs if you need to make changes to the
 // bison or flex sources (see the next point, below).
 #defer BISON bison
-#defer FLEX flex 
+#defer FLEX flex
 
 // You may not even have bison and flex installed.  If you don't, no
 // sweat; Panda ships with the pre-generated output of these programs,
@@ -466,7 +466,9 @@
 // However, don't define this to be '.', or you will be very sad the
 // next time you run 'make clean'.
 //#defer ODIR Opt$[OPTIMIZE]-$[PLATFORM]$[USE_COMPILER]
-#defer ODIR Opt$[OPTIMIZE]-$[PLATFORM]
+// ODIR_SUFFIX is optional, usually empty
+#defer ODIR Opt$[OPTIMIZE]-$[PLATFORM]$[ODIR_SUFFIX]
+
 
 // What is the normal extension of a compiled object file?
 #if $[WINDOWS_PLATFORM]
@@ -568,7 +570,7 @@
 #if $[eq $[USE_COMPILER], MIPS]
   #define CC cc -n32 -mips3
   #define CXX CC -n32 -mips3
-    
+
   // Turn off a few annoying warning messages.
   // 1174 - function 'blah' was declared but never used
   // 1201 - trailing comma is nonstandard.
@@ -585,20 +587,20 @@
   // 85 - definition of SOMESYMBOL in SOMELIB preempts that of definition in
   //      SOMEOTHERLIB.
   #define WOFF_LIST $[WOFF_LIST] -Wl,-LD_MSG:off=85
-  
+
   #defer OPTFLAGS -O2 -OPT:Olimit=2500
-  
+
   #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] $[WOFF_LIST] -g
   #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] $[WOFF_LIST]
   #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[WOFF_LIST]
   #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[WOFF_LIST]
-  
+
   #defer CFLAGS_SHARED
-  
+
   #defer STATIC_LIB_C $[CC] -ar -o $[target] $[sources]
   #defer STATIC_LIB_C++ $[CXX] -ar -o $[target] $[sources]
   #defer RANLIB
-  
+
   #define SHARED_FLAGS -Wl,-none -Wl,-update_registry,$[TOPDIR]/so_locations
   #defer SHARED_LIB_C $[CC] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
   #defer SHARED_LIB_C++ $[CXX] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]

+ 4 - 5
dtool/pptempl/Depends.pp

@@ -36,13 +36,12 @@
   // various Template.*.pp files will be able to reliably access
   // $[compile_sources] from the different directories.
   #define composite_list
-
   // Tag all the static libraries by defining the "lib_is_static" variable.
   #forscopes static_lib_target ss_lib_target
     #define lib_is_static 1
   #end static_lib_target ss_lib_target
 
-  #forscopes metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
+  #forscopes metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
     // We can optimize quite a bit by evaluating now several of the key
     // deferred variables defined in Globals.pp.  This way they won't need
     // to get repeatedly reevaluated as each directory examines each
@@ -69,13 +68,13 @@
 
     // Now compute the source files.
     #define c_sources $[filter %.c,$[get_sources]]
-    #define cxx_sources $[filter-out %_src.cxx,$[filter %.cxx,$[get_sources]]]
+    #define cxx_sources $[filter-out %_src.cxx,$[filter %.cxx %.cpp,$[get_sources]]]
     #define yxx_sources $[filter %.yxx,$[get_sources]]
     #define lxx_sources $[filter %.lxx,$[get_sources]]
 
     // Define what the object files are.
     #foreach file $[c_sources] $[cxx_sources] $[yxx_sources] $[lxx_sources]
-      #define $[file]_obj $[patsubst %.c %.cxx %.yxx %.lxx,$[ODIR]/$[TARGET]_%$[OBJ],$[file]]
+      #define $[file]_obj $[patsubst %.c %.cxx %.cpp %.yxx %.lxx,$[ODIR]/$[TARGET]_%$[OBJ],$[notdir $[file]]]
       #push 1 $[file]_obj
     #end file
 
@@ -132,7 +131,7 @@
 
     #define compile_sources $[c_sources] $[cxx_sources]
 
-  #end metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
+  #end metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
 
   // Allow the user to define additional EXTRA_DEPENDS targets in each
   // Sources.pp.

+ 19 - 9
dtool/pptempl/Global.gmsvc.pp

@@ -11,7 +11,7 @@
   // encapsulates each of the libraries we'd be linking with normally.
   // In the case where a particular library is not part of a metalib,
   // we include the library itself.
-  
+
   #define actual_libs
   #foreach lib $[complete_libs]
     // Only consider libraries that we're actually building.
@@ -57,12 +57,12 @@
 #if $[ne $[LINK_ALL_STATIC],]
   #define dlink_all_static LINK_ALL_STATIC
   #define build_dlls
-  #define build_libs yes  
+  #define build_libs yes
   #define dlllib lib
 #else
   #define dlink_all_static
   #define build_dlls yes
-  #define build_libs  
+  #define build_libs
   #define dlllib dll
 #endif
 
@@ -80,8 +80,8 @@
 #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] $[EXTRA_CDEFS] $[CDEFINES_OPT4]
 
 //  Opt1 /GZ disables OPT flags, so make sure its OPT1 only
-#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS] 
-#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS] 
+#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS]
+#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS]
 #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGPDBFLAGS]
 #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[OPT4FLAGS] $[DEBUGPDBFLAGS]
 
@@ -107,6 +107,11 @@
 // distinction is so important in Windows).
 #define dllext $[if $[<= $[OPTIMIZE],2],_d]
 
+// note: does NOT include .dll or .lib at end
+#defun get_dllname dll_basename
+ $[if $[ne $[DONT_USE_PANDA_DLL_NAMING],], $[dll_basename], lib$[dll_basename]$[dllext]]
+#end get_dllname
+
 #defer interrogate_ipath $[decygwin %,-I"%",$[target_ipath]]
 #defer interrogate_spath $[decygwin %,-S"%",$[install_parser_inc_dir]]
 
@@ -118,13 +123,16 @@
 #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS]
 #defer COMPILE_C++ $[COMPILE_C]
 
-#defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]" 
+#defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]"
 #defer STATIC_LIB_C++ $[STATIC_LIB_C]
 
+#defer COMPILE_IDL midl /nologo /env win32 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
+#defer COMPILE_RC rc /R /D "NDEBUG" /L 0x409 $[DECYGWINED_INC_PATHLIST_ARGS]
+
 // if we're attached, use dllbase.txt.  otherwise let OS loader resolve dll addrspace collisions
 #if $[ne $[DTOOL],]
 // use predefined bases to speed dll loading and simplify debugging
-#defer DLLNAMEBASE lib$[TARGET]$[dllext]
+#defer DLLNAMEBASE $[get_dllname $[TARGET]]
 #defer DLLBASEADDRFILENAME dllbase.txt
 #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
 #else
@@ -132,9 +140,11 @@
 #define GENERATE_BUILDDATE
 #endif
 
+#defer LINKER_DEF_FILE_ARG $[if $[LINKER_DEF_FILE],/DEF:"$[LINKER_DEF_FILE]",]
+
 //#defer ver_resource $[directory]\ver.res
-//#defer SHARED_LIB_C link /nologo /dll /VERBOSE:LIB $[LDFLAGS_OPT$[OPTIMIZE]] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] 
-#defer SHARED_LIB_C $[LINKER] /nologo /dll  $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] 
+//#defer SHARED_LIB_C link /nologo /dll /VERBOSE:LIB $[LDFLAGS_OPT$[OPTIMIZE]] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
+#defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
 #defer SHARED_LIB_C++ $[SHARED_LIB_C]
 
 #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"

+ 22 - 20
dtool/pptempl/Global.pp

@@ -35,7 +35,7 @@
 // variable as set for the dconfig library (that is, the expression
 // $[SOURCES] is evaluated within the named scope whose key is
 // "dconfig"--whose variable $[TARGET] was defined to be "dconfig").
-#map all_libs TARGET(*/static_lib_target */ss_lib_target */lib_target */noinst_lib_target */metalib_target)
+#map all_libs TARGET(*/static_lib_target */ss_lib_target */lib_target */noinst_lib_target */test_lib_target */metalib_target)
 
 // This map variable allows us to look up global variables that might
 // be defined in a particular Sources.pp, e.g. in the "toplevel" file.
@@ -51,10 +51,10 @@
 // Windows).
 #if $[WINDOWS_PLATFORM]
   #map static_libs TARGET(*/static_lib_target */ss_lib_target)
-  #map dynamic_libs TARGET(*/lib_target */noinst_lib_target */metalib_target)
+  #map dynamic_libs TARGET(*/lib_target */noinst_lib_target */test_lib_target */metalib_target)
 #else
   #map static_libs TARGET(*/static_lib_target)
-  #map dynamic_libs TARGET(*/lib_target */ss_lib_target */noinst_lib_target */metalib_target)
+  #map dynamic_libs TARGET(*/lib_target */ss_lib_target */noinst_lib_target */test_lib_target */metalib_target)
 #endif
 
 // This lets us identify which metalib, if any, is including each
@@ -63,7 +63,7 @@
 #map module COMPONENT_LIBS(*/metalib_target)
 
 // This lets up look up components of a particular metalib.
-#map components TARGET(*/lib_target */noinst_lib_target)
+#map components TARGET(*/lib_target */noinst_lib_target */test_lib_target)
 
 // And this lets us look up source directories by dirname.
 #map dirnames DIRNAME(*/)
@@ -114,7 +114,7 @@
 
 #if $[HAVE_SOXST]
   #define soxst_ipath $[wildcard $[SOXST_IPATH]]
-  #define soxst_lpath $[wildcard $[SOXST_LPATH]] 
+  #define soxst_lpath $[wildcard $[SOXST_LPATH]]
   #define soxst_cflags $[SOXST_CFLAGS]
   #define soxst_libs $[SOXST_LIBS]
 #endif
@@ -293,7 +293,7 @@
   $[if $[ne $[NO_COMBINED_SOURCES],], $[INCLUDED_SOURCES], $[get_combined_sources]]
 
 #defer included_sources $[INCLUDED_SOURCES]
-  
+
 // This variable returns the set of sources that are to be
 // interrogated for the current target.
 #defer get_igatescan \
@@ -326,12 +326,13 @@
 // This variable returns the set of external packages used by this
 // target, and by all the components shared by this target.
 #defer use_packages $[sort $[USE_PACKAGES] $[components $[USE_PACKAGES],$[active_component_libs]]]
-    
+
 // This function returns the appropriate cflags for the target, based
 // on the various external packages this particular target claims to
 // require.
 #defun get_cflags
-  #define alt_cflags $[stl_cflags] $[nspr_cflags] $[python_cflags]
+  // hack to add stl,nspr,python.  should be removed
+  #define alt_cflags $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_cflags] $[nspr_cflags] $[python_cflags]]
 
   #foreach package $[use_packages]
     #set alt_cflags $[alt_cflags] $[$[package]_cflags]
@@ -345,8 +346,9 @@
 // claims to require.  This returns a space-separated set of directory
 // names only; the -I switch is not included here.
 #defun get_ipath
-  #define alt_ipath $[stl_ipath] $[nspr_ipath] $[python_ipath]
-  
+  // hack to add stl,nspr,python.  should be removed
+  #define alt_ipath $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_ipath] $[nspr_ipath] $[python_ipath]]
+
   #foreach package $[use_packages]
     #set alt_ipath $[alt_ipath] $[$[package]_ipath]
   #end package
@@ -359,11 +361,11 @@
 // target claims to require.  This returns a space-separated set of
 // directory names only; the -L switch is not included here.
 #defun get_lpath
-  #define alt_lpath $[stl_lpath] $[nspr_lpath] $[python_lpath]
-  
-  #if $[WINDOWS_PLATFORM]  
-    #set alt_lpath $[WIN32_PLATFORMSDK_LIBPATH] $[alt_lpath] 
-  #endif  
+  #define alt_lpath $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_lpath] $[nspr_lpath] $[python_lpath]]
+
+  #if $[WINDOWS_PLATFORM]
+    #set alt_lpath $[WIN32_PLATFORMSDK_LIBPATH] $[alt_lpath]
+  #endif
 
   #foreach package $[use_packages]
     #set alt_lpath $[alt_lpath] $[$[package]_lpath]
@@ -378,7 +380,7 @@
 // space-separated set of library names only; the -l switch is not
 // included here.
 #defun get_libs
-  #define alt_libs $[stl_libs] $[nspr_libs] $[python_libs] $[TARGET_LIBS]
+  #define alt_libs $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_libs] $[nspr_libs] $[python_libs]]
 
   #if $[WINDOWS_PLATFORM]
     #set alt_libs $[alt_libs] $[WIN_SYS_LIBS] $[components $[WIN_SYS_LIBS],$[active_component_libs] $[transitive_link]]
@@ -412,7 +414,7 @@
     $[dependencies $[source]]
   #endif
 #end get_depends
-  
+
 
 // This function determines the set of libraries our various targets
 // depend on.  This is a complicated definition.  It is the union of
@@ -425,7 +427,7 @@
 // the same as case (b) above.
 #defun get_depend_libs
   #define depend_libs
-  #forscopes lib_target noinst_lib_target
+  #forscopes lib_target noinst_lib_target test_lib_target
     #define metalib $[module $[TARGET],$[TARGET]]
     #if $[ne $[metalib],]
       // This library is included on a metalib.
@@ -455,8 +457,8 @@
         #endif
       #end depend
     #endif
-  #end lib_target noinst_lib_target
-  
+  #end lib_target noinst_lib_target test_lib_target
+
   // These will never be part of a metalib.
   #forscopes static_lib_target ss_lib_target bin_target noinst_bin_target metalib_target
     #foreach depend $[LOCAL_LIBS]

+ 107 - 47
dtool/pptempl/Template.gmsvc.pp

@@ -55,15 +55,25 @@
   // $[lib_targets] will be the list of dynamic libraries,
   // $[static_lib_targets] the list of static libraries, and
   // $[bin_targets] the list of binaries.  $[test_bin_targets] is the
-  // list of binaries that are to be built only when specifically asked
-  // for.
-  #define lib_targets $[patsubst %,$[ODIR]/lib%$[dllext].$[dlllib],$[active_target(metalib_target noinst_lib_target)] $[real_lib_targets]]
-  #define static_lib_targets $[active_target(static_lib_target ss_lib_target):%=$[ODIR]/lib%$[dllext].lib]
+  // list of binaries that are to be built only when specifically asked for.
+
+  // #set requires pre-existing vars
+  #define lib_targets
+  #define static_lib_targets
+
+  #forscopes lib_target noinst_lib_target test_lib_target
+    // get_dllname() needs to be evaluated in its lib's scope, but we need to build a global list, so use #set
+    #set lib_targets $[patsubst %,$[ODIR]/$[get_dllname %].$[dlllib],$[active_target(metalib_target noinst_lib_target test_lib_target)] $[real_lib_targets]]
+    #set static_lib_targets $[active_target(static_lib_target ss_lib_target):%=$[ODIR]/$[get_dllname %].lib]
+  #end lib_target noinst_lib_target test_lib_target
+
   #define bin_targets \
       $[active_target(bin_target noinst_bin_target):%=$[ODIR]/%.exe] \
       $[active_target(sed_bin_target):%=$[ODIR]/%]
   #define test_bin_targets $[active_target(test_bin_target):%=$[ODIR]/%.exe]
 
+  #defer test_lib_targets $[active_target(test_lib_target):%=$[if $[TEST_ODIR],$[TEST_ODIR],$[ODIR]]/%.$[dlllib]]
+
   // And these variables will define the various things we need to
   // install.
   #define install_lib $[active_target(metalib_target static_lib_target ss_lib_target)] $[real_lib_targets]
@@ -77,15 +87,15 @@
 
   // These are the various sources collected from all targets within the
   // directory.
-  #define st_sources $[sort $[compile_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target)]]
-  #define yxx_st_sources $[sort $[yxx_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target)]]
-  #define lxx_st_sources $[sort $[lxx_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target)]]
-  #define dep_sources_1 $[sort $[get_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target)]]
+  #define st_sources $[sort $[compile_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target)]]
+  #define yxx_st_sources $[sort $[yxx_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target)]]
+  #define lxx_st_sources $[sort $[lxx_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target)]]
+  #define dep_sources_1  $[sort $[get_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target)]]
 
   // These are the source files that our dependency cache file will
   // depend on.  If it's an empty list, we won't bother writing rules to
   // freshen the cache file.
-  #define dep_sources $[sort $[filter %.c %.cxx %.yxx %.lxx %.h %.I %.T,$[dep_sources_1]]]
+  #define dep_sources $[sort $[filter %.c %.cxx %.cpp %.yxx %.lxx %.h %.I %.T,$[dep_sources_1]]]
 
 #endif  // $[build_directory]
 
@@ -107,8 +117,10 @@
 // tree) we should add to our -I list.  It's basically just one for
 // each directory named in the $[complete_local_libs], above, plus
 // whatever else the user might have explicitly named in
-// $[LOCAL_INCS].
-#defer complete_ipath $[all_libs $[RELDIR],$[complete_local_libs]] $[RELDIR($[LOCAL_INCS:%=%/])]
+// $[LOCAL_INCS].  LOCAL_INCS MUST be a ppremake src dir! (RELDIR only checks those)
+// To add an arbitrary extra include dir, define EXTRA_IPATH in the Sources.pp
+
+#defer complete_ipath $[all_libs $[RELDIR],$[complete_local_libs]] $[RELDIR($[LOCAL_INCS:%=%/])] $[EXTRA_IPATH]
 
 // $[target_ipath] is the proper ipath to put on the command line,
 // from the context of a particular target.
@@ -150,7 +162,7 @@
 // Similarly, we need to ensure that $[ODIR] exists.  Trying to make
 // the makefiles do this automatically just causes problems with
 // multiprocess builds.
-#mkdir $[ODIR]
+#mkdir $[ODIR] $[TEST_ODIR]
 
 // Pre-compiled headers are one way to speed the compilation of many
 // C++ source files that include similar headers, but it turns out a
@@ -198,7 +210,7 @@ MAKEFLAGS := -j$[NUMBER_OF_PROCESSORS]
 all : $[all_targets]
 
 // The 'test' rule makes all the test_bin_targets.
-test : $[test_bin_targets]
+test : $[test_bin_targets] $[test_lib_targets]
 
 clean : clean-igate
 #if $[st_sources]
@@ -343,7 +355,7 @@ igate : $[get_igatedb(metalib_target lib_target ss_lib_target)]
 
   #define varname $[subst -,_,lib$[TARGET]_so]
 $[varname] = $[sources]
-  #define target $[ODIR]/lib$[TARGET]$[dllext].$[dlllib]
+  #define target $[ODIR]/$[get_dllname $[TARGET]].$[dlllib]
   #define sources $($[varname])
   #define flags   $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%]
   #define mybasename $[basename $[notdir $[target]]]
@@ -358,14 +370,14 @@ $[TAB]  mkdir -p $[tmpdirname_cyg]  // this dir-creation-stuff is leftover from
  #define VER_RESOURCE "$[tmpdirname_win]\$[mybasename].res"
 $[TAB]  cl /nologo /EP "$[dtool_ver_dir]\verdate.cpp"  > "$[tmpdirname_win]\verdate.h"
 $[TAB]  rc /n /I"$[tmpdirname_win]" $[DECYGWINED_INC_PATHLIST_ARGS] /fo$[VER_RESOURCE] $[filter /D%, $[flags]]  "$[dtool_ver_dir]\version.rc"
-  #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
+  #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]]
 $[TAB] $[SHARED_LIB_C++] $[VER_RESOURCE]
   #else
 $[TAB] $[SHARED_LIB_C] $[VER_RESOURCE]
   #endif
 #else
 .NOTPARALLEL $[target] : $[sources] $[dtool_ver_dir_cyg]/$[DLLBASEADDRFILENAME]
-  #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
+  #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]]
 $[TAB] $[SHARED_LIB_C++]
   #else
 $[TAB] $[SHARED_LIB_C]
@@ -373,10 +385,10 @@ $[TAB] $[SHARED_LIB_C]
 #endif
 
 #if $[build_dlls]
-$[ODIR]/lib$[TARGET]$[dllext].lib : $[ODIR]/lib$[TARGET]$[dllext].dll
+$[ODIR]/$[get_dllname $[TARGET]].lib : $[ODIR]/$[get_dllname $[TARGET]].dll
 #endif
 #if $[build_pdbs]
-$[ODIR]/lib$[TARGET]$[dllext].pdb : $[ODIR]/lib$[TARGET]$[dllext].dll
+$[ODIR]/$[get_dllname $[TARGET]].pdb : $[ODIR]/$[get_dllname $[TARGET]].dll
 #endif
 
 #endif
@@ -385,9 +397,9 @@ $[ODIR]/lib$[TARGET]$[dllext].pdb : $[ODIR]/lib$[TARGET]$[dllext].dll
 // everything that goes along with it.
 #define installed_files \
     $[if $[build_it], \
-      $[if $[build_dlls],$[install_lib_dir]/lib$[TARGET]$[dllext].dll] \
-      $[install_lib_dir]/lib$[TARGET]$[dllext].lib \
-      $[if $[and $[build_dlls],$[build_pdbs]],$[install_lib_dir]/lib$[TARGET]$[dllext].pdb] \
+      $[if $[build_dlls],$[install_lib_dir]/$[get_dllname $[TARGET]].dll] \
+      $[install_lib_dir]/$[get_dllname $[TARGET]].lib \
+      $[if $[and $[build_dlls],$[build_pdbs]],$[install_lib_dir]/$[get_dllname $[TARGET]].pdb] \
     ] \
     $[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
     $[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
@@ -403,20 +415,20 @@ $[TAB] rm -f $[sort $[installed_files]]
 #endif
 
 #if $[build_dlls]
-$[install_lib_dir]/lib$[TARGET]$[dllext].dll : $[ODIR]/lib$[TARGET]$[dllext].dll
-#define local lib$[TARGET]$[dllext].dll
+$[install_lib_dir]/$[get_dllname $[TARGET]].dll : $[ODIR]/$[get_dllname $[TARGET]].dll
+#define local $[get_dllname $[TARGET]].dll
 #define dest $[install_lib_dir]
 $[TAB] cp -f $[ODIR]/$[local] $[dest]
 #endif
 
-$[install_lib_dir]/lib$[TARGET]$[dllext].lib : $[ODIR]/lib$[TARGET]$[dllext].lib
-#define local lib$[TARGET]$[dllext].lib
+$[install_lib_dir]/$[get_dllname $[TARGET]].lib : $[ODIR]/$[get_dllname $[TARGET]].lib
+#define local $[get_dllname $[TARGET]].lib
 #define dest $[install_lib_dir]
 $[TAB] cp -f $[ODIR]/$[local] $[dest]
 
 #if $[and $[build_dlls],$[build_pdbs]]
-$[install_lib_dir]/lib$[TARGET]$[dllext].pdb : $[ODIR]/lib$[TARGET]$[dllext].pdb
-#define local lib$[TARGET]$[dllext].pdb
+$[install_lib_dir]/$[get_dllname $[TARGET]].pdb : $[ODIR]/$[get_dllname $[TARGET]].pdb
+#define local $[get_dllname $[TARGET]].pdb
 #define dest $[install_lib_dir]
 $[TAB] cp -f $[ODIR]/$[local] $[dest]
 #endif
@@ -470,8 +482,6 @@ $[TAB] $[INTERROGATE_MODULE] -oc $[target] -module "$[igatemod]" -library "$[iga
 #end metalib_target lib_target
 
 
-
-
 /////////////////////////////////////////////////////////////////////
 // Now, the noninstalled dynamic libraries.  These are presumably used
 // only within this directory, or at the most within this tree, and
@@ -480,27 +490,72 @@ $[TAB] $[INTERROGATE_MODULE] -oc $[target] -module "$[igatemod]" -library "$[iga
 // lot simpler.
 /////////////////////////////////////////////////////////////////////
 
-#forscopes noinst_lib_target
+#forscopes noinst_lib_target test_lib_target
 #define varname $[subst -,_,lib$[TARGET]_so]
 $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
-#define target $[ODIR]/lib$[TARGET]$[dllext].$[dlllib]
+#define target $[ODIR]/$[get_dllname $[TARGET]].$[dlllib]
 #define sources $($[varname])
 $[target] : $[sources] $[static_lib_dependencies]
-#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
+#if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]]
 $[TAB] $[SHARED_LIB_C++]
 #else
-$[TAB] $[SHARED_LIB_C]
+$[TAB] $[SHARED_LIB_C] $[COMPILED_RESOURCES]
 #endif
 
 #if $[build_dlls]
-$[ODIR]/lib$[TARGET]$[dllext].lib : $[ODIR]/lib$[TARGET]$[dllext].dll
+$[ODIR]/$[get_dllname $[TARGET]].lib : $[ODIR]/$[get_dllname $[TARGET]].dll
 #endif
 #if $[build_pdbs]
-$[ODIR]/lib$[TARGET]$[dllext].pdb : $[ODIR]/lib$[TARGET]$[dllext].dll
+$[ODIR]/$[get_dllname $[TARGET]].pdb : $[ODIR]/$[get_dllname $[TARGET]].dll
+#endif
+
+// this section is all very clunky and not generalized enough
+// assuming tgt dirs and such
+
+#define rc_to_gen $[filter %.rc, $[GENERATED_SOURCES]]
+#if $[rc_to_gen]
+$[rc_to_gen] : $[GENERATED_RC_DEPENDENCIES]
+$[TAB] $[RC_GENERATOR_RULE]
+
+$[ODIR]/$[RC_BASENAME].res : $[rc_to_gen]
+$[TAB] $[COMPILE_RC] /I"$[ODIR]" /Fo"$[ODIR]/$[RC_BASENAME].res" $[ODIR]/$[RC_BASENAME].rc
 #endif
 
-#end noinst_lib_target
+#define inf_to_gen $[filter %.inf, $[GENERATED_SOURCES]]
+#if $[inf_to_gen]
+$[inf_to_gen] : $[GENERATED_INF_DEPENDENCIES]
+$[TAB] $[INF_GENERATOR_RULE]
+#endif
+
+#define rgs_to_gen $[filter %.rgs, $[GENERATED_SOURCES]]
+#if $[rgs_to_gen]
+$[rgs_to_gen] : $[GENERATED_RGS_DEPENDENCIES]
+$[TAB] $[RGS_GENERATOR_RULE]
+#endif
+
+#define MIDL_COMMAND $[COMPILE_IDL] /cstub $[ODIR]/$[IDL_BASENAME].cpp /tlb $[ODIR]/$[IDL_BASENAME].tlb /h $[ODIR]/$[IDL_BASENAME].h /proxy $[ODIR]/$[IDL_BASENAME]_p.c /dlldata $[ODIR]/dlldata.c /iid $[ODIR]/$[IDL_BASENAME]_i.c $[ODIR]/$[IDL_BASENAME].idl
+
+#define idl_to_gen $[filter %.idl, $[GENERATED_SOURCES]]
+#if $[idl_to_gen]
+$[idl_to_gen] : $[GENERATED_IDL_DEPENDENCIES]
+$[TAB] $[IDL_GENERATOR_RULE]
+
+.NOTPARALLEL $[ODIR]/$[IDL_BASENAME].h : $[idl_to_gen]
+$[TAB] $[MIDL_COMMAND]
 
+// this is a complete hack.  I dont know how add a generated .h to the dependency list of $[IDL_BASENAME].cpp.
+// it is already there, but in the wrong directory.  should really add this to official dependency list
+#foreach file $[GENERATED_IDL_H_DEPENDENTS]
+$[file] : $[ODIR]/$[IDL_BASENAME].h
+$[TAB]  // empty, dependency-only 'rule'
+
+#end file
+
+$[ODIR]/$[IDL_BASENAME].tlb : $[idl_to_gen]
+$[TAB] $[MIDL_COMMAND]
+#endif
+
+#end noinst_lib_target test_lib_target
 
 
 /////////////////////////////////////////////////////////////////////
@@ -512,17 +567,17 @@ $[ODIR]/lib$[TARGET]$[dllext].pdb : $[ODIR]/lib$[TARGET]$[dllext].dll
 #forscopes static_lib_target ss_lib_target
 #define varname $[subst -,_,lib$[TARGET]_a]
 $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
-#define target $[ODIR]/lib$[TARGET]$[dllext].lib
+#define target $[ODIR]/$[get_dllname $[TARGET]].lib
 #define sources $($[varname])
 $[target] : $[sources]
-#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
+#if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]]
 $[TAB] $[STATIC_LIB_C++]
 #else
 $[TAB] $[STATIC_LIB_C]
 #endif
 
 #define installed_files \
-    $[install_lib_dir]/lib$[TARGET]$[dllext].lib \
+    $[install_lib_dir]/$[get_dllname $[TARGET]].lib \
     $[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
     $[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
     $[INSTALL_DATA:%=$[install_data_dir]/%] \
@@ -535,8 +590,8 @@ uninstall-lib$[TARGET] :
 $[TAB] rm -f $[sort $[installed_files]]
 #endif
 
-$[install_lib_dir]/lib$[TARGET]$[dllext].lib : $[ODIR]/lib$[TARGET]$[dllext].lib
-#define local lib$[TARGET]$[dllext].lib
+$[install_lib_dir]/$[get_dllname $[TARGET]].lib : $[ODIR]/$[get_dllname $[TARGET]].lib
+#define local $[get_dllname $[TARGET]].lib
 #define dest $[install_lib_dir]
 $[TAB] cp -f $[ODIR]/$[local] $[dest]
 
@@ -597,7 +652,7 @@ $[target] : $[sources] $[static_lib_dependencies]
 $[TAB] $[ld] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
 #else
   // Otherwise, we can use the normal linker.
-  #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
+  #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]]
 $[TAB] $[LINK_BIN_C++]
   #else
 $[TAB] $[LINK_BIN_C]
@@ -655,7 +710,7 @@ $[TAB] cp -f $[output_exe] $[install_bin_dir]
 // of being built (when requested), but having no install rules.
 /////////////////////////////////////////////////////////////////////
 
-#forscopes noinst_bin_target test_bin_target
+#forscopes noinst_bin_target test_bin_target test_lib_target
 $[TARGET] : $[ODIR]/$[TARGET].exe
 
 #define varname $[subst -,_,bin_$[TARGET]]
@@ -663,13 +718,13 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
 #define target $[ODIR]/$[TARGET].exe
 #define sources $($[varname])
 $[target] : $[sources] $[static_lib_dependencies]
-#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
+#if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]]
 $[TAB] $[LINK_BIN_C++]
 #else
 $[TAB] $[LINK_BIN_C]
 #endif
 
-#end noinst_bin_target test_bin_target
+#end noinst_bin_target test_bin_target test_lib_target
 
 /////////////////////////////////////////////////////////////////////
 // Rules to run bison and/or flex as needed.
@@ -727,7 +782,11 @@ $[TAB] cp $[target_prebuilt] $[target]
 // file.
 /////////////////////////////////////////////////////////////////////
 
-#forscopes metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
+#forscopes metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target
+// need to use #print to avoid printing to Makefile
+// printvar prints the unevaluated defn of the var
+// #print TARGET=$[TARGET]
+// #printvar TARGET
 
 // Rules to compile ordinary C files.
 #foreach file $[sort $[c_sources]]
@@ -766,7 +825,7 @@ $[TAB] $[COMPILE_C++]
 
 #end file
 
-#end metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
+#end metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target
 
 // And now the rules to install the auxiliary files, like headers and
 // data files.
@@ -969,3 +1028,4 @@ $[TAB] cp -f $[local] $[dest]
 
 //////////////////////////////////////////////////////////////////////
 #endif // DIR_TYPE
+

+ 103 - 96
dtool/pptempl/compilerSettings.pp

@@ -4,199 +4,206 @@
   #define LINKER link
   #define LIBBER lib
   #define COMMONFLAGS /Gi-
-  
+
   // use "unsafe" QIfist flt->int rounding only if FAST_FLT_TO_INT is defined
-  #define OPTFLAGS /O2 /Ob1 /G6 $[if $[ne $[FAST_FLT_TO_INT],], /QIfist,]  
-  #define OPT1FLAGS /GZ 
+  #define OPTFLAGS /O2 /Ob1 /G6 $[if $[ne $[FAST_FLT_TO_INT],], /QIfist,]
+  #define OPT1FLAGS /GZ
 
   // Note: Zi cannot be used on multiproc builds with precomp hdrs, Z7 must be used instead
-  #defer DEBUGPDBFLAGS /Zi /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"  
+  #defer DEBUGPDBFLAGS /Zi /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"
   #defer DEBUGFLAGS /MDd $[BROWSEINFO_FLAG] $[DEBUGINFOFLAGS] $[DEBUGPDBFLAGS]
   #define RELEASEFLAGS /MD
-  #define WARNING_LEVEL_FLAG /W3  
-  
-  // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs    
-  #define LDFLAGS_OPT1 /NODEFAULTLIB:MSVCRT.LIB 
-  #define LDFLAGS_OPT2 /NODEFAULTLIB:MSVCRT.LIB 
+  #define WARNING_LEVEL_FLAG /W3
+
+  // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
+  #define LDFLAGS_OPT1 /NODEFAULTLIB:MSVCRT.LIB
+  #define LDFLAGS_OPT2 /NODEFAULTLIB:MSVCRT.LIB
   #define LDFLAGS_OPT3 /NODEFAULTLIB:MSVCRTD.LIB /OPT:REF
   #define LDFLAGS_OPT4 /NODEFAULTLIB:MSVCRTD.LIB /OPT:REF $[LDFLAGS_OPT4]
-  
+
   #define MAPINFOFLAGS /MAPINFO:EXPORTS /MAPINFO:FIXUPS /MAPINFO:LINES
-  
+
   #if $[ENABLE_PROFILING]
       // note according to docs, this should force /PDB:none /DEBUGTYPE:cv, so no pdb file is generated for debug??  (doesnt seem to be true)
-    #define PROFILE_FLAG /PROFILE 
+    #define PROFILE_FLAG /PROFILE
   #else
-    #define PROFILE_FLAG 
+    #define PROFILE_FLAG
   #endif
- 
-  // Note: all Opts will link w/debug info now 
-  #define LINKER_FLAGS /DEBUG /DEBUGTYPE:CV $[PROFILE_FLAG] /MAP $[MAPINFOFLAGS] /fixed:no /incremental:no /WARN:3 
-  
-// in case we have mixed intel/msvc build
-  #define EXTRA_LIBPATH /ia32/lib
-  #define EXTRA_INCPATH /ia32/include    
+
+  // Note: all Opts will link w/debug info now
+  #define LINKER_FLAGS /DEBUG /DEBUGTYPE:CV $[PROFILE_FLAG] /MAP $[MAPINFOFLAGS] /fixed:no /incremental:no /WARN:3
+
+// for mixed intel/msvc build, add these
+//  #define EXTRA_LIBPATH /ia32/lib
+//  #define EXTRA_INCPATH /ia32/include
 
   #if $[or $[ne $[FORCE_INLINING],],$[>= $[OPTIMIZE],2]]
       #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
-  #endif 
-  
+  #endif
+
   // ensure pdbs are copied to install dir
-  #define build_pdbs yes  
-  
+  #define build_pdbs yes
+
   #define STL_ALLOCATOR VC6
-  
+
 #elif $[or $[eq $[USE_COMPILER], MSVC7], $[eq $[USE_COMPILER], MSVC7_1]]
 
   #define COMPILER cl
   #define LINKER link
   #define LIBBER lib
 
-  #if $[eq $[USE_COMPILER], MSVC7]  
+  #if $[eq $[USE_COMPILER], MSVC7]
     // What is the syntax of the STL allocator declaration?  See
     // LocalSetup.pp for allowable values.
     #define STL_ALLOCATOR MODERN
   #else
     // until I figure out how to get rid of 'rebind' vc7.1 C4346 build errors
     #define STL_ALLOCATOR UNKNOWN
-  #endif  
+  #endif
 
   #if $[eq $[NO_CROSSOBJ_OPT],]
      #define DO_CROSSOBJ_OPT 1
-  #endif 
-  
+  #endif
+
   #if $[DO_CROSSOBJ_OPT]
      #define OPT4FLAGS /GL
      #define LDFLAGS_OPT4 /LTCG
-     #if $[>= $[OPTIMIZE],4] 
+     #if $[>= $[OPTIMIZE],4]
         #define LIBBER $[LIBBER] /LTCG
-     #endif 
-  #endif 
-  
+     #endif
+  #endif
+
   #define CDEFINES_OPT1
   #define CDEFINES_OPT2
   #define CDEFINES_OPT3
   #define CDEFINES_OPT4
 
-  // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs  
-  #define LDFLAGS_OPT1 /NODEFAULTLIB:MSVCRT.LIB 
-  #define LDFLAGS_OPT2 /NODEFAULTLIB:MSVCRT.LIB 
+  // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
+
+  #define LDFLAGS_OPT1 /NODEFAULTLIB:MSVCRT.LIB
+  #define LDFLAGS_OPT2 /NODEFAULTLIB:MSVCRT.LIB
   #define LDFLAGS_OPT3 /NODEFAULTLIB:MSVCRTD.LIB /OPT:REF
   #define LDFLAGS_OPT4 /NODEFAULTLIB:MSVCRTD.LIB /OPT:REF $[LDFLAGS_OPT4]
 
   #define COMMONFLAGS /DHAVE_DINKUM /Zc:forScope
 
   // use "unsafe" QIfist flt->int rounding only if FAST_FLT_TO_INT is defined
-  #define OPTFLAGS /O2 /Ob2 /G6 $[if $[ne $[FAST_FLT_TO_INT],], /QIfist,]
-  
-//  #define OPT1FLAGS /RTCsu /GS  removing /RTCu because it crashes in dxgsg with internal compiler bug
+  #define REGULAR_OPTFLAGS /O2 /Ob2 /G6 $[if $[ne $[FAST_FLT_TO_INT],], /QIfist,]
+
+  #defer OPTFLAGS $[if $[OPT_MINSIZE],/O1 /Og /Ob1 /Oi /Os /G6,$[REGULAR_OPTFLAGS]]
+
+  //  #define OPT1FLAGS /RTCsu /GS  removing /RTCu because it crashes in dxgsg with internal compiler bug
   #define OPT1FLAGS /RTCs /GS
-  
-//  #define WARNING_LEVEL_FLAG /Wall  //this is scary
+
+  //  #define WARNING_LEVEL_FLAG /Wall  //this is scary
   #define WARNING_LEVEL_FLAG /W3   // WL
 
   // Note: Zi cannot be used on multiproc builds with precomp hdrs, Z7 must be used instead
-  #defer DEBUGPDBFLAGS /Zi /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"  
-  #defer DEBUGFLAGS /MDd $[BROWSEINFO_FLAG] $[DEBUGINFOFLAGS] $[DEBUGPDBFLAGS]
-  #define RELEASEFLAGS /MD
-  
+  #defer DEBUGPDBFLAGS /Zi /Fd"$[osfilename $[patsubst %.obj,%.pdb, $[target]]]"
+
+  // if LINK_FORCE_STATIC_C_RUNTIME is defined, it always links with static c runtime (release version
+  // for both Opt1 and Opt4!) instead of the msvcrt dlls
+
+  #defer DEBUGFLAGS $[if $[ne $[LINK_FORCE_STATIC_RELEASE_C_RUNTIME],],/MT, /MDd] $[BROWSEINFO_FLAG] $[DEBUGINFOFLAGS] $[DEBUGPDBFLAGS]
+  #defer RELEASEFLAGS $[if $[ne $[LINK_FORCE_STATIC_RELEASE_C_RUNTIME],],/MT, /MD]
+
   #define MAPINFOFLAGS /MAPINFO:EXPORTS /MAPINFO:LINES
-  
+
   #if $[ENABLE_PROFILING]
     #define PROFILE_FLAG /FIXED:NO
   #else
-    #define PROFILE_FLAG 
+    #define PROFILE_FLAG
   #endif
-  
+
   #if $[or $[ne $[FORCE_INLINING],],$[>= $[OPTIMIZE],2]]
-      #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
-  #endif 
- 
-  // Note: all Opts will link w/debug info now 
-  #define LINKER_FLAGS /DEBUG $[PROFILE_FLAG] /MAP $[MAPINFOFLAGS] /fixed:no /incremental:no 
-  
+      #defer EXTRA_CDEFS $[EXTRA_CDEFS] $[if $[OPT_MINSIZE],,FORCE_INLINING]
+  #endif
+
+  // Note: all Opts will link w/debug info now
+  #define LINKER_FLAGS /DEBUG $[PROFILE_FLAG] /MAP $[MAPINFOFLAGS] /fixed:no /incremental:no
+
 // in case we have mixed intel/msvc build
 //  #define EXTRA_LIBPATH /ia32/lib
-//  #define EXTRA_INCPATH /ia32/include  
+//  #define EXTRA_INCPATH /ia32/include
 
   // ensure pdbs are copied to install dir
-  #define build_pdbs yes  
-    
+  #define build_pdbs yes
+
 #elif $[eq $[USE_COMPILER], INTEL]
   #define COMPILER icl
   #define LINKER xilink
   #define LIBBER xilib
-  #define COMMONFLAGS /DHAVE_DINKUM /Gi- /Qwd985 /Qvc7 /G6 
-  
+  #define COMMONFLAGS /DHAVE_DINKUM /Gi- /Qwd985 /Qvc7 /G6
+
   // Note: Zi cannot be used on multiproc builds with precomp hdrs, Z7 must be used instead
-  #defer DEBUGPDBFLAGS /Zi /Qinline_debug_info /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"  
+  #defer DEBUGPDBFLAGS /Zi /Qinline_debug_info /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"
   // Oy- needed for MS debugger
-  #defer DEBUGFLAGS /Oy- /MDd $[BROWSEINFO_FLAG] $[DEBUGINFOFLAGS] $[DEBUGPDBFLAGS] 
+  #defer DEBUGFLAGS /Oy- /MDd $[BROWSEINFO_FLAG] $[DEBUGINFOFLAGS] $[DEBUGPDBFLAGS]
   #define RELEASEFLAGS /MD
-  #define WARNING_LEVEL_FLAG /W3    
-  
+  #define WARNING_LEVEL_FLAG /W3
+
   #if $[DO_CROSSOBJ_OPT]
      #define OPT4FLAGS /Qipo
      #define LDFLAGS_OPT4 /Qipo
-  #endif   
-  
+  #endif
+
   // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
-  #define LDFLAGS_OPT1 /NODEFAULTLIB:MSVCRT.LIB 
-  #define LDFLAGS_OPT2 /NODEFAULTLIB:MSVCRT.LIB 
+  #define LDFLAGS_OPT1 /NODEFAULTLIB:MSVCRT.LIB
+  #define LDFLAGS_OPT2 /NODEFAULTLIB:MSVCRT.LIB
   #define LDFLAGS_OPT3 /NODEFAULTLIB:MSVCRTD.LIB /OPT:REF
   #define LDFLAGS_OPT4 /NODEFAULTLIB:MSVCRTD.LIB /OPT:REF $[LDFLAGS_OPT4]
-  
-//  #define OPTFLAGS /O3 /Qipo /QaxW /Qvec_report1 
+
+//  #define OPTFLAGS /O3 /Qipo /QaxW /Qvec_report1
   #define OPTFLAGS /O3 /Qip
-  
+
   // use "unsafe" QIfist flt->int rounding only if FAST_FLT_TO_INT is defined
-  #define OPTFLAGS $[OPTFLAGS] $[if $[ne $[FAST_FLT_TO_INT],], /QIfist,]  
-  
+  #define OPTFLAGS $[OPTFLAGS] $[if $[ne $[FAST_FLT_TO_INT],], /QIfist,]
+
   #define OPT1FLAGS /GZ /Od
   // We assume the Intel compiler installation dir is mounted as /ia32.
   #define EXTRA_LIBPATH /ia32/lib
-  #define EXTRA_INCPATH /ia32/include  
-  
+  #define EXTRA_INCPATH /ia32/include
+
   #if $[or $[ne $[FORCE_INLINING],],$[>= $[OPTIMIZE],2]]
       #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
-  #endif   
-  
-  // Note: all Opts will link w/debug info now 
+  #endif
+
+  // Note: all Opts will link w/debug info now
   #define LINKER_FLAGS /DEBUG /DEBUGTYPE:CV $[PROFILE_FLAG] /MAP $[MAPINFOFLAGS] /fixed:no /incremental:no
-  
+
   // ensure pdbs are copied to install dir
-  #define build_pdbs yes    
-  
+  #define build_pdbs yes
+
 #elif $[eq $[USE_COMPILER], BOUNDS] // NuMega BoundsChecker
   #define COMPILER nmcl
   #define LINKER nmlink
   #define LIBBER lib
   #define COMMONFLAGS
   #define OPTFLAGS /O2 /Ogity /G6
-  #define OPT1FLAGS /GZ   
-  #defer DEBUGPDBFLAGS /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"  
+  #define OPT1FLAGS /GZ
+  #defer DEBUGPDBFLAGS /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"
   #define RELEASEFLAGS /MD
   #define EXTRA_LIBPATH
   #define EXTRA_INCPATH
   #if $[BOUNDS_TRUETIME] // NuMega BoundsChecker TrueTime Profiler
-    // This may look like a bad thing (to extend the compiler 
-    // and linker with a switch), but I think it's the right 
+    // This may look like a bad thing (to extend the compiler
+    // and linker with a switch), but I think it's the right
     // thing to do in this case -- skyler.
     #define COMPILER $[COMPILER] /NMttOn
     #define LINKER $[LINKER] /NMttOn
-  #endif 
-  
+  #endif
+
 #elif $[eq $[USE_COMPILER], TRUETIME] // NuMega TrueTime Profiler
-  // This may look like a bad thing (to extend the compiler 
-  // and linker with a switch), but I think it's the right 
+  // This may look like a bad thing (to extend the compiler
+  // and linker with a switch), but I think it's the right
   // thing to do in this case -- skyler.
   #define COMPILER nmcl /NMttOn
   #define LINKER nmlink /NMttOn
   #define LIBBER lib
   #define COMMONFLAGS
   #define OPTFLAGS /O2 /Ogity /G6
-  #define OPT1FLAGS /GZ   
-  #defer DEBUGPDBFLAGS /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"  
+  #define OPT1FLAGS /GZ
+  #defer DEBUGPDBFLAGS /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[patsubst %.obj,%.pdb,$[target]]]"
   #define RELEASEFLAGS /MD
   #define EXTRA_LIBPATH
   #define EXTRA_INCPATH
@@ -205,14 +212,14 @@
 #endif
 
 #if $[CHECK_SYNTAX_ONLY]
-#define END_CFLAGS $[END_CFLAGS] /Zs 
-#endif 
-  
+#define END_CFLAGS $[END_CFLAGS] /Zs
+#endif
+
 #if $[GEN_ASSEMBLY]
 #define END_CFLAGS $[END_CFLAGS] /FAs
-#endif 
+#endif
 
 #if $[PREPROCESSOR_OUTPUT]
-#define END_CFLAGS $[END_CFLAGS] /E 
-#endif 
+#define END_CFLAGS $[END_CFLAGS] /E
+#endif