Skip to content

Commit 78b30bf

Browse files
author
Damian Rouson
committed
Arguments -p/--package install specified package
build.sh correctly responds to the following arguments: -d --debug -D --print-downloader -h --help -i --install-dir -j --num-threads -I --install-version -l --list-packages -n --no-color -p --package -P --print-path -U --print-url -V --print-version build.sh accepts compiler specifications Enabled the following arguments: -c --with-c [arg] Default="gcc" -C --with-cxx [arg] Default="g++" -f --with-fortran [arg] Default="gfortran" Correct catastrophic typo in build_and_install.sh Fixed CMake build on OS X. install-binary.sh works for ofp & its prereqs ./install.sh -p [arg] works for arg={ofp|aterm|sdf2-bundle|strategoxt} Started OFP installation sript. install-ofp.sh nearly complete install-binary.sh installs OFP prerequisites The following command installs the three Open Fortran Parser prerequisites: ./install-binary.sh -p strategoxt-superbundle -i /opt Corrected typo in strategoxt-superbundle URL. Refactored move_binaries_to_install_path.sh enable -D, -P, -U ,V arguments with install-ofp.sh ./install-ofp.sh -P prints the default installation paths for OFP an its prequisites ./install-ofp.sh -U prints the URL used to download OFP an its prequisites ./install-ofp.sh -D prints the default download programs for OFP an its prequisites ./install-ofp.sh -V prints the default versions for OFP an its prequisites Fully working draft of boilerplated OFP install ./install-ofp.sh now downloads and installs OFP and its prerequisites and builds the OFP parse table. Adjust installation names/paths in install-ofp.sh
1 parent 3e5f189 commit 78b30bf

24 files changed

+705
-57
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Make the build directory, configure, and build
2+
build_and_install()
3+
{
4+
num_threads=${arg_j}
5+
build_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/builds/${package_to_build}-${version_to_build}"
6+
7+
info "Building ${package_to_build} ${version_to_build}"
8+
info "Build path: ${build_path}"
9+
10+
set_SUDO_if_needed_to_write_to_directory "${build_path}"
11+
set_SUDO_if_needed_to_write_to_directory "${install_path}"
12+
mkdir -p "${build_path}"
13+
info "pushd ${build_path}"
14+
pushd "${build_path}"
15+
if [[ "${package_to_build}" == "gcc" ]]; then
16+
info 'pushd ${download_path}/${package_source_directory} '
17+
pushd "${download_path}/${package_source_directory}"
18+
"${PWD}"/contrib/download_prerequisites
19+
info "popd"
20+
popd
21+
info "Configuring with the following command:"
22+
info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror"
23+
"${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror
24+
info "Building with the following command: 'make -j${num_threads} bootstrap'"
25+
make "-j${num_threads}" bootstrap
26+
if [[ ! -z "${SUDO:-}" ]]; then
27+
info "You do not have write permissions to the installation path ${install_path}"
28+
info "If you have administrative privileges, enter your password to install ${package_to_build}"
29+
fi
30+
info "Installing with the following command: ${SUDO:-} make install"
31+
${SUDO:-} make install
32+
else
33+
info "Configuring ${package_to_build} ${version_to_build} with the following command:"
34+
info "CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" \"${download_path}/${package_source_directory}\"/configure --prefix=\"${install_path}\""
35+
CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" "${download_path}/${package_source_directory}"/configure --prefix="${install_path}"
36+
info "Building with the following command:"
37+
info "CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" make -j\"${num_threads}\""
38+
CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" make "-j${num_threads}"
39+
info "Installing ${package_to_build} in ${install_path}"
40+
if [[ ! -z "${SUDO:-}" ]]; then
41+
info "You do not have write permissions to the installation path ${install_path}"
42+
info "If you have administrative privileges, enter your password to install ${package_to_build}"
43+
fi
44+
info "Installing with the following command: ${SUDO:-} make install"
45+
${SUDO:-} make install
46+
fi
47+
info "popd"
48+
popd
49+
}

