diff --git a/dtool/pptempl/Global.gmsvc.pp b/dtool/pptempl/Global.gmsvc.pp index 384c19bfaa..5791ca20a2 100644 --- a/dtool/pptempl/Global.gmsvc.pp +++ b/dtool/pptempl/Global.gmsvc.pp @@ -6,8 +6,10 @@ // Template.gmsvc.pp. // -#if $[< $[PPREMAKE_VERSION],0.58] - #error You need at least ppremake version 0.58 to use BUILD_TYPE gmsvc. +#define REQUIRED_VERSION 1.00 + +#if $[< $[PPREMAKE_VERSION],$[REQUIRED_VERSION]] + #error You need at least ppremake version $[REQUIRED_VERSION] to use BUILD_TYPE gmsvc. #endif #defun get_metalibs target,complete_libs @@ -59,6 +61,10 @@ #define BROWSEINFO_FLAG #endif +#if $[eq $[NO_PCH],] +#define DO_PCH 1 +#endif + #define CFLAGS_SHARED // Define LINK_ALL_STATIC to generate static libs instead of DLL's. @@ -74,6 +80,24 @@ #define dlllib dll #endif +// multi-processor PCH cannot use .pdb debug fmt because +// .pdb file name must be the same for obj and pch header obj +// and currently every cxx generates its own separate pdb +// to avoid write file conflict in multi-proc build + +#if $[NO_PCH] +// different .pdb for every .obj +#defer DEBUG_TYPE_FLAGS /Zi /Fd"$[osfilename $[target:%.obj=%.pdb]]" +#elif $[eq $[NUMBER_OF_PROCESSORS],1] +// no multi-proc, so can use same .pdb file for each compile +//#defer DEBUG_TYPE_FLAGS /Zi /Fd"$[osfilename $[st_dir]/$[TARGET].pdb]" +#defer DEBUG_TYPE_FLAGS /Zi /Fd"$[osfilename $[target_dirname].pdb]" +#else +// puts dbg info inside first .obj +#defer DEBUG_TYPE_FLAGS /Z7 +#define NO_PDB 1 +#endif + #include $[THISDIRPREFIX]compilerSettings.pp #define WARNING_LEVEL_FLAG /W3 @@ -92,7 +116,7 @@ #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] $[EXTRA_CDEFS] // /GZ disables OPT flags, so OPT1 only -#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[OPT1FLAGS] $[DEBUGFLAGS] +#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] #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] @@ -131,9 +155,18 @@ #defer extra_cflags /EHsc /Zm250 /DWIN32_VC /DWIN32 $[WARNING_LEVEL_FLAG] $[END_CFLAGS] -#defer COMPILE_C $[COMPILER] /nologo /c /Fo"$[osfilename $[target]]" $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath]] $[flags] $[extra_cflags] $[source] +#defer MAIN_C_COMPILE_ARGS /nologo /c $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath]] $[flags] $[extra_cflags] $[source] + +#defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS] #defer COMPILE_C++ $[COMPILE_C] +#if $[DO_PCH] +#defer MAIN_C_COMPILE_ARGS_PCH /Fp"$[osfilename $[target_pch]]" $[MAIN_C_COMPILE_ARGS] +#defer COMPILE_C_WITH_PCH $[COMPILER] /Yu /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS_PCH] +#defer COMPILE_CSTYLE_PCH $[COMPILER] /TC /Yc /Fo"$[osfilename $[target_obj]]" $[MAIN_C_COMPILE_ARGS_PCH] +#defer COMPILE_CXXSTYLE_PCH $[COMPILER] /TP /Yc /Fo"$[osfilename $[target_obj]]" $[MAIN_C_COMPILE_ARGS_PCH] +#endif + #defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]" #defer STATIC_LIB_C++ $[STATIC_LIB_C] diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index 38ab44b028..bd03eb3147 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -292,6 +292,7 @@ // target. #defer get_sources \ $[SOURCES] \ + $[PRECOMPILED_HEADER] \ $[if $[HAVE_CRYPTO],$[IF_CRYPTO_SOURCES]] \ $[if $[HAVE_JPEG],$[IF_JPEG_SOURCES]] \ $[if $[HAVE_TIFF],$[IF_TIFF_SOURCES]] \ @@ -304,6 +305,7 @@ #defer all_sources \ $[SOURCES] \ + $[PRECOMPILED_HEADER] \ $[IF_CRYPTO_SOURCES] \ $[IF_JPEG_SOURCES] \ $[IF_TIFF_SOURCES] \ @@ -336,6 +338,16 @@ $[if $[and $[run_interrogate],$[IGATESCAN]], \ lib$[TARGET]_igate.cxx] +#defer get_precompiled_header $[PRECOMPILED_HEADER] + +// This variable returns the name of the fake precompiled header cxx +// that will be used to force linking of the generated pch .obj into libs +// returns non-empty if sources var contains a *_headers.h +// should probably use PRECOMPILED_HEADER var directly here instead +#defer get_pch_outputcxx \ + $[if $[and $[DO_PCH], $[filter %_headers.h, $[get_sources]]], \ + $[TARGET]_headers.cxx] + // This variable returns the name of the interrogate module, if the // current metalib target should include one, or empty string if it // should not. @@ -343,8 +355,6 @@ $[if $[and $[run_interrogate],$[components $[IGATESCAN],$[active_component_libs]]], \ $[TARGET]] - - // This function returns the appropriate cflags for the target, based // on the various external packages this particular target claims to // require. diff --git a/dtool/pptempl/Template.gmsvc.pp b/dtool/pptempl/Template.gmsvc.pp index f86aef3f9e..68fcf335b1 100644 --- a/dtool/pptempl/Template.gmsvc.pp +++ b/dtool/pptempl/Template.gmsvc.pp @@ -112,6 +112,14 @@ #define lxx_so_sources $[filter %.lxx,$[so_sources]] #define lxx_st_sources $[filter %.lxx,$[st_sources]] +#if $[DO_PCH] +#define pch_header_source $[get_precompiled_header(metalib_target lib_target noinst_lib_target)] + +#define st_pch_files $[patsubst %.h,$[st_dir]/%.pch,$[pch_header_source]] +#define st_pch_obj_files $[patsubst %.h,$[st_dir]/%.obj,$[pch_header_source]] + +#endif + // This map variable gets us all the various source files from all the // targets in this directory. We need it to look up the context in // which to build a particular source file, since some targets may @@ -194,22 +202,23 @@ test : $[test_bin_targets] // It does assume that the odirs are not '.', however. clean : #if $[so_sources] -$[TAB]rm -rf $[so_dir] +$[TAB] rm -rf $[so_dir] #endif #if $[st_sources] -$[TAB]rm -rf $[st_dir] +$[TAB] rm -rf $[st_dir] #endif -$[TAB]rm -f *.pyc *.pyo // Also scrub out old generated Python code. +$[TAB] rm -f *.pyc *.pyo // Also scrub out old generated Python code. + // 'cleanall' is not much more thorough than 'clean': At the moment, // it also cleans up the bison and flex output, as well as the // dependency cache file. cleanall : clean #if $[yxx_so_sources] $[yxx_st_sources] $[lxx_so_sources] $[lxx_st_sources] -$[TAB]rm -f $[patsubst %.yxx %.lxx,%.cxx,$[yxx_so_sources] $[yxx_st_sources] $[lxx_so_sources] $[lxx_st_sources]] +$[TAB] rm -f $[patsubst %.yxx %.lxx,%.cxx,$[yxx_so_sources] $[yxx_st_sources] $[lxx_so_sources] $[lxx_st_sources]] #endif #if $[ne $[DEPENDENCY_CACHE_FILENAME],] -$[TAB]rm -f $[DEPENDENCY_CACHE_FILENAME] +$[TAB] rm -f $[DEPENDENCY_CACHE_FILENAME] #endif clean-igate : @@ -219,13 +228,13 @@ clean-igate : #define igatemscan $[components $[get_igatedb:%=$[RELDIR]/$[so_dir]/%],$[active_component_libs]] #define igatemout $[if $[igatemscan],lib$[TARGET]_module.cxx] #if $[igatedb] -$[TAB]rm -f $[so_dir]/$[igatedb] +$[TAB] rm -f $[so_dir]/$[igatedb] #endif #if $[igateoutput] -$[TAB]rm -f $[so_dir]/$[igateoutput] $[igateoutput:%.cxx=$[so_dir]/%.obj] +$[TAB] rm -f $[so_dir]/$[igateoutput] $[igateoutput:%.cxx=$[so_dir]/%.obj] #endif #if $[igatemout] -$[TAB]rm -f $[so_dir]/$[igatemout] $[igatemout:%.cxx=$[so_dir]/%.obj] +$[TAB] rm -f $[so_dir]/$[igatemout] $[igatemout:%.cxx=$[so_dir]/%.obj] #endif #end metalib_target lib_target ss_lib_target @@ -262,12 +271,12 @@ install-igate : $[sort $[installed_igate_files]] uninstall : $[active_target(metalib_target lib_target static_lib_target ss_lib_target):%=uninstall-lib%] $[active_target(bin_target):%=uninstall-%] #if $[installed_files] -$[TAB]rm -f $[sort $[installed_files]] +$[TAB] rm -f $[sort $[installed_files]] #endif uninstall-igate : #if $[installed_igate_files] -$[TAB]rm -f $[sort $[installed_igate_files]] +$[TAB] rm -f $[sort $[installed_igate_files]] #endif @@ -284,8 +293,8 @@ $[TAB]rm -f $[sort $[installed_igate_files]] $[if $[install_igatedb],$[install_igatedb_dir]] \ ] $[directory] : -$[TAB]@test -d $[directory] || echo mkdir -p $[directory] -$[TAB]@test -d $[directory] || mkdir -p $[directory] +$[TAB] @test -d $[directory] || echo mkdir -p $[directory] +$[TAB] @test -d $[directory] || mkdir -p $[directory] #end directory // We need to make the .obj files depend on the $[so_dir] and @@ -298,9 +307,9 @@ $[TAB]@test -d $[directory] || mkdir -p $[directory] $[if $[st_sources],$[st_dir]] \ ] $[directory]/stamp : -$[TAB]@test -d $[directory] || echo mkdir -p $[directory] -$[TAB]@test -d $[directory] || mkdir -p $[directory] -$[TAB]@touch $[directory]/stamp +$[TAB] @test -d $[directory] || echo mkdir -p $[directory] +$[TAB] @test -d $[directory] || mkdir -p $[directory] +$[TAB] @touch $[directory]/stamp #end directory @@ -353,9 +362,11 @@ $[TAB]@touch $[directory]/stamp #if $[build_it] // Now output the rule to actually link the library from all of its // various .obj files. + #define sources \ $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[so_dir]/%.obj,%,,$[get_sources] $[igateoutput] $[igatemout]]] \ - $[components $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[RELDIR]/$[so_dir]/%.obj,%,,$[get_sources] $[get_igateoutput]]],$[active_component_libs]] + $[components $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[RELDIR]/$[so_dir]/%.obj,%,,$[get_sources] $[get_igateoutput] $[get_pch_outputcxx]]],$[active_component_libs]] + #define varname $[subst -,_,lib$[TARGET]_so] $[varname] = $[sources] #define target $[so_dir]/lib$[TARGET]$[dllext].$[dlllib] @@ -368,26 +379,25 @@ $[varname] = $[sources] // not parallel (requires gmake 3.79) because of link.exe conflicts in TMP dir (see audiotraits dir) #if $[GENERATE_BUILDDATE] .NOTPARALLEL $[target] : $[sources] $[so_dir]/stamp $[dtool_ver_dir_cyg]/version.rc - // first generate builddate for rc compiler -$[TAB]mkdir -p $[tmpdirname_cyg] // this dir-creation-stuff is leftover from trying to resolve parallel link difficulties +// first generate builddate for rc compiler using compiler preprocessor +$[TAB] mkdir -p $[tmpdirname_cyg] // this dir-creation-stuff is leftover from trying to resolve parallel link difficulties #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]" /fo$[VER_RESOURCE] $[filter /D%, $[flags]] "$[dtool_ver_dir]\version.rc" +$[TAB] cl /nologo /EP "$[dtool_ver_dir]\verdate.cpp" > "$[tmpdirname_win]\verdate.h" +$[TAB] rc /n /i"$[tmpdirname_win]" /fo$[VER_RESOURCE] $[filter /D%, $[flags]] "$[dtool_ver_dir]\version.rc" #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB]$[SHARED_LIB_C++] $[VER_RESOURCE] +$[TAB] $[SHARED_LIB_C++] $[VER_RESOURCE] #else -$[TAB]$[SHARED_LIB_C] $[VER_RESOURCE] +$[TAB] $[SHARED_LIB_C] $[VER_RESOURCE] #endif #else .NOTPARALLEL $[target] : $[sources] $[so_dir]/stamp #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB]$[SHARED_LIB_C++] +$[TAB] $[SHARED_LIB_C++] #else -$[TAB]$[SHARED_LIB_C] +$[TAB] $[SHARED_LIB_C] #endif #endif - #if $[build_dlls] $[so_dir]/lib$[TARGET]$[dllext].lib : $[so_dir]/lib$[TARGET]$[dllext].dll #endif @@ -415,26 +425,26 @@ install-lib$[TARGET] : $[installed_files] uninstall-lib$[TARGET] : #if $[installed_files] -$[TAB]rm -f $[sort $[installed_files]] +$[TAB] rm -f $[sort $[installed_files]] #endif #if $[build_dlls] $[install_lib_dir]/lib$[TARGET]$[dllext].dll : $[so_dir]/lib$[TARGET]$[dllext].dll $[so_dir]/stamp #define local lib$[TARGET]$[dllext].dll #define dest $[install_lib_dir] -$[TAB]cp -f $[so_dir]/$[local] $[dest] +$[TAB] cp -f $[so_dir]/$[local] $[dest] #endif $[install_lib_dir]/lib$[TARGET]$[dllext].lib : $[so_dir]/lib$[TARGET]$[dllext].lib $[so_dir]/stamp #define local lib$[TARGET]$[dllext].lib #define dest $[install_lib_dir] -$[TAB]cp -f $[so_dir]/$[local] $[dest] +$[TAB] cp -f $[so_dir]/$[local] $[dest] #if $[and $[build_dlls],$[build_pdbs]] $[install_lib_dir]/lib$[TARGET]$[dllext].pdb : $[so_dir]/lib$[TARGET]$[dllext].pdb $[so_dir]/stamp #define local lib$[TARGET]$[dllext].pdb #define dest $[install_lib_dir] -$[TAB]cp -f $[so_dir]/$[local] $[dest] +$[TAB] cp -f $[so_dir]/$[local] $[dest] #endif #if $[igatescan] @@ -453,7 +463,7 @@ $[TAB]cp -f $[so_dir]/$[local] $[dest] $[install_igatedb_dir]/$[igatedb] : $[so_dir]/$[igatedb] $[so_dir]/stamp #define local $[igatedb] #define dest $[install_igatedb_dir] -$[TAB]cp -f $[so_dir]/$[local] $[dest] +$[TAB] cp -f $[so_dir]/$[local] $[dest] // We have to split this out as a separate rule to properly support // parallel make. @@ -461,14 +471,14 @@ $[so_dir]/$[igatedb] : $[so_dir]/$[igateoutput] lib$[TARGET]_igatescan = $[igatescan] $[so_dir]/$[igateoutput] : $[sort $[patsubst %.h,%.h,%.I,%.I,%.T,%.T,%,,$[dependencies $[igatescan]] $[igatescan:%=./%]]] $[so_dir]/stamp -$[TAB]interrogate -od $[so_dir]/$[igatedb] -oc $[so_dir]/$[igateoutput] $[interrogate_options] -module "$[igatemod]" -library "$[igatelib]" $(lib$[TARGET]_igatescan) +$[TAB] interrogate -od $[so_dir]/$[igatedb] -oc $[so_dir]/$[igateoutput] $[interrogate_options] -module "$[igatemod]" -library "$[igatelib]" $(lib$[TARGET]_igatescan) #define target $[igateoutput:%.cxx=$[so_dir]/%.obj] #define source $[so_dir]/$[igateoutput] #define ipath . $[target_ipath] #define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%] $[target] : $[source] $[so_dir]/stamp -$[TAB]$[COMPILE_C++] +$[TAB] $[COMPILE_C++] #endif // $[igatescan] #if $[igatemout] @@ -483,14 +493,14 @@ lib$[TARGET]_igatemscan = $[igatemscan] #define target $[so_dir]/$[igatemout] #define sources $(lib$[TARGET]_igatemscan) $[target] : $[sources] $[so_dir]/stamp -$[TAB]interrogate_module -oc $[target] -module "$[igatemod]" -library "$[igatelib]" -python $[sources] +$[TAB] interrogate_module -oc $[target] -module "$[igatemod]" -library "$[igatelib]" -python $[sources] #define target $[igatemout:%.cxx=$[so_dir]/%.obj] #define source $[so_dir]/$[igatemout] #define ipath . $[target_ipath] #define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%] $[target] : $[source] $[so_dir]/stamp -$[TAB]$[COMPILE_C++] +$[TAB] $[COMPILE_C++] #endif // $[igatescan] #end metalib_target lib_target @@ -513,9 +523,9 @@ $[varname] = $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[so_dir]/%.ob #define sources $($[varname]) $[target] : $[sources] $[so_dir]/stamp #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB]$[SHARED_LIB_C++] +$[TAB] $[SHARED_LIB_C++] #else -$[TAB]$[SHARED_LIB_C] +$[TAB] $[SHARED_LIB_C] #endif #if $[build_dlls] @@ -542,9 +552,9 @@ $[varname] = $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[st_dir]/%.ob #define sources $($[varname]) $[target] : $[sources] $[st_dir]/stamp #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB]$[STATIC_LIB_C++] +$[TAB] $[STATIC_LIB_C++] #else -$[TAB]$[STATIC_LIB_C] +$[TAB] $[STATIC_LIB_C] #endif #define installed_files \ @@ -558,13 +568,13 @@ install-lib$[TARGET] : $[installed_files] uninstall-lib$[TARGET] : #if $[installed_files] -$[TAB]rm -f $[sort $[installed_files]] +$[TAB] rm -f $[sort $[installed_files]] #endif $[install_lib_dir]/lib$[TARGET]$[dllext].lib : $[st_dir]/lib$[TARGET]$[dllext].lib $[st_dir]/stamp #define local lib$[TARGET]$[dllext].lib #define dest $[install_lib_dir] -$[TAB]cp -f $[st_dir]/$[local] $[dest] +$[TAB] cp -f $[st_dir]/$[local] $[dest] #end static_lib_target ss_lib_target @@ -583,8 +593,8 @@ $[TARGET] : $[st_dir]/$[TARGET] $[st_dir]/stamp #define source $[SOURCE] #define script $[COMMAND] $[target] : $[source] $[st_dir]/stamp -$[TAB]$[SED] -$[TAB]chmod +x $[target] +$[TAB] $[SED] +$[TAB] chmod +x $[target] #define installed_files \ $[install_bin_dir]/$[TARGET] @@ -593,13 +603,13 @@ install-$[TARGET] : $[installed_files] uninstall-$[TARGET] : #if $[installed_files] -$[TAB]rm -f $[sort $[installed_files]] +$[TAB] rm -f $[sort $[installed_files]] #endif #define local $[TARGET] #define dest $[install_bin_dir] $[install_bin_dir]/$[TARGET] : $[st_dir]/$[TARGET] $[st_dir]/stamp -$[TAB]cp -f $[st_dir]/$[local] $[dest] +$[TAB] cp -f $[st_dir]/$[local] $[dest] #end sed_bin_target @@ -620,13 +630,13 @@ $[varname] = $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[st_dir]/%.ob $[target] : $[sources] $[st_dir]/stamp #if $[ld] // If there's a custom linker defined for the target, we have to use it. -$[TAB]$[ld] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]$[TAB] +$[TAB] $[ld] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] #else // Otherwise, we can use the normal linker. #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB]$[LINK_BIN_C++] +$[TAB] $[LINK_BIN_C++] #else -$[TAB]$[LINK_BIN_C] +$[TAB] $[LINK_BIN_C] #endif #endif @@ -646,19 +656,19 @@ install-$[TARGET] : $[installed_files] uninstall-$[TARGET] : #if $[installed_files] -$[TAB]rm -f $[sort $[installed_files]] +$[TAB] rm -f $[sort $[installed_files]] #endif $[install_bin_dir]/$[TARGET].exe : $[st_dir]/$[TARGET].exe $[st_dir]/stamp #define local $[TARGET].exe #define dest $[install_bin_dir] -$[TAB]cp -f $[st_dir]/$[local] $[dest] +$[TAB] cp -f $[st_dir]/$[local] $[dest] #if $[build_pdbs] $[install_bin_dir]/$[TARGET].pdb : $[st_dir]/$[TARGET].pdb $[st_dir]/stamp #define local $[TARGET].pdb #define dest $[install_bin_dir] -$[TAB]cp -f $[st_dir]/$[local] $[dest] +$[TAB] cp -f $[st_dir]/$[local] $[dest] #endif #end bin_target @@ -679,9 +689,9 @@ $[varname] = $[unique $[patsubst %_src.cxx,,%.cxx %.c %.yxx %.lxx,$[st_dir]/%.ob #define sources $($[varname]) $[target] : $[sources] $[st_dir]/stamp #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB]$[LINK_BIN_C++] +$[TAB] $[LINK_BIN_C++] #else -$[TAB]$[LINK_BIN_C] +$[TAB] $[LINK_BIN_C] #endif #end noinst_bin_target test_bin_target @@ -699,9 +709,9 @@ $[TAB]$[LINK_BIN_C] #define target $[patsubst %.yxx,%.cxx,$[file]] #define source $[file] $[target] : $[source] -$[TAB]$[BISON] $[YFLAGS] -y $[if $[YACC_PREFIX],-d --name-prefix=$[YACC_PREFIX]] $[source] -$[TAB]mv y.tab.c $[target] -$[TAB]mv y.tab.h $[patsubst %.yxx,%.h,$[source]] +$[TAB] $[BISON] $[YFLAGS] -y $[if $[YACC_PREFIX],-d --name-prefix=$[YACC_PREFIX]] $[source] +$[TAB] mv y.tab.c $[target] +$[TAB] mv y.tab.h $[patsubst %.yxx,%.h,$[source]] #end file @@ -710,11 +720,11 @@ $[TAB]mv y.tab.h $[patsubst %.yxx,%.h,$[source]] #define target $[patsubst %.lxx,%.cxx,$[file]] #define source $[file] $[target] : $[source] -$[TAB]$[FLEX] $[LFLAGS] $[if $[YACC_PREFIX],-P$[YACC_PREFIX]] -olex.yy.c $[source] +$[TAB] $[FLEX] $[LFLAGS] $[if $[YACC_PREFIX],-P$[YACC_PREFIX]] -olex.yy.c $[source] #define source lex.yy.c #define script /#include /d -$[TAB]$[SED] -$[TAB]rm $[source] +$[TAB] $[SED] +$[TAB] rm $[source] #end file @@ -725,7 +735,7 @@ $[TAB]rm $[source] #define ipath $[file_ipath] #define flags $[cflags] $[CFLAGS_SHARED] $[all_sources $[building_var:%=/D%],$[file]] $[target] : $[source] $[dependencies $[source]] $[so_dir]/stamp -$[TAB]$[COMPILE_C] +$[TAB] $[COMPILE_C] #end file @@ -736,8 +746,8 @@ $[TAB]$[COMPILE_C] #define source $[file] #define ipath $[file_ipath] #define flags $[cflags] $[all_sources $[building_var:%=/D%],$[file]] -$[target] : $[source] $[dependencies $[source]] $[st_dir]/stamp -$[TAB]$[COMPILE_C] +$[target] : $[source] $[dependencies $[source]] $[st_pch_files] $[st_dir]/stamp +$[TAB] $[COMPILE_C] #end file @@ -750,22 +760,58 @@ $[TAB]$[COMPILE_C] // Yacc must run before some files can be compiled, so all files // depend on yacc having run. $[target] : $[source] $[dependencies $[file]] $[yxx_so_sources:%.yxx=%.cxx] $[so_dir]/stamp -$[TAB]$[COMPILE_C++] +$[TAB] $[COMPILE_C++] #end file // Rules to compile C++ files that appear on a static library or in an // executable. + +//#foreach file $[sort $[filter-out %_headers.cxx, $[cxx_st_sources]]] #foreach file $[sort $[cxx_st_sources]] #define target $[patsubst %.cxx,$[st_dir]/%.obj,$[file]] #define source $[file] #define ipath $[file_ipath] + +#if $[DO_PCH] +// best way to find out if file use pch (and needs /Yu) is to check dependencies +// these must be defined before flags (or could defer them) +#define target_pch $[subst /./,/,$[patsubst %.h,$[st_dir]/%.pch,$[filter %_headers.h, $[dependencies $[file]]]]] +#define target_dirname $[patsubst %_headers.pch,%,$[target_pch]] +#endif + #define flags $[c++flags] $[all_sources $[building_var:%=/D%],$[file]] -$[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx] $[st_dir]/stamp -$[TAB]$[COMPILE_C++] + +#if $[target_pch] +#define COMPILE_LINE $[COMPILE_C_WITH_PCH] +#else +#define COMPILE_LINE $[COMPILE_C++] +#endif + +$[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx] $[target_pch] $[st_dir]/stamp +$[TAB] $[COMPILE_LINE] #end file +#if $[DO_PCH] +// Rules to compile _headers.pch from _header.h in static lib +#foreach file $[pch_header_source] +#define target_pch $[patsubst %.h,$[st_dir]/%.pch,$[file]] +#define target_obj $[patsubst %.h,$[st_dir]/%.obj,$[file]] +#define target $[target_obj] +#define source $[file] +#define ipath $[file_ipath] +#define flags $[c++flags] $[CFLAGS_SHARED] $[all_sources $[building_var:%=/D%],$[file]] +// Yacc must run before some files can be compiled, so all files +// depend on yacc having run. +$[target_obj] : $[source] $[dependencies $[file]] $[st_dir]/stamp +$[TAB] $[COMPILE_CXXSTYLE_PCH] + +$[target_pch] : $[target_obj] + +#end file +#endif + // Rules to compile generated C++ files that appear on a shared library. #foreach file $[sort $[yxx_so_sources] $[lxx_so_sources]] #define target $[patsubst %.lxx %.yxx,$[so_dir]/%.obj,$[file]] @@ -775,7 +821,7 @@ $[TAB]$[COMPILE_C++] // Yacc must run before some files can be compiled, so all files // depend on yacc having run. $[target] : $[source] $[dependencies $[file]] $[yxx_so_sources:%.yxx=%.cxx] $[so_dir]/stamp -$[TAB]$[COMPILE_C++] +$[TAB] $[COMPILE_C++] #end file @@ -787,7 +833,7 @@ $[TAB]$[COMPILE_C++] #define ipath $[file_ipath] #define flags $[noopt_c++flags] $[all_sources $[building_var:%=/D%],$[file]] $[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx] $[st_dir]/stamp -$[TAB]$[COMPILE_C++] +$[TAB] $[COMPILE_C++] #end file @@ -797,53 +843,53 @@ $[TAB]$[COMPILE_C++] $[install_bin_dir]/$[file] : $[file] #define local $[file] #define dest $[install_bin_dir] -$[TAB]cp -f $[local] $[dest] +$[TAB] cp -f $[local] $[dest] #end file #foreach file $[install_headers] $[install_headers_dir]/$[file] : $[file] #define local $[file] #define dest $[install_headers_dir] -$[TAB]cp -f $[local] $[dest] +$[TAB] cp -f $[local] $[dest] #end file #foreach file $[install_parser_inc] $[install_parser_inc_dir]/$[file] : $[file] #define local $[file] #define dest $[install_parser_inc_dir] -$[TAB]cp -f $[local] $[dest] +$[TAB] cp -f $[local] $[dest] #end file #foreach file $[install_data] $[install_data_dir]/$[file] : $[file] #define local $[file] #define dest $[install_data_dir] -$[TAB]cp -f $[local] $[dest] +$[TAB] cp -f $[local] $[dest] #end file #foreach file $[install_config] $[install_config_dir]/$[file] : $[file] #define local $[file] #define dest $[install_config_dir] -$[TAB]cp -f $[local] $[dest] +$[TAB] cp -f $[local] $[dest] #end file // Finally, all the special targets. These are commands that just need // to be invoked; we don't pretend to know what they are. #forscopes special_target $[TARGET] : -$[TAB]$[COMMAND] +$[TAB] $[COMMAND] #end special_target // Finally, the rules to freshen the Makefile itself. Makefile : $[SOURCE_FILENAME] -$[TAB]ppremake +$[TAB] ppremake #if $[and $[DEPENDENCY_CACHE_FILENAME],$[dep_sources]] $[DEPENDENCY_CACHE_FILENAME] : $[dep_sources] -$[TAB]@ppremake -D $[DEPENDENCY_CACHE_FILENAME] +$[TAB] @ppremake -D $[DEPENDENCY_CACHE_FILENAME] #endif @@ -896,65 +942,65 @@ install : $[if $[CONFIG_HEADER],$[install_headers_dir] $[install_headers_dir]/$[ install-igate : $[subdirs:%=install-igate-%] uninstall : $[subdirs:%=uninstall-%] #if $[CONFIG_HEADER] -$[TAB]rm -f $[install_headers_dir]/$[CONFIG_HEADER] +$[TAB] rm -f $[install_headers_dir]/$[CONFIG_HEADER] #endif uninstall-igate : $[subdirs:%=uninstall-igate-%] #formap dirname subdirs #define depends $[dirname] : $[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]] -$[TAB]cd ./$[PATH] && $(MAKE) all +$[TAB] cd ./$[PATH] && $(MAKE) all #end dirname #formap dirname subdirs test-$[dirname] : -$[TAB]cd ./$[PATH] && $(MAKE) test +$[TAB] cd ./$[PATH] && $(MAKE) test #end dirname #formap dirname subdirs clean-$[dirname] : -$[TAB]cd ./$[PATH] && $(MAKE) clean +$[TAB] cd ./$[PATH] && $(MAKE) clean #end dirname #formap dirname subdirs clean-igate-$[dirname] : -$[TAB]cd ./$[PATH] && $(MAKE) clean-igate +$[TAB] cd ./$[PATH] && $(MAKE) clean-igate #end dirname #formap dirname subdirs cleanall-$[dirname] : $[patsubst %,cleanall-%,$[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]] -$[TAB]cd ./$[PATH] && $(MAKE) cleanall +$[TAB] cd ./$[PATH] && $(MAKE) cleanall #end dirname #formap dirname subdirs install-$[dirname] : $[patsubst %,install-%,$[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]] -$[TAB]cd ./$[PATH] && $(MAKE) install +$[TAB] cd ./$[PATH] && $(MAKE) install #end dirname #formap dirname subdirs install-igate-$[dirname] : -$[TAB]cd ./$[PATH] && $(MAKE) install-igate +$[TAB] cd ./$[PATH] && $(MAKE) install-igate #end dirname #formap dirname subdirs uninstall-$[dirname] : -$[TAB]cd ./$[PATH] && $(MAKE) uninstall +$[TAB] cd ./$[PATH] && $(MAKE) uninstall #end dirname #formap dirname subdirs uninstall-igate-$[dirname] : -$[TAB]cd ./$[PATH] && $(MAKE) uninstall-igate +$[TAB] cd ./$[PATH] && $(MAKE) uninstall-igate #end dirname #if $[ne $[CONFIG_HEADER],] $[install_headers_dir] : -$[TAB]@test -d $[install_headers_dir] || echo mkdir -p $[install_headers_dir] -$[TAB]@test -d $[install_headers_dir] || mkdir -p $[install_headers_dir] +$[TAB] @test -d $[install_headers_dir] || echo mkdir -p $[install_headers_dir] +$[TAB] @test -d $[install_headers_dir] || mkdir -p $[install_headers_dir] $[install_headers_dir]/$[CONFIG_HEADER] : $[CONFIG_HEADER] #define local $[CONFIG_HEADER] #define dest $[install_headers_dir] -$[TAB]cp -f $[local] $[dest] +$[TAB] cp -f $[local] $[dest] #endif #end Makefile