From: Jones, W. <Wes...@nr...> - 2003-06-02 20:52:09
|
Along the lines of Stenn's question, How are people supporting compiler flags? It seems hard to add and delete flags from an environment variable list using straightforward modulefiles, and one probably does not want a global CFLAGS environment variable anyway. So, I began to integrate the use of pkg-config into my use of modules. If you are using the gnu tools and autoconfig with defined depenencies, you can just use the PKG_CONFIG_PATH to load different packages and versions. Otherwise, I also define some standard environment variables based on the output from pkg-config. I like to base the flags on an execution of pkg-config, so that I can make modifications to $modroot/lib/$PKG.pc without modification of the modulefiles. Unfortunately, in my modulefiles, when I envoke modules to unload a package, the setenv (interpreted as an unsetenv when unloading) is still invoking the "pkg-config" command after the package has been removed from the PKG_CONFIG_PATH. So, I have the ugly implementation below. If someone has a suggestion for better ways of doing this, or better ways of including compiler flags in modules I'd like to hear them. ## ## modules $PKG $VERSION ## module-whatis "loads the $PKG software environment" # for Tcl script use only set version $VERSION set modroot $ROOT/$PKG/\$version prepend-path PATH \$modroot/bin #AIX prepend-path LIBPATH \$modroot/lib prepend-path LD_LIBRARY_PATH \$modroot/lib prepend-path MANPATH \$modroot/man prepend-path PKG_CONFIG_PATH \$modroot/lib if { ![is-loaded [module-info name]] && ![module-info mode load] || [module-info mode remove] } { setenv ${CAP_PKG}_LIBS 0 setenv ${CAP_PKG}_CFLAGS 0 setenv ${CAP_PKG}_INCLUDES 0 setenv ${CAP_PKG}_FLIBS 0 setenv ${CAP_PKG}_FFLAGS 0 } else { setenv ${CAP_PKG}_LIBS [exec pkg-config --silence-errors --libs $PKG] setenv ${CAP_PKG}_CFLAGS [exec pkg-config --silence-errors --cflags $PKG] setenv ${CAP_PKG}_INCLUDES [exec pkg-config --silence-errors --cflags-only-I $PKG] setenv ${CAP_PKG}_FLIBS [exec pkg-config --silence-errors --variable=FLIBS $PKG] setenv ${CAP_PKG}_FFLAGS [exec pkg-config --silence-errors --variable=FFLAGS $PKG] } --- Wesley Jones, Ph.D. Senior Computational Scientist Phone: 303-275-4070 National Renewable Energy Lab wes...@nr... |