diff --git a/macOS/build.sh b/macOS/build.sh
index 752a180c70474671e4dc03186b69a6a81d80a038..b188675dcdda146b3654784b8792f5ac54c9d3d9 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -49,16 +49,18 @@ if [[ -z $VERSION ]]; then
     fi
 fi
 
-# Install location must be truncated for installation of `gcc`
-# If it's too long, the headers of the compiled libraries cannot be modified
-# obliging recompilation on the user's system. Truncate to 5 characters
-# To allow for distribution version to appear
-LOCATION=$(echo "$VERSION" | cut -f1 -d"-" | cut -c 1-5)
-if [[ "$VERSION" == *-unstable* || "$VERSION" == [a-zA-Z]* ]]; then
-    LOCATION="$LOCATION"-"$DATE"
+# Install location must not be too long for gcc.
+# Otherwise, the headers of the compiled libraries cannot be modified
+# obliging recompilation on the user's system.
+# If VERSION is not a official release number, then do some magic
+# to get something not too long, still more or less unique.
+if [[ "$VERSION" =~ ^[0-9\.]+$ ]]; then
+    LOCATION=$VERSION
+else
+    # Get the first component, truncate it to 5 characters, and add the date
+    LOCATION=$(echo "$VERSION" | cut -f1 -d"-" | cut -c 1-5)-"$DATE"
 fi
 
-
 ##
 ## Compile Dynare doc, dynare++, preprocessor, mex for MATLAB < 2018a
 ##