Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
82f92b4a2b

+ 30 - 10
dtool/Config.pp

@@ -271,12 +271,30 @@
 #defer COMPILE_C $[CC] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
 #defer COMPILE_C++ $[CXX] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
 
-// What additional flags should be passed to both C and C++ compilers
-// when OPTIMIZE (above) is defined for each of its four values?
-#defer CFLAGS_OPT1 -Wall -g
-#defer CFLAGS_OPT2 -Wall -g -O2
-#defer CFLAGS_OPT3 -O2
-#defer CFLAGS_OPT4 -O2 -DNDEBUG
+// What flags should be passed to both C and C++ compilers to enable
+// compiler optimizations?  This will be supplied when OPTIMIZE
+// (above) is set to 2, 3, or 4.
+#defer OPTFLAGS -O2
+
+// What define variables should be passed to the compilers for each
+// value of OPTIMIZE?  We separate this so we can pass these same
+// options to interrogate, guaranteeing that the correct interfaces
+// are generated.  Do not include -D here; that will be supplied
+// automatically.
+#defer CDEFINES_OPT1
+#defer CDEFINES_OPT2
+#defer CDEFINES_OPT3
+#defer CDEFINES_OPT4 NDEBUG
+
+// What additional flags should be passed for each value of OPTIMIZE
+// (above)?  We separate out the compiler-optimization flags, above,
+// so we can compile certain files that give optimizers trouble (like
+// the output of lex and yacc) without them, but with all the other
+// relevant flags.
+#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] -Wall -g
+#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] -Wall -g
+#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%]
+#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%]
 
 // What additional flags should be passed to both compilers when
 // building shared (relocatable) sources?  Some architectures require
@@ -348,10 +366,12 @@
   //      SOMEOTHERLIB.
   #define WOFF_LIST $[WOFF_LIST] -Wl,-LD_MSG:off=85
   
-  #defer CFLAGS_OPT1 $[WOFF_LIST] -g
-  #defer CFLAGS_OPT2 $[WOFF_LIST] -O2 -OPT:Olimit=2500
-  #defer CFLAGS_OPT3 $[WOFF_LIST] -O2 -OPT:Olimit=2500
-  #defer CFLAGS_OPT4 $[WOFF_LIST] -O2 -OPT:Olimit=2500 -DNDEBUG
+  #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
   

+ 19 - 12
dtool/pptempl/Global.msvc.pp

@@ -48,28 +48,35 @@
 #defer BROWSEINFO_FLAG /Fr"$[osfilename $[target:%.obj=%.sbr]]"
 #defer CFLAGS_SHARED
 
-#defer CFLAGS_OPT1 /MDd /GZ /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" /D_DEBUG
-#defer CFLAGS_OPT2 /MDd /Zi /Fd"$[osfilename $[target:%.obj=%.pdb]]" /D_DEBUG /O2 /Ob1 /Ogity /G6
-#defer CFLAGS_OPT3 /MD /DOPTIMIZE /O2 /Ob1 /Ogity /G6 /Gi-
-#defer CFLAGS_OPT4 /MD /DOPTIMIZE /DNDEBUG /O2 /Ob1 /Ogity /G6 /Gi-
+#defer OPTFLAGS /O2 /Ob1 /Ogity /G6
 
-#defer LFLAGS_OPT1 /debug /incremental:no
-#defer LFLAGS_OPT2 /debug /incremental:no
-#defer LFLAGS_OPT3 /fixed:no
-#defer LFLAGS_OPT4 /fixed:no
+#defer CDEFINES_OPT1 _DEBUG
+#defer CDEFINES_OPT2 _DEBUG
+#defer CDEFINES_OPT3
+#defer CDEFINES_OPT4 NDEBUG
+
+#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] /MDd /GZ /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]"
+#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]"
+#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] /MD /Gi-
+#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] /MD /Gi-
+
+#defer LDFLAGS_OPT1 /debug /incremental:no
+#defer LDFLAGS_OPT2 /debug /incremental:no
+#defer LDFLAGS_OPT3 /fixed:no
+#defer LDFLAGS_OPT4 /fixed:no
 
 #defer interrogate_ipath $[decygwin %,-I"%",$[target_ipath]]
 #defer interrogate_spath $[decygwin %,-S"%",$[install_parser_inc_dir]]
 
 #defer extra_cflags /nologo /W3 /EHsc /Zm250 /D_WINDOWS /DWIN32 /D_WINDLL /DSTRICT /DPENV_WIN32 /DWIN32_VC
