From dd810cadd304c39b2d85e53e7e689ccf71b97cd9 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 13 Feb 2008 11:04:52 +0000 Subject: [PATCH] Another fix to stop infinite loops when detecting javac. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@559 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/Makefile | 22 +--------------------- prism/src/scripts/findjavac.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100755 prism/src/scripts/findjavac.sh diff --git a/prism/Makefile b/prism/Makefile index 201311e2..6085e5f5 100644 --- a/prism/Makefile +++ b/prism/Makefile @@ -77,28 +77,8 @@ endif # either set the variable yourself by uncommenting and/or modifying one of the lines below # or pass a value to make directly, e.g.: make JAVA_DIR=/usr/java -# The detection of javac below can handle cases: -# - where javac is a symbolic link -# - where there is actually a chain of symbolic links -# - where there are relative symbolic links -# - where there are directory names including spaces -# Note: The code would be simpler if we could rely on -# the existence of "readlink -f" but we can't. - # Find javac -DETECT_JAVAC = $(shell \ - (DETECT_JAVAC=`which javac`; \ - if [ -f "$$DETECT_JAVAC" ]; then \ - DETECT_JAVAC_DIR=`dirname "$$DETECT_JAVAC"`; \ - cd "$$DETECT_JAVAC_DIR"; \ - while [ -h ./javac ]; do \ - DETECT_JAVAC=`readlink ./javac`; \ - DETECT_JAVAC_DIR=`dirname "$$DETECT_JAVAC"`; \ - cd "$$DETECT_JAVAC_DIR"; \ - DETECT_JAVAC_DIR=`pwd`; \ - done; \ - echo $$DETECT_JAVAC_DIR/javac; \ - fi) 2> /dev/null) +DETECT_JAVAC = $(shell src/findjavac.sh 2> /dev/null) # Find directory containing javac ifeq ("$(DETECT_JAVAC)","") diff --git a/prism/src/scripts/findjavac.sh b/prism/src/scripts/findjavac.sh new file mode 100755 index 00000000..5e4ae22a --- /dev/null +++ b/prism/src/scripts/findjavac.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# The detection of javac below can handle cases: +# - where javac is a symbolic link +# - where there is actually a chain of symbolic links +# - where there are relative symbolic links +# - where some links/files are not called javac (e.g. ecj) +# - where there are directory names including spaces +# Note: The code would be simpler if we could rely on +# the existence of "readlink -f" but we can't. + +DETECT_JAVAC=`which javac` +if [ -f "$DETECT_JAVAC" ]; then + DETECT_JAVAC_DIR=`dirname "$DETECT_JAVAC"` + DETECT_JAVAC_EXE=`basename "$DETECT_JAVAC"` + cd "$DETECT_JAVAC_DIR" + while [ -h ./"$DETECT_JAVAC_EXE" ]; do + DETECT_JAVAC=`readlink ./javac` + DETECT_JAVAC_DIR=`dirname "$DETECT_JAVAC"` + DETECT_JAVAC_EXE=`basename "$DETECT_JAVAC"` + cd "$DETECT_JAVAC_DIR" + DETECT_JAVAC_DIR=`pwd` + #pwd + done + echo "$DETECT_JAVAC_DIR"/"$DETECT_JAVAC_EXE" +fi