Gitlab will migrate to a new storage backend starting 0300 UTC on 2020-04-04. We do not anticipate a maintenance window for this migration. Performance may be impacted over the weekend. Thanks for your patience.

Commit 893aa055 authored by Karl Wette's avatar Karl Wette

Common user environment script generation in top-level library Makefiles

Original: 67bbe1e6973438f7a3298a916154627d1cadc636
parent 4fdc6b5d
# Environment script generation
# Author: Karl Wette, 2011
# print an error message to standard error, remove output file, and exit
function msg(str) {
print "generate_user_env.awk: " str >"/dev/stderr"
if (output != "") {
system("rm -f " output)
}
exit 1
}
# script setup
BEGIN {
# check that required variables were set on command line
if (SED == "") {
msg("no value for 'SED' given on command line")
}
if (output == "") {
msg("no value for 'output' given on command line")
}
# remove output file
system("rm -f " output)
}
# comments are passed through
/^#/ {
print $0 >>output
}
# source another environment setup file
# syntax: source FILE
$1 == "source" {
for (i = 2; i <= NF; ++i) {
sourcefiles[$i] = $i
}
}
# set a environment variable to a given value or path
# syntax: set NAME value
# set NAME /dir1 /dir2
$1 == "set" {
name = $2
if (name == "") {
msg("no name given to prepend")
}
setvars[name] = ""
value = ""
for (i = 3; i <= NF; ++i) {
found = index(":" setvars[name] ":", ":" $i ":") > 0 ||
index(":" value ":", ":" $i ":") > 0
if (!found) {
value = value ":" $i
}
}
if (value != "") {
setvars[name] = substr(value, 2)
}
delete pathvars[name]
}
# prepend a value to a path environment variable
# syntax: prepend PATH /dir1 /dir2 /dir3 ...
$1 == "prepend" {
name = $2
if (name == "") {
msg("no name given to prepend")
}
value = ""
for (i = 3; i <= NF; ++i) {
found = index(":" pathvars[name] ":", ":" $i ":") > 0 ||
index(":" value ":", ":" $i ":") > 0
if (!found) {
value = value $i ":"
}
}
if (value != "") {
if (pathvars[name] == "") {
pathvars[name] = sprintf("${%s}", name)
}
pathvars[name] = value pathvars[name]
}
delete setvars[name]
}
# append a value to a path environment variable
# syntax: append PATH /dir1 /dir2 /dir3 ...
$1 == "append" {
name = $2
if (name == "") {
msg("no name given to prepend")
}
value = ""
for (i = 3; i <= NF; ++i) {
found = index(":" pathvars[name] ":", ":" $i ":") > 0 ||
index(":" value ":", ":" $i ":") > 0
if (!found) {
value = value ":" $i
}
}
if (value != "") {
if (pathvars[name] == "") {
pathvars[name] = sprintf("${%s}", name)
}
pathvars[name] = pathvars[name] value
}
delete setvars[name]
}
# output environment variables
END {
# if output file ends in 'csh', use C shell syntax, otherwise Bourne shell syntax
csh = (output ~ /\.csh$/)
# output source files
for (sourcefile in sourcefiles) {
if (csh) {
print "source " sourcefile ".csh" >>output
}
else {
print ". " sourcefile ".sh" >>output
}
}
# output set variables
for (name in setvars) {
if (csh) {
print "setenv " name " \"" setvars[name] "\"" >>output
}
else {
print name "=\"" setvars[name] "\"" >>output
print "export " name >>output
}
}
# output prepend/append variables
for (name in pathvars) {
sed_script = "s|::|:!@%COLON%@!:|;"
split(pathvars[name], pathvar, ":")
for (i in pathvar) {
if (substr(pathvar[i], 1, 1) != "$") {
sed_script = sed_script "s|:" pathvar[i] ":|:|;"
}
}
sed_script = sed_script "s|::*|:|g;s|^:||;s|:$||;s|!@%COLON%@!||g;"
if (csh) {
print "if ( ! ${?" name "} ) setenv " name >>output
print "setenv " name " `echo \":${" name "}:\" | " SED " '" sed_script "'`" >>output
print "setenv " name " \"" pathvars[name] "\"" >>output
}
else {
print name "=`echo \":${" name "}:\" | " SED " '" sed_script "'`" >>output
print name "=\"" pathvars[name] "\"" >>output
print "export " name >>output
}
}
}
BUILT_SOURCES += \
$(PACKAGE)-user-env.csh \
$(PACKAGE)-user-env.sh \
$(END_OF_LIST)
sysconf_DATA += \
$(PACKAGE)-user-env.csh \
$(PACKAGE)-user-env.sh \
$(END_OF_LIST)
MOSTLYCLEANFILES += \
$(PACKAGE)-user-env.csh \
$(PACKAGE)-user-env.sh \
$(PACKAGE)-user-env.shell \
$(END_OF_LIST)
EXTRA_DIST += generate_user_env.awk
$(PACKAGE)-user-env.shell: Makefile $(srcdir)/generate_user_env.awk
$(AM_V_GEN)echo "$(user_environment)" | $(SED) -e 's|; *|\n|g' | $(AWK) -f $(srcdir)/generate_user_env.awk >$@
$(PACKAGE)-user-env.csh $(PACKAGE)-user-env.sh: $(PACKAGE)-user-env.shell
$(AM_V_GEN)prefix=`echo "$@" | $(SED) -e 's|.*\.||'`; \
echo "# source this file to access $(PACKAGE_NAME)" >$@; \
$(SED) -n -e "s|[@]SED[@]|$(SED)|g;s|^$$prefix:||p" $< >>$@
......@@ -40,6 +40,9 @@ include/lal/*.i
include/lal/header-link-stamp
include/stamp-h1
lal-*.tar.gz
lal-user-env.csh
lal-user-env.sh
lal-user-env.shell
lal.spec
lib/lal/.vcsinfo
lib/lal/LALBuildInfo.c
......@@ -47,9 +50,6 @@ lib/lal/LALConfig.h
lib/lal/LALVCSInfo.h
lib/lal/git_info.sed
lib/lal/git_version
lib/lal/lal-user-env.csh
lib/lal/lal-user-env.sh
lib/lal/lal-user-env.shell
lib/lal/lal-version
lib/lal/stamp-h2
lib/lalsupport/test/*PrintVector.*
......
BUILT_SOURCES =
sysconf_DATA =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_user_env.am
ACLOCAL_AMFLAGS = -I gnuscripts
if HAVE_GIT_REPO
......@@ -8,7 +14,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(SHELL) ./00boot
endif # HAVE_GIT_REPO
EXTRA_DIST = \
EXTRA_DIST += \
README.bugs \
README.contrib \
README.install \
......@@ -23,10 +29,20 @@ SUBDIRS = \
python \
swig
user_environment = \
set $(PACKAGE)_PREFIX $(prefix); \
prepend LAL_DATA_PATH $(pkgdatadir); \
prepend MANPATH $(mandir); \
prepend OCTAVE_PATH $(octexecdir); \
prepend PATH $(bindir); \
prepend PKG_CONFIG_PATH $(libdir)/pkgconfig; \
prepend PYTHONPATH $(pyexecdir) $(pythondir); \
$(END_OF_LIST)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = lal.pc lalsupport.pc
noinst_DATA = lal-uninstalled.pc lalsupport-uninstalled.pc
BUILT_SOURCES = lal-uninstalled.pc lalsupport-uninstalled.pc
BUILT_SOURCES += lal-uninstalled.pc lalsupport-uninstalled.pc
all-local:
@echo "";\
......
# Environment script generation
# Author: Karl Wette, 2011--2014
# env[name] holds the value of environment variable 'name'
# set[name,path] is defined if 'path' has already been set in 'name'
# sed[name] holds sed scripts to remove duplicates from 'name'
# set an environment variable to a given value
# syntax: set NAME value
$1 == "set" {
if (NF == 3) {
name = toupper($2)
env[name] = $3
}
}
# prepend a value to an environment variable
# syntax: prepend PATH path1 path2 path3 ...
$1 == "prepend" {
if (NF >= 3) {
name = toupper($2)
for (i = 3; i <= NF; ++i) {
if ( !( (name,$i) in set ) ) {
set[name, $i] = 1
env[name] = env[name] $i ":"
sed[name] = sed[name] "s|" $i ":||g;"
}
}
env[name] = env[name] "${" name "}"
}
}
# append a value to an environment variable
# syntax: append PATH path1 path2 path3 ...
$1 == "append" {
if (NF >= 3) {
name = toupper($2)
for (i = 3; i <= NF; ++i) {
if ( !( (name,$i) in set ) ) {
set[name, $i] = 1
env[name] = ":" env[name] $i
sed[name] = sed[name] "s|:" $i "||g;"
}
}
env[name] = "${" name "}" env[name]
}
}
# output environment variables in both C and Bourne shell syntax
END {
for (name in env) {
print "csh:if ( ! ${?" name "} ) setenv " name
print "sh:export " name
if (sed[name] != "") {
print "csh:setenv " name " `echo \"${" name "}\" | @SED@ -e '" sed[name] "'`"
print "sh:" name "=`echo \"${" name "}\" | @SED@ -e '" sed[name] "'`"
}
print "csh:setenv " name " \"" env[name] "\""
print "sh:" name "=\"" env[name] "\""
}
}
../../gnuscripts/lalsuite_user_env.am
\ No newline at end of file
include $(top_srcdir)/gnuscripts/lallibs_header_links.am
EXTRA_DIST = \
generate_user_env.awk
lib_LTLIBRARIES = liblal.la
pkginclude_HEADERS = \
......@@ -35,33 +32,10 @@ bin_PROGRAMS = lal-version
lal_version_SOURCES = lal-version.c
lal_version_LDADD = liblal.la
MOSTLYCLEANFILES = \
lal-user-env.shell \
lal-user-env.sh \
lal-user-env.csh
sysconf_DATA = \
lal-user-env.sh \
lal-user-env.csh
BUILT_SOURCES = \
lal-user-env.sh \
lal-user-env.csh
TESTS = lal-version
lal-user-env.shell: Makefile $(srcdir)/generate_user_env.awk
@echo "# source this file to access $(PACKAGE_NAME)" >$@
@echo "set LAL_PREFIX $(prefix)" >>$@
@echo "prepend PATH $(bindir)" >>$@
@echo "prepend MANPATH $(mandir)" >>$@
@echo "prepend PKG_CONFIG_PATH $(libdir)/pkgconfig" >>$@
@echo "prepend PYTHONPATH $(pyexecdir) $(pythondir)" >>$@
@echo "prepend LAL_DATA_PATH $(pkgdatadir)" >>$@
@echo "prepend OCTAVE_PATH $(octexecdir)" >>$@
lal-user-env.csh lal-user-env.sh: lal-user-env.shell $(srcdir)/generate_user_env.awk
$(AM_V_GEN)$(AWK) -f $(srcdir)/generate_user_env.awk -v SED="$(SED)" -v output="$@" $<
BUILT_SOURCES =
MOSTLYCLEANFILES =
if HAVE_GIT_REPO
BUILT_SOURCES += LALVCSInfo.h
......
../../../gnuscripts/generate_user_env.awk
\ No newline at end of file
......@@ -23,6 +23,9 @@ doc/lalapps.out
doc/lalapps.pdf
doc/lalapps.toc
lalapps-*.tar.gz
lalapps-user-env.csh
lalapps-user-env.sh
lalapps-user-env.shell
lalapps.spec
libtool
src/*/python_config.sed
......@@ -139,9 +142,6 @@ src/inspiral/ssipe_config.sed
src/lalapps/LALAppsBuildInfo.c
src/lalapps/LALAppsVCSInfo.h
src/lalapps/git_version.py
src/lalapps/lalapps-user-env.csh
src/lalapps/lalapps-user-env.sh
src/lalapps/lalapps-user-env.shell
src/lalapps/lalapps_cache
src/lalapps/lalapps_fftw*_wisdom
src/lalapps/lalapps_tconvert
......
BUILT_SOURCES =
sysconf_DATA =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_user_env.am
ACLOCAL_AMFLAGS = -I gnuscripts
if HAVE_GIT_REPO
......@@ -8,7 +14,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(SHELL) ./00boot
endif # HAVE_GIT_REPO
EXTRA_DIST = \
EXTRA_DIST += \
README \
README.bugs \
README.contrib \
......@@ -21,6 +27,14 @@ SUBDIRS = \
doc \
man
user_environment = \
set $(PACKAGE)_PREFIX $(prefix); \
prepend LAL_DATA_PATH $(pkgdatadir); \
prepend MANPATH $(mandir); \
prepend PATH $(bindir); \
prepend PYTHONPATH $(pyexecdir) $(pythondir); \
$(END_OF_LIST)
all-local:
@echo "";\
echo "==================================================";\
......
../lal/generate_user_env.awk
\ No newline at end of file
../../gnuscripts/lalsuite_user_env.am
\ No newline at end of file
......@@ -74,44 +74,15 @@ EXTRA_DIST = \
__init__.py \
fftw_wisdom.c \
fftwf_wisdom.c \
generate_user_env.awk \
lalappsfrutils.c \
lalappsfrutils.h \
processtable.c \
processtable.h \
git_version.py
BUILT_SOURCES =
MOSTLYCLEANFILES =
CLEANFILES = \
lalapps-user-env.shell \
lalapps-user-env.sh \
lalapps-user-env.csh
sysconf_DATA = \
lalapps-user-env.sh \
lalapps-user-env.csh
BUILT_SOURCES = \
lalapps-user-env.sh \
lalapps-user-env.csh
if HAVE_PYTHON
lalapps_pythonpath = $(pyexecdir) $(pythondir)
else
lalapps_pythonpath =
endif
lalapps-user-env.shell: Makefile $(srcdir)/generate_user_env.awk
@echo "# source this file to access $(PACKAGE_NAME)" >$@
@echo "prepend PATH $(bindir)" >>$@
@echo "prepend MANPATH $(mandir)" >>$@
@echo "prepend PYTHONPATH $(lalapps_pythonpath)" >>$@
@echo "prepend LAL_DATA_PATH $(pkgdatadir)" >>$@
lalapps-user-env.csh lalapps-user-env.sh: lalapps-user-env.shell $(srcdir)/generate_user_env.awk
$(AM_V_GEN)$(AWK) -f $(srcdir)/generate_user_env.awk -v SED="$(SED)" -v output="$@" $<
if HAVE_GIT_REPO
BUILT_SOURCES += LALAppsVCSInfo.h
MOSTLYCLEANFILES += LALAppsVCSInfo.h
......
../../../gnuscripts/generate_user_env.awk
\ No newline at end of file
......@@ -15,6 +15,9 @@ include/lal/*.h
include/lal/*.i
include/lal/header-link-stamp
lalburst-*.tar.gz
lalburst-user-env.csh
lalburst-user-env.sh
lalburst-user-env.shell
lalburst.spec
libtool
python/__init__.py
......@@ -25,9 +28,6 @@ src/LALBurstVCSInfo.h
src/config.h
src/config.h.in
src/git_version
src/lalburst-user-env.csh
src/lalburst-user-env.sh
src/lalburst-user-env.shell
src/stamp-h1
src/stamp-h2
test/CLRTest
......
BUILT_SOURCES =
sysconf_DATA =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_user_env.am
ACLOCAL_AMFLAGS = -I gnuscripts
if HAVE_GIT_REPO
......@@ -8,7 +14,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(SHELL) ./00boot
endif # HAVE_GIT_REPO
EXTRA_DIST = \
EXTRA_DIST += \
doc \
lalburst.spec \
$(DATA)
......@@ -21,10 +27,20 @@ SUBDIRS = \
test \
swig
user_environment = \
set $(PACKAGE)_PREFIX $(prefix); \
prepend LAL_DATA_PATH $(pkgdatadir); \
prepend MANPATH $(mandir); \
prepend OCTAVE_PATH $(octexecdir); \
prepend PATH $(bindir); \
prepend PKG_CONFIG_PATH $(libdir)/pkgconfig; \
prepend PYTHONPATH $(pyexecdir) $(pythondir); \
$(END_OF_LIST)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = lalburst.pc
noinst_DATA = lalburst-uninstalled.pc
BUILT_SOURCES = lalburst-uninstalled.pc
BUILT_SOURCES += lalburst-uninstalled.pc
all-local:
@echo "";\
......
../lal/generate_user_env.awk
\ No newline at end of file
../../gnuscripts/lalsuite_user_env.am
\ No newline at end of file
......@@ -51,39 +51,15 @@ nodist_liblalburst_la_SOURCES = LALBurstBuildInfo.c
liblalburst_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBVERSION)
MOSTLYCLEANFILES = \
lalburst-user-env.shell \
lalburst-user-env.sh \
lalburst-user-env.csh
sysconf_DATA = \
lalburst-user-env.sh \
lalburst-user-env.csh
BUILT_SOURCES = \
lalburst-user-env.sh \
lalburst-user-env.csh
lalburst-user-env.shell: Makefile $(srcdir)/generate_user_env.awk
@echo "# source this file to access $(PACKAGE_NAME)" >$@
@echo "set LALBURST_PREFIX $(prefix)" >>$@
@echo "prepend PATH $(bindir)" >>$@
@echo "prepend MANPATH $(mandir)" >>$@
@echo "prepend PKG_CONFIG_PATH $(libdir)/pkgconfig" >>$@
@echo "prepend PYTHONPATH $(pyexecdir)" >>$@
@echo "prepend LAL_DATA_PATH $(pkgdatadir)" >>$@
@echo "prepend OCTAVE_PATH $(octexecdir)" >>$@
lalburst-user-env.csh lalburst-user-env.sh: lalburst-user-env.shell $(srcdir)/generate_user_env.awk
$(AM_V_GEN)$(AWK) -f $(srcdir)/generate_user_env.awk -v SED="$(SED)" -v output="$@" $<
EXTRA_DIST = \
LALBurstConfig.h.in \
config.h.in \
generate_user_env.awk
config.h.in
DISTCLEANFILES = config.h
BUILT_SOURCES =
MOSTLYCLEANFILES =
if HAVE_GIT_REPO
BUILT_SOURCES += LALBurstVCSInfo.h
MOSTLYCLEANFILES += LALBurstVCSInfo.h
......
../../gnuscripts/generate_user_env.awk
\ No newline at end of file
......@@ -19,6 +19,9 @@ include/lal/*.h
include/lal/*.i
include/lal/header-link-stamp
laldetchar-*.tar.gz
laldetchar-user-env.csh
laldetchar-user-env.sh
laldetchar-user-env.shell
laldetchar.spec
libtool
python/__init__.py
......@@ -29,8 +32,5 @@ src/LALDetCharVCSInfo.h
src/config.h
src/config.h.in
src/laldetchar-hveto
src/laldetchar-user-env.csh
src/laldetchar-user-env.sh
src/laldetchar-user-env.shell
src/stamp-h1
src/stamp-h2
BUILT_SOURCES =
sysconf_DATA =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_user_env.am
ACLOCAL_AMFLAGS = -I gnuscripts
if HAVE_GIT_REPO
......@@ -8,7 +14,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(SHELL) ./00boot
endif # HAVE_GIT_REPO
EXTRA_DIST = \
EXTRA_DIST += \
laldetchar.spec \
$(DATA)
......@@ -21,10 +27,20 @@ SUBDIRS = \
test \
swig
user_environment = \
set $(PACKAGE)_PREFIX $(prefix); \
prepend LAL_DATA_PATH $(pkgdatadir); \
prepend MANPATH $(mandir); \
prepend OCTAVE_PATH $(octexecdir); \
prepend PATH $(bindir); \
prepend PKG_CONFIG_PATH $(libdir)/pkgconfig; \
prepend PYTHONPATH $(pyexecdir) $(pythondir); \
$(END_OF_LIST)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = laldetchar.pc
noinst_DATA = laldetchar-uninstalled.pc
BUILT_SOURCES = laldetchar-uninstalled.pc
BUILT_SOURCES += laldetchar-uninstalled.pc
all-local:
@echo "";\
......
../lal/generate_user_env.awk
\ No newline at end of file
../../gnuscripts/lalsuite_user_env.am
\ No newline at end of file
......@@ -27,41 +27,17 @@ nodist_liblaldetchar_la_SOURCES = LALDetCharBuildInfo.c
liblaldetchar_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBVERSION)
MOSTLYCLEANFILES = \
laldetchar-user-env.shell \
laldetchar-user-env.sh \
laldetchar-user-env.csh
sysconf_DATA = \
laldetchar-user-env.sh \
laldetchar-user-env.csh
#bin_PROGRAMS = \
#laldetchar-hveto
#laldetchar_hveto_SOURCES = hveto.c
BUILT_SOURCES = \
laldetchar-user-env.sh \
laldetchar-user-env.csh
laldetchar-user-env.shell: Makefile $(srcdir)/generate_user_env.awk
@echo "# source this file to access $(PACKAGE_NAME)" >$@
@echo "set LALDETCHAR_PREFIX $(prefix)" >>$@
@echo "prepend PATH $(bindir)" >>$@
@echo "prepend MANPATH $(mandir)" >>$@
@echo "prepend PKG_CONFIG_PATH $(libdir)/pkgconfig" >>$@
@echo "prepend PYTHONPATH $(pyexecdir)" >>$@
@echo "prepend LAL_DATA_PATH $(pkgdatadir)" >>$@
@echo "prepend OCTAVE_PATH $(octexecdir)" >>$@
laldetchar-user-env.csh laldetchar-user-env.sh: laldetchar-user-env.shell $(srcdir)/generate_user_env.awk
$(AM_V_GEN)$(AWK) -f $(srcdir)/generate_user_env.awk -v SED="$(SED)" -v output="$@" $<
EXTRA_DIST = \
LALDetCharConfig.h.in \
config.h.in \
generate_user_env.awk
config.h.in
BUILT_SOURCES =
MOSTLYCLEANFILES =
if HAVE_GIT_REPO
BUILT_SOURCES += LALDetCharVCSInfo.h
......
../../gnuscripts/generate_user_env.awk
\ No newline at end of file
......@@ -15,6 +15,9 @@ include/lal/*.h
include/lal/*.i
include/lal/header-link-stamp
lalframe-*.tar.gz
lalframe-user-env.csh
lalframe-user-env.sh
lalframe-user-env.shell
lalframe.spec
libtool
python/__init__.py
......@@ -25,9 +28,6 @@ src/LALFrameVCSInfo.h
src/config.h
src/config.h.in
src/lalfr-*[!1]
src/lalframe-user-env.csh
src/lalframe-user-env.sh
src/lalframe-user-env.shell
src/stamp-h1
src/stamp-h2
test/AggregationTest
......
BUILT_SOURCES =
sysconf_DATA =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_user_env.am
ACLOCAL_AMFLAGS = -I gnuscripts
if HAVE_GIT_REPO
......@@ -8,7 +14,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(SHELL) ./00boot
endif # HAVE_GIT_REPO
EXTRA_DIST = \
EXTRA_DIST += \
lalframe.spec \
$(DATA)
......@@ -20,10 +26,20 @@ SUBDIRS = \