-#defer extra_so_lflags /DLL /NOLOGO
-#defer extra_bin_lflags /NOLOGO
+#defer extra_so_ldflags /DLL /NOLOGO
+#defer extra_bin_ldflags /NOLOGO
 
 #defer COMPILE_C cl /c /Fo"$[osfilename $[target]]" $[decygwin %,/I"%",$[ipath]] $[flags] $[extra_cflags] $[source]
 #defer COMPILE_C++ $[COMPILE_C]
 
-#defer SHARED_LIB_C link $[LFLAGS_OPT$[OPTIMIZE]] $[extra_so_lflags] $[sources] $[decygwin %,-LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
+#defer SHARED_LIB_C link $[LDFLAGS_OPT$[OPTIMIZE]] $[extra_so_ldflags] $[sources] $[decygwin %,-LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
 #defer SHARED_LIB_C++ $[SHARED_LIB_C]
 
-#defer LINK_BIN_C link $[LFLAGS_OPT$[OPTIMIZE]] $[extra_bin_lflags] $[sources] $[decygwin %,-LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
+#defer LINK_BIN_C link $[LDFLAGS_OPT$[OPTIMIZE]] $[extra_bin_ldflags] $[sources] $[decygwin %,-LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
 #defer LINK_BIN_C++ $[LINK_BIN_C]

+ 2 - 1
dtool/pptempl/Global.pp

@@ -505,7 +505,8 @@ Warning: Variable $[upcase $[tree]]_INSTALL is not set!
 #defer interrogate_options \
     -DCPPPARSER -D__cplusplus $[SYSTEM_IGATE_FLAGS] \
     $[interrogate_spath] $[interrogate_ipath] \
-    $[filter -D%,$[get_cflags] $[C++FLAGS]] \
+    $[CDEFINES_OPT$[OPTIMIZE]:%=-D%] \
+    $[filter -D%,$[C++FLAGS]] \
     $[INTERROGATE_OPTIONS] \
     $[if $[INTERROGATE_PYTHON_INTERFACE],-python] \
     $[if $[INTERROGATE_C_INTERFACE],-c]

+ 2 - 2
dtool/pptempl/Template.msvc.pp

@@ -566,7 +566,7 @@ $[target] : $[sources]
 #define target $[patsubst %.yxx,%.cxx,$[file]]
 #define source $[file]
 $[target] : $[source]
-	$[BISON] -y $[if $[YACC_PREFIX],-d --name-prefix=$[YACC_PREFIX]] $[source]
+	$[BISON] $[YFLAGS] -y $[if $[YACC_PREFIX],-d --name-prefix=$[YACC_PREFIX]] $[source]
 	mv y.tab.c $[target]
 	mv y.tab.h $[patsubst %.yxx,%.h,$[source]]
 
@@ -577,7 +577,7 @@ $[target] : $[source]
 #define target $[patsubst %.lxx,%.cxx,$[file]]
 #define source $[file]
 $[target] : $[source]
-	$[FLEX] $[if $[YACC_PREFIX],-P$[YACC_PREFIX]] -olex.yy.c $[source]
+	$[FLEX] $[LFLAGS] $[if $[YACC_PREFIX],-P$[YACC_PREFIX]] -olex.yy.c $[source]
 	$[SED] '/#include <unistd.h>/d' lex.yy.c > $[target]
 	rm lex.yy.c
 

+ 38 - 10
dtool/pptempl/Template.unix.pp

@@ -117,8 +117,11 @@
 
 // These are the complete set of extra flags the compiler requires,
 // from the context of a particular file, given in $[file].