prerequisites/build-functions/download_if_necessary.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
source "${OPENCOARRAYS_SRC_DIR:-}/install_prerequisites/build-functions/ftp-url.sh"
2-
source "${OPENCOARRAYS_SRC_DIR:-}/install_prerequisites/build-functions/set_SUDO_if_needed_to_create.sh"
1+
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/ftp-url.sh"
2+
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
33

44
# Download pkg-config if the tar ball is not already in the present working directory
55
download_if_necessary()
66
{
7-
download_path="${PWD}/opencoarrays-downloads"
8-
set_SUDO_if_needed_to_create_directory "${download_path}"
7+
download_path="${PWD}/downloads"
8+
set_SUDO_if_needed_to_write_to_directory "${download_path}"
99
if [ -f $url_tail ] || [ -d $url_tail ]; then
1010
info "Found '${url_tail}' in ${PWD}."
11-
info "If it resulted from an incomplete download, building ${package_to_build} could fail."
11+
info "If it resulted from an incomplete download, building ${package_name} could fail."
1212
info "Would you like to proceed anyway? (y/n)"
1313
read proceed
1414
if [[ "${proceed}" == "y" ]]; then
@@ -20,9 +20,9 @@ download_if_necessary()
2020
fi
2121
elif ! type "${fetch}" &> /dev/null; then
2222
# The download mechanism is missing
23-
info "The default download mechanism for ${package_to_build} is ${fetch}."
23+
info "The default download mechanism for ${package_name} is ${fetch}."
2424
info "Please either ensure that ${fetch} is installed and in your PATH"
25-
info "or download the ${package_to_build} source from "
25+
info "or download the ${package_name} source from "
2626
info "${package_url}"
2727
#called_by_install_sh=`echo "$(ps -p $PPID -o args=)" | grep install.sh`
2828
info "Place the downloaded file in ${download_path} and restart this script."
@@ -50,9 +50,9 @@ download_if_necessary()
5050
if [[ "${fetch}" == "svn" || "${fetch}" == "git" ]]; then
5151
package_source_directory="${url_tail}"
5252
else
53-
package_source_directory="${package_to_build}-${version_to_build}"
53+
package_source_directory="${package_name}-${version_to_build}"
5454
fi
55-
info "Downloading ${package_to_build} ${version_to_build} to the following location:"
55+
info "Downloading ${package_name} ${version_to_build} to the following location:"
5656
info "${download_path}/${package_source_directory}"
5757
info "Download command: ${fetch} ${args} ${package_url}"
5858
info "Depending on the file size and network bandwidth, this could take several minutes or longer."
@@ -69,10 +69,10 @@ download_if_necessary()
6969
search_path="${download_path}/${url_tail}"
7070
fi
7171
if [ -f "${search_path}" ] || [ -d "${search_path}" ]; then
72-
info "Download succeeded. The "${package_to_build}" source is in the following location:"
72+
info "Download succeeded. The "${package_name}" source is in the following location:"
7373
info "${search_path}"
7474
else
75-
info "Download failed. The "${package_to_build}" source is not in the following, expected location:"
75+
info "Download failed. The "${package_name}" source is not in the following, expected location:"
7676
info "${search_path}"
7777
emergency "Aborting. [exit 110]"
7878
fi

prerequisites/build-functions/ftp-url.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
# ftp-url -n ftp.gnu.org:/gnu/m4/m4-1.4.17.tar.bz2
88
ftp-url()
99
{
10-
ftp_mode=$1
11-
url=$2
10+
ftp_mode="${1}"
11+
url="${2}"
1212

1313
text_before_colon="${url%%:*}"
14-
FTP_SERVER=$text_before_colon
14+
FTP_SERVER="${text_before_colon}"
1515

1616
text_after_colon="${url##*:}"
1717
text_after_final_slash="${text_after_colon##*/}"
18-
FILE_NAME=$text_after_final_slash
18+
FILE_NAME="${text_after_final_slash}"
1919

2020
text_before_final_slash="${text_after_colon%/*}"
21-
FILE_PATH="$text_before_final_slash"
21+
FILE_PATH="${text_before_final_slash}"
2222

2323
USERNAME=anonymous
2424
PASSWORD=""
25-
echo "$this_script: starting anonymous download: ftp $ftp_mode $FTP_SERVER... cd $FILE_PATH... get $FILE_NAME"
25+
info "starting anonymous download: ftp ${ftp_mode} ${FTP_SERVER}... cd ${FILE_PATH}... get ${FILE_NAME}"
2626

27-
ftp $ftp_mode $FTP_SERVER <<Done-ftp
28-
user $USERNAME $PASSWORD
29-
cd $FILE_PATH
27+
ftp "${ftp_mode}" "${FTP_SERVER}" <<Done-ftp
28+
user "${USERNAME}" "${PASSWORD}"
29+
cd "${FILE_PATH}"
3030
passive
3131
binary
32-
get "$FILE_NAME"
32+
get "${FILE_NAME}"
3333
bye
3434
Done-ftp
3535

36-
echo "$this_script: finished anonymous ftp"
36+
info "finished anonymous ftp"
3737
}

prerequisites/build-functions/set_SUDO_if_needed_to_create.sh renamed to prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Define the sudo command to be used if the installation path requires administrative permissions
2-
set_SUDO_if_needed_to_create_directory()
2+
set_SUDO_if_needed_to_write_to_directory()
33
{
44
if [[ $# != "1" ]]; then
5-
emergency "set_SUDO_if_needed_to_create takes exactly one argument"
5+
emergency "set_SUDO_if_needed_to_write_to_directory takes exactly one argument"
66
else
77
directory_to_create=$1
88
fi
99
if [[ -z "${LD_LIBRARY_PATH:-}" ]]; then
1010
info "\${LD_LIBRARY_PATH} is empty. Try setting it if the compiler encounters linking problems."
1111
fi
12-
SUDO_COMMAND="sudo env LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}"
13-
info "Checking whether the ${directory_to_create} exists... "
12+
SUDO_COMMAND="sudo env LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-""}"
13+
info "Checking whether the directory ${directory_to_create} exists... "
1414
if [[ -d "${directory_to_create}" ]]; then
1515
info "yes"
16-
info "Checking whether I have write permissions to create ${directory_to_create} ... "
16+
info "Checking whether I have write permissions to ${directory_to_create} ... "
1717
if [[ -w "${directory_to_create}" ]]; then
1818
info "yes"
1919
else
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Set CC, CXX, and FC
2+
set_compilers()
3+
{
4+
# If FC is already set, use the set value.
5+
# Else if FC is empty, use the value specified via the -f or --with-fortran command-line arguments.
6+
# Else use the default specifed in ../build.sh-usage.
7+
FC=${FC:-${arg_f}}
8+
info "Fortran compiler: ${FC}"
9+
10+
if [[ `uname` == "Darwin" && "${package_to_build}" == "cmake" ]]; then
11+
if [[ -x "/usr/bin/gcc" ]]; then
12+
[ ! -z ${CC:-} ] && info "Overriding CC: cmake build requires Apple LLVM gcc, which XCode command-line tools puts in /usr/bin"
13+
CC=/usr/bin/gcc
14+
else
15+
info "OS X detected. Please install XCode command-line tools and "
16+
emergency "ensure that /usr/bin/gcc exists and is executable. Aborting."
17+
fi
18+
else
19+
# If CC is already set, use the set value.
20+
# Else if CC is empty, use the value specified via the -c or --with-c command-line arguments.
21+
# Else use the default specifed in ../build.sh-usage.
22+
CC=${CC:-${arg_c}}
23+
fi
24+
info "C compiler: ${CC}"
25+
26+
if [[ `uname` == "Darwin" && ${package_to_build} == "cmake" ]]; then
27+
if [[ -x "/usr/bin/g++" ]]; then
28+
[ ! -z ${CXX:-} ] && info "Overriding CXX: cmake build requires Apple LLVM g++, which XCode command-line tools puts in /usr/bin"
29+
CXX=/usr/bin/g++
30+
else
31+
info "OS X detected. Please install XCode command-line tools and "
32+
emergency "ensure that /usr/bin/g++ exists and is executable. Aborting."
33+
fi
34+
else
35+
# If CXX is already set, use the set value.
36+
# Else if CXX is empty, use the value specified via the -C or --with-cxx command-line arguments.
37+
# Else use the default specifed in ../build.sh-usage.
38+
CXX=${CXX:-${arg_C}}
39+
fi
40+
info "C++ compiler: ${CXX}"
41+
}

prerequisites/build-functions/set_or_list_versions.sh renamed to prerequisites/build-functions/set_or_print_default_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# If -p, -D, -P, or -U specifies a package, set default_version
22
# If -V specifies a package, print the default_version and exit with normal status
33
# If -l is present, list all packages and versions and exit with normal status
4-
set_or_list_versions()
4+
set_or_print_default_version()
55
{
66
# Verify requirements
77
[ "${arg_l}" == "${__flag_present}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}" ] &&
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# If -P specifies a package, print the installation path and exit with normal status
2+
# Otherwise, set install_path
3+
set_or_print_installation_path()
4+
{
5+
# Verify requirements
6+
[ ! -z "${arg_P}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_U:-${arg_V}}}}" ] &&
7+
emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
8+
9+
# ../build.sh-usage specifies the following installation path default for illustrative purposes only:
10+
# Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name:-}/${version_to_build:-}/"
11+
# When the parse_command_line function executes, ${package_name:-} and ${version_to_build:-} are empty,
12+
# but they have been set before reaching the current function so now we can get the true values if the
13+
# user didn't override the default:
14+
15+
path_in_usage_file="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations///"
16+
if [[ "${arg_i}" == "${path_in_usage_file}" ]]; then
17+
install_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name}/${version_to_build}/"
18+
else
19+
install_path="${arg_i}"
20+
fi
21+
22+
# If -P is present, print ${install_path} and exit with normal status
23+
if [[ ! -z "${arg_P:-}" ]]; then
24+
printf "${install_path}\n"
25+
exit 0
26+
fi
27+
28+
info "${package_name} ${version_to_build} installation path: ${install_path}"
29+
}

prerequisites/build-functions/set_package_url.sh renamed to prerequisites/build-functions/set_or_print_url.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# If -p, -D, -P, or -V specifies a package, set package_url
22
# If -U specifies a package, print the package_url and exit with normal status
3-
set_package_url()
3+
set_or_print_url()
44
{
55
# Verify requirements
66
[ ! -z "${arg_U}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_V}}}}" ] &&

prerequisites/build-functions/unpack_if_necessary.sh

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ unpack_if_necessary()
99
pushd "${download_path}"
1010
tar xf "${url_tail}"
1111
popd
12-
package_source_directory="${package_to_build}-${version_to_build}"
12+
package_source_directory="${package_name}-${version_to_build}"
1313
fi
1414
}

prerequisites/build-tau.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# (3) Parse the usage information (default usage file name: current file's name with -usage appended).
3131
# (4) Parse the command line using the usage information.
3232

33-
export __usage=${OPENCOARRAYS_SRC_DIR}/install_prerequisites/build.sh-usage
33+
export __usage=${OPENCOARRAYS_SRC_DIR}/prerequisites/build.sh-usage
3434

3535
### Start of boilerplate -- do not edit this block #######################
3636
if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
@@ -107,6 +107,6 @@ info "arg_U: ${arg_U}"
107107
info "arg_v: ${arg_v}"
108108
info "arg_V: ${arg_V}"
109109

110-
source "${OPENCOARRAYS_SRC_DIR:-}"/install_prerequisites/set_or_list_versions.sh
110+
source "${OPENCOARRAYS_SRC_DIR:-}"/prerequisites/set_or_list_versions.sh
111111
set_or_list_versions
112112
[[ ! -z "${arg_p}" ]] && info "package (default version): ${arg_p} (${default_version})"

0 commit comments

Comments
 (0)