]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow setup_astyle.sh to be used on macOS as well 6204/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 8 Apr 2018 16:33:52 +0000 (18:33 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 8 Apr 2018 16:51:00 +0000 (18:51 +0200)
contrib/utilities/indent
contrib/utilities/setup_astyle.sh

index dd0923ff55b2f572a17bb7064f37c1da712aa5c5..b18c59af6af4d0edcb33552e3b554d0bceaa4408 100755 (executable)
@@ -36,7 +36,7 @@ if test ! -d source -o ! -d include -o ! -d examples ; then
 fi
 
 # Add the location 'setup_astyle.sh' installs astyle to to the local PATH.
-ASTYLE_PATH="$(realpath contrib/utilities)/programs/astyle/build/gcc/bin"
+ASTYLE_PATH="$(cd "$(dirname "$0")" && pwd)/programs/astyle/bin"
 export PATH=$ASTYLE_PATH:$PATH
 
 if test ! -f contrib/styles/astyle.rc ; then
index e9296a16b10fdab5b2c9fa56001a85a5561aeddb..8005442b54a27391937a67c8b86f9615b8fdff3a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 ## ---------------------------------------------------------------------
 ##
 ## Copyright (C) 2018 by the deal.II authors
 ## ---------------------------------------------------------------------
 
 #
-# This script downloads and installs astyle-2.04 in programs/astyle/build/gcc.
+# This script downloads and installs astyle-2.04 in programs/astyle/bin.
 # The installed binary is used in the 'indent' script in case astyle is
 # installed by this script.
 #
-# This script only works on Linux, and also puts the 'astyle'
+# This script only works on Linux and macOS, and also puts the 'astyle'
 # executable into a very specific place. This is not a general purpose
 # solution. A better solution is to essentially execute the commands
 # below in a shell and make sure that the executable is installed into
 # a central directory -- say, /usr/bin or /usr/local/bin.
 #
 
-PRG=$PWD/programs
+PRG="$(cd "$(dirname "$0")" && pwd)/programs"
+
+# Find out which kind of OS we are running and set the appropriate settings
+case "$OSTYPE" in
+  darwin*)
+    FILENAME="astyle_2.04_macosx.tar.gz"
+    CHECKSUM_CMD="shasum"
+    CHECKSUM="e0ba90723463172fd8a063897092284993eeebb87c63cf26ee36f555b0d89368  $FILENAME"
+    BUILD_PATH="$PRG/astyle/build/mac"
+    ;;
+  linux*)
+    FILENAME="astyle_2.04_linux.tar.gz"
+    CHECKSUM_CMD="sha256sum"
+    CHECKSUM="70b37f4853c418d1e2632612967eebf1bdb93dfbe558c51d7d013c9b4e116b60  $FILENAME"
+    BUILD_PATH="$PRG/astyle/build/gcc"
+    ;;
+  *)
+    echo "unknown: $OSTYPE"
+    exit 1
+    ;;
+esac
+
+INSTALL_PATH="$BUILD_PATH"/../../
 
 if [ ! -d "$PRG" ]
 then
@@ -39,11 +61,12 @@ if [ ! -d "$PRG/astyle" ]
 then
     echo "Downloading and installing astyle."
     mkdir "$PRG/astyle"
-    wget https://downloads.sourceforge.net/project/astyle/astyle/astyle%202.04/astyle_2.04_linux.tar.gz  > /dev/null
-    if echo "70b37f4853c418d1e2632612967eebf1bdb93dfbe558c51d7d013c9b4e116b60 astyle_2.04_linux.tar.gz" | sha256sum -c; then
-      tar xfz astyle_2.04_linux.tar.gz -C "$PRG" > /dev/null
-      cd "$PRG/astyle/build/gcc" || exit 1
+    curl -s -L "https://downloads.sourceforge.net/project/astyle/astyle/astyle%202.04/$FILENAME" -O > /dev/null
+    if echo "$CHECKSUM" | "${CHECKSUM_CMD}" -c; then
+      tar xfz "$FILENAME" -C "$PRG" > /dev/null
+      cd "$BUILD_PATH" || exit 1
       make -j4 > /dev/null
+      cp -r "$BUILD_PATH"/bin "$INSTALL_PATH"
     else
       echo "*** The downloaded file has the wrong SHA256 checksum!"
       exit 1

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.