diff --git a/dtool/Config.pp b/dtool/Config.pp index ab58ba578d..9f5ae2c021 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -587,10 +587,11 @@ // $[sources] is the list of .o files. $[libs] is a space-separated // list of dependent libraries, and $[lpath] is a space-separated list // of directories in which those libraries can be found. -#defer LINK_BIN_C $[cc_ld] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]\ +#defer LINK_BIN_C $[cc_ld] -o $[target] $[sources] $[flags] $[lpath:%=-L%] $[libs:%=-l%]\ $[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[frameworks]] #defer LINK_BIN_C++ $[cxx_ld]\ -o $[target] $[sources]\ + $[flags]\ $[lpath:%=-L%] $[libs:%=-l%]\ $[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[frameworks]] diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index d8acd02134..5bf06aaa0d 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -89,6 +89,8 @@ #define python_ipath $[wildcard $[PYTHON_IPATH]] #define python_lpath $[wildcard $[PYTHON_LPATH]] #define python_fpath $[wildcard $[PYTHON_FPATH]] + #define python_cflags $[PYTHON_CFLAGS] + #define python_lflags $[PYTHON_LFLAGS] #define python_libs $[PYTHON_LIBS] #define python_framework $[PYTHON_FRAMEWORK] #endif @@ -355,6 +357,20 @@ $[alt_cflags] #end get_cflags +// This function returns the appropriate lflags for the target, based +// on the various external packages this particular target claims to +// require. +#defun get_lflags + // hack to add stl,nspr,python. should be removed + #define alt_lflags $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_lflags] $[nspr_lflags] $[python_lflags]] + + #foreach package $[use_packages] + #set alt_lflags $[alt_lflags] $[$[package]_lflags] + #end package + + $[alt_lflags] +#end get_lflags + // This function returns the appropriate include path for the target, // based on the various external packages this particular target // claims to require. This returns a space-separated set of directory diff --git a/dtool/pptempl/Template.unix.pp b/dtool/pptempl/Template.unix.pp index 93a14a23f0..ab28b927c5 100644 --- a/dtool/pptempl/Template.unix.pp +++ b/dtool/pptempl/Template.unix.pp @@ -100,6 +100,7 @@ // These are the complete set of extra flags the compiler requires. #defer cflags $[get_cflags] $[CFLAGS] $[CFLAGS_OPT$[OPTIMIZE]] #defer c++flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] +#defer lflags $[get_lflags] $[LFLAGS] $[LFLAGS_OPT$[OPTIMIZE]] // $[complete_lpath] is rather like $[complete_ipath]: the list of // directories (from within this tree) we should add to our -L list. @@ -515,6 +516,7 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define sources $($[varname]) #define cc_ld $[or $[get_ld],$[CC]] #define cxx_ld $[or $[get_ld],$[CXX]] +#define flags $[lflags] $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] $[TAB] $[LINK_BIN_C++] @@ -559,6 +561,7 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define sources $($[varname]) #define cc_ld $[or $[get_ld],$[CC]] #define cxx_ld $[or $[get_ld],$[CXX]] +#define flags $[lflags] $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] $[TAB] $[LINK_BIN_C++]