-#defer cflags $[all_sources $[get_cflags] $[CFLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]]
-#defer c++flags $[all_sources $[get_cflags] $[C++FLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]]
+#defer cflags $[all_sources $[get_cflags] $[CFLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]] $[if $[>= $[OPTIMIZE],2],$[OPTFLAGS]]
+#defer c++flags $[all_sources $[get_cflags] $[C++FLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]] $[if $[>= $[OPTIMIZE],2],$[OPTFLAGS]]
+
+// These are the same flags, sans the compiler optimizations.
+#defer noopt_c++flags $[all_sources $[get_cflags] $[C++FLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]]
 
 // $[complete_lpath] is rather like $[complete_ipath]: the list of
 // directories (from within this tree) we should add to our -L list.
@@ -319,7 +322,7 @@ $[so_dir]/$[igatedb] $[so_dir]/$[igateoutput] : $[filter-out .c .cxx,$[igatescan
 #define target $[igateoutput:%.cxx=$[so_dir]/%.o]
 #define source $[so_dir]/$[igateoutput]
 #define ipath . $[target_ipath]
-#define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED]
+#define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[if $[>= $[OPTIMIZE],2],$[OPTFLAGS]] $[CFLAGS_SHARED]
 $[target] : $[source]
 	$[COMPILE_C++]
 #endif  // $[igatescan]
@@ -341,7 +344,7 @@ $[target] : $[sources]
 #define target $[igatemout:%.cxx=$[so_dir]/%.o]
 #define source $[so_dir]/$[igatemout]
 #define ipath . $[target_ipath]
-#define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED]
+#define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[if $[>= $[OPTIMIZE],2],$[OPTFLAGS]] $[CFLAGS_SHARED]
 $[target] : $[source]
 	$[COMPILE_C++]
 #endif  // $[igatescan]
@@ -566,9 +569,9 @@ $[target] : $[source] $[dependencies $[source]]
 #end file
 
 // Rules to compile C++ files that appear on a shared library.
-#foreach file $[sort $[cxx_so_sources] $[yxx_so_sources] $[lxx_so_sources]]
-#define target $[patsubst %.cxx %.lxx %.yxx,$[so_dir]/%.o,$[file]]
-#define source $[patsubst %.cxx %.lxx %.yxx,%.cxx,$[file]]
+#foreach file $[sort $[cxx_so_sources]]
+#define target $[patsubst %.cxx,$[so_dir]/%.o,$[file]]
+#define source $[file]
 #define ipath $[file_ipath]
 #define flags $[c++flags] $[CFLAGS_SHARED]
 // Yacc must run before some files can be compiled, so all files
@@ -580,9 +583,9 @@ $[target] : $[source] $[dependencies $[file]] $[yxx_so_sources:%.yxx=%.cxx]
 
 // Rules to compile C++ files that appear on a static library or in an
 // executable.
-#foreach file $[sort $[cxx_st_sources] $[yxx_st_sources] $[lxx_st_sources]]
-#define target $[patsubst %.cxx %.lxx %.yxx,$[st_dir]/%.o,$[file]]
-#define source $[patsubst %.cxx %.lxx %.yxx,%.cxx,$[file]]
+#foreach file $[sort $[cxx_st_sources]]
+#define target $[patsubst %.cxx,$[st_dir]/%.o,$[file]]
+#define source $[file]
 #define ipath $[file_ipath]
 #define flags $[c++flags]
 $[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx]
@@ -590,6 +593,31 @@ $[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx]
 
 #end file
 
+// 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]/%.o,$[file]]
+#define source $[patsubst %.lxx %.yxx,%.cxx,$[file]]
+#define ipath $[file_ipath]
+#define flags $[noopt_c++flags] $[CFLAGS_SHARED]
+// 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]
+	$[COMPILE_C++]
+
+#end file
+
+// Rules to compile C++ files that appear on a static library or in an
+// executable.
+#foreach file $[sort $[yxx_st_sources] $[lxx_st_sources]]
+#define target $[patsubst %.lxx %.yxx,$[st_dir]/%.o,$[file]]
+#define source $[patsubst %.lxx %.yxx,%.cxx,$[file]]
+#define ipath $[file_ipath]
+#define flags $[noopt_c++flags]
+$[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx]
+	$[COMPILE_C++]
+
+#end file
+
 // And now the rules to install the auxiliary files, like headers and
 // data files.
 #foreach file $[install_scripts]