Commit Diff


commit - e5ad324e23d617bc975b15a18de325c2601ec34e
commit + 1145767803ca86b228d456b855f0c2ea52d5c336
blob - 79c04745ef45c12ae0d38cd89a3af780c66dc674
blob + dd050e145bf3b8fb0af537d764f9f3466ae8b2dd
--- configure.ac
+++ configure.ac
@@ -246,6 +246,7 @@ if test x"$PLATFORM" = "xdarwin"; then
 	HB_PREFIX=""
 	HB_USR_LOCAL=""
 	FOUND_BISON="no"
+	GNUBISON=""
 	if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
 		# HOMEBREW_PREFIX not set, check for brew(1)
 		if command -v brew >/dev/null 2>&1; then
@@ -261,8 +262,13 @@ if test x"$PLATFORM" = "xdarwin"; then
 				HB_USR_LOCAL="/usr/local"
 				AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to /usr/local")
 			else
-				export HOMEBREW_PREFIX="$(eval echo ${prefix})"
-				AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
+				HB_PREFIX="$(eval echo ${prefix})" 
+				if test "$HB_PREFIX" = "NONE"; then
+					HB_PREFIX="/opt/local"
+				else
+					AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
+				fi
+				export HOMEBREW_PREFIX="$HB_PREFIX"
 			fi
 		fi
 	fi
@@ -278,37 +284,39 @@ if test x"$PLATFORM" = "xdarwin"; then
 			     Falling back to checking either /usr/local or \${prefix}"
 		])
 
-		if test -z "$HB_USR_LOCAL"; then
+		if test -n "$HB_USR_LOCAL"; then
 			FOUND_BISON="no"
 			AC_MSG_WARN("Trying ${HB_USR_LOCAL}/opt/bison/bin/bison")
 			if test -x "${HB_USR_LOCAL}/opt/bison/bin/bison"; then
 				export HOMEBREW_PREFIX="/usr/local"
 				FOUND_BISON="yes"
+				GNUBISON="${HB_USR_LOCAL}/opt/bison/bin/bison"
 			fi
 		fi
 
-		if test -z "$HB_PREFIX"; then
+		if test -n "$HB_PREFIX"; then
 			FOUND_BISON="no"
-			AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
-			export HOMEBREW_PREFIX="$(eval echo ${prefix})"
+			AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
 
-			if test -x "${HB_USR_LOCAL}/opt/bison/bin/bison"; then
-				export HOMEBREW_PREFIX="$(eval echo ${prefix})"
+			if test -x "${HB_PREFIX}/bin/bison"; then
+				export HOMEBREW_PREFIX="${HB_PREFIX}"
+				GNUBISON="${HB_PREFIX}/bin/bison"
 				FOUND_BISON="yes"
 			fi
 		fi
 	else
 		FOUND_BISON="yes"
+		GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
 	fi
 
 	if test "$FOUND_BISON" = "no"; then
 		AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
 	fi
 
-	AC_MSG_NOTICE("Found GNU Bison as: ${HOMEBREW_PREFIX}/opt/bison/bin/bison")
+	AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
 
 	# Override YACC here to point to the GNU version of bison.
-	export YACC="${HOMEBREW_PREFIX}/opt/bison/bin/bison -y"
+	export YACC="${GNUBISON} -y"
 	export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
 	export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
 	export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"