Nancy E. Davis (ne...@fa...) wrote:
> Leo,
>
> Thanks much! This works well as below:
>
> set flags_add {
> -L/usr/shlib -L/usr/ccs/lib -L/usr/lib/cmplrs/cc -L/usr/lib
> -L/usr/local/lib -L/
> var/shlib
> }
>
> if {([module-info mode load] || [module-info mode switch2]) && [info
exists env(DEC_CC)]} {
> setenv _SAVE_DEC_CC $env(DEC_CC)
> set flags_use [concat $flags_add $env(DEC_CC)]
> setenv DEC_CC $flags_use
> } else {
> set flags_end " | "
> set flags_use [concat $flags_add $flags_end]
> setenv DEC_CC $flags_use
> }
>
> For now, this is enough. Once I learn more tcl, I can think about
> replacing the saved env var. I would also like to figure out
> how to do some sanity checking on the list and avoid replicate
> entries. Some users are coming in with no flags set, others have
> a very specific list that include some or all of the flags I want
> them to be certain to have.
>
> Thanks to all for your help.
Hello, Nancy.
If you can think of a way to make use of "append-path", it would
be easiest to work with in modules. So you'd end up with the usual
colon-delimited list, but perhaps you could process that into a
space-delimited list in your compile process.
We have a setup in our modulefiles that allows us to set a particular
env var if not already set, but when unloading one of the modulefiles
that sets the env var we have some Tcl that prevents the var from being
unsetenv *unless* the modulefile is the last of the bunch that needs it
set. It will then be allowed to unsetenv the var. It's essentially
a "last one out of the house shuts the door" function.
This works very well, but currently requires that each modulefile
know about the others (use of env vars indicating certain modulefiles
have been loaded). Depending upon how many modulefiles would need
to set the same set of libraries in your environment, this might work
for you or could get very messy very fast. If most of the lib paths
are mutually exclusive, it should be okay.
Just some thoughts. Good luck!
- Leo Butler
|