-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModuleRecipe
More file actions
123 lines (114 loc) · 4.62 KB
/
ModuleRecipe
File metadata and controls
123 lines (114 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
MODULEDIR="$INSTALLROOT/etc/modulefiles"
MODULEFILE=$MODULEDIR/$PKGNAME
MODULE_OPTIONS="--bin --lib"
function GenerateModule() {
# --bin prepends $PKG_ROOT/bin to PATH, sets ${PKGNAME}_ROOT
# --lib prepends $PKG_ROOT/lib and $PKG_ROOT/lib64 to LD_LIBRARY_PATH,
# sets ${PKGNAME}_INCLUDE_DIR (lib64 is a no-op if the dir does not exist)
# --inc sets ${PKGNAME}_INCLUDE_DIR
# --cmake prepends $PKG_ROOT to CMAKE_PREFIX_PATH
# --root sets ${PKGNAME}_ROOT
# --python prepends $PKG_ROOT/lib/pythonX.Y/site-packages to PYTHONPATH
# (versioned; requires PYTHON_MAJOR_MINOR to be set, e.g. via PythonRecipe)
# --root-inc prepends $PKG_ROOT/include to ROOT_INCLUDE_PATH
# (used by ROOT's ACLiC/cling to locate headers; add for all HEP libraries)
# --pylib prepends $PKG_ROOT/lib to PYTHONPATH
# (for packages that install .py files directly under lib/, e.g. ROOT/PyROOT)
# --pysite prepends $PKG_ROOT/lib/python/site-packages to PYTHONPATH
# (for C++ packages with Python bindings at an unversioned site-packages path)
# --pkgconfig prepends $PKG_ROOT/lib/pkgconfig to PKG_CONFIG_PATH
# (for packages that install .pc files)
HAS_BIN=
HAS_LIB=
HAS_CMAKE=
HAS_ROOT=
HAS_INC=
HAS_PYTHON=
HAS_ROOT_INC=
HAS_PYLIB=
HAS_PYSITE=
HAS_PKGCONFIG=
while [ "X$#" != "X0" ]; do
case $1 in
--bin) HAS_BIN=true; HAS_ROOT=true; shift ;;
--lib) HAS_LIB=true; HAS_INC=true; shift ;;
--inc) HAS_INC=true; shift ;;
--cmake) HAS_CMAKE=true; shift ;;
--root) HAS_ROOT=true; shift ;;
--python) HAS_PYTHON=true; shift ;;
--root-inc) HAS_ROOT_INC=true; shift ;;
--pylib) HAS_PYLIB=true; shift ;;
--pysite) HAS_PYSITE=true; shift ;;
--pkgconfig) HAS_PKGCONFIG=true; shift ;;
*) shift ;;
esac
done
cat << EOF
#%Module1.0
proc ModulesHelp { } {
global version
puts stderr "Modulefile for $PKGNAME $PKGVERSION-@@PKGREVISION@$PKGHASH@@"
}
set version $PKGVERSION-@@PKGREVISION@$PKGHASH@@
module-whatis "Modulefile for $PKGNAME $PKGVERSION-@@PKGREVISION@$PKGHASH@@"
# Dependencies
EOF
printf "if ![ is-loaded 'BASE/1.0' ] {\n module load BASE/1.0\n}"
echo BUILD_REQUIRES=$BUILD_REQUIRES >&2
FULL_BUILD_REQUIRES=${FULL_BUILD_REQUIRES:-$BUILD_REQUIRES}
echo FULL_BUILD_REQUIRES=$FULL_BUILD_REQUIRES >&2
# Dependencies
for x in `env | cut -f1 -d= | grep -v "^DEFAULT_" | grep -v PKGREVISION | grep -v _RECIPE_TOOLS | grep REVISION | sed -e 's/_REVISION//'`; do
REVISION_VALUE=`eval "echo $(echo \\$$(echo ${x}_REVISION))"`
VERSION_VALUE=`eval "echo $(echo \\$$(echo ${x}_VERSION))"`
ROOT_PATH_VALUE=`eval "echo $(echo \\$$(echo ${x}_ROOT))"`
if echo $FULL_BUILD_REQUIRES | tr [:lower:] [:upper:] | tr - _ | tr \ \\n | grep -q "^$x$"; then
echo $x is a build_requires. Skipping loading the associated module. >&2
elif [ -d $ROOT_PATH_VALUE/etc/modulefiles ]; then
for filename in `find $ROOT_PATH_VALUE/etc/modulefiles -type f ! -name '*.*' | xargs -n1 basename`; do
printf "\nif ![ is-loaded \"${REVISION_LABEL:-$filename/$VERSION_VALUE-$REVISION_VALUE}\" ] { module load ${REVISION_LABEL:-$filename/$VERSION_VALUE-$REVISION_VALUE} }"
done
fi
done
printf "\n\nset PKG_ROOT \$::env(BASEDIR)/$PKGNAME/\$version\n"
if [ X$HAS_BIN = Xtrue ]; then
printf "prepend-path PATH \$PKG_ROOT/bin\n"
fi
if [ X$HAS_LIB = Xtrue ]; then
printf "prepend-path LD_LIBRARY_PATH \$PKG_ROOT/lib\n"
printf "prepend-path LD_LIBRARY_PATH \$PKG_ROOT/lib64\n"
fi
PKGNAME_UPPER=$(echo "${PKGNAME}" | tr '[:lower:]-' '[:upper:]_')
if [ X$HAS_INC = Xtrue ]; then
printf "setenv ${PKGNAME_UPPER}_INCLUDE_DIR \$PKG_ROOT/include\n"
fi
if [ X$HAS_CMAKE = Xtrue ]; then
printf "prepend-path CMAKE_PREFIX_PATH \$PKG_ROOT\n"
fi
if [ X$HAS_ROOT = Xtrue ]; then
printf "setenv ${PKGNAME_UPPER}_ROOT \$PKG_ROOT\n"
fi
if [ X$HAS_PYTHON = Xtrue ] && [ -n "${PYTHON_MAJOR_MINOR:-}" ]; then
printf "prepend-path PYTHONPATH \$PKG_ROOT/lib/python${PYTHON_MAJOR_MINOR}/site-packages\n"
fi
if [ X$HAS_ROOT_INC = Xtrue ]; then
printf "prepend-path ROOT_INCLUDE_PATH \$PKG_ROOT/include\n"
fi
if [ X$HAS_PYLIB = Xtrue ]; then
printf "prepend-path PYTHONPATH \$PKG_ROOT/lib\n"
fi
if [ X$HAS_PYSITE = Xtrue ]; then
printf "prepend-path PYTHONPATH \$PKG_ROOT/lib/python/site-packages\n"
fi
if [ X$HAS_PKGCONFIG = Xtrue ]; then
printf "prepend-path PKG_CONFIG_PATH \$PKG_ROOT/lib/pkgconfig\n"
printf "prepend-path PKG_CONFIG_PATH \$PKG_ROOT/lib64/pkgconfig\n"
fi
echo
}
function MakeModule () {
mkdir -p $MODULEDIR
mkdir -p etc/modulefiles
GenerateModule $MODULE_OPTIONS > etc/modulefiles/$PKGNAME
rsync -a --delete etc/modulefiles/ $MODULEDIR
}