1 |
#!/bin/sh |
2 |
# |
3 |
# Shell script to controls building several module files and |
4 |
# then moving them to a common "package" directory. |
5 |
# This script uses the build_mod.sh script to build the |
6 |
# individual module source files. |
7 |
# |
8 |
# Usage: |
9 |
# build_pkg.sh pkg_prefix |
10 |
# |
11 |
# where |
12 |
# pkg_prefix is a character string that is used to prefix |
13 |
# the package. |
14 |
# |
15 |
fc=`which $0` |
16 |
sroot=${fc%/*} |
17 |
. ${sroot}/build_pkg_funcs.sh |
18 |
build_mod=${sroot}/../build_mod/build_mod.sh |
19 |
rootdir=`pwd` |
20 |
|
21 |
# See which action was requested and exit with usage if it isn't |
22 |
# there or is an unrecognised string. |
23 |
action=$1 |
24 |
check_action $action |
25 |
|
26 |
# Set name of file standard output is written |
27 |
export STDOUT=build_pkg.stdout |
28 |
export ERROUT=build_pkg.stderr |
29 |
\rm -fr ${STDOUT} ${STDERR} |
30 |
touch ${STDOUT} ${STDERR} |
31 |
# Set name of file with package name |
32 |
export PKG_NAME_FILE=package_name |
33 |
|
34 |
# Read the package name from ${PKG_NAME_FILE} |
35 |
com='PKG_NAME=`(grep -v '^#' ${PKG_NAME_FILE})`' |
36 |
if [ -r ${PKG_NAME_FILE} ]; then |
37 |
export PKG_NAME=`(grep -v '^#' ${PKG_NAME_FILE}) 2> ${STDOUT}` |
38 |
rc=$? |
39 |
else |
40 |
rc=2 |
41 |
fi |
42 |
check_rc_exit $rc "$com" \ |
43 |
"Error reading name of package from file \"${PKG_NAME_FILE}\"" |
44 |
|
45 |
if [ x"$#" != "x1" ]; then |
46 |
write_usage |
47 |
fi |
48 |
|
49 |
echo "# Building package \"$1\"" |
50 |
|
51 |
mkdir -p $1.pkg |
52 |
MOD_DIR_LIST=${1}.dirlist |
53 |
{ |
54 |
while read line ; do |
55 |
is_comment_line $line; rc=$? |
56 |
if [ "x$rc" == "x0" ]; then |
57 |
fname=$line |
58 |
echo "Moving to directory \"$fname\"" |
59 |
cd $fname |
60 |
${build_mod} |
61 |
cd built_src |
62 |
cp *.F90 ${rootdir}/$1.pkg |
63 |
fi |
64 |
done |
65 |
} < ${MOD_DIR_LIST} |
66 |
cd $rootdir |