Subject: Re: bug#57015: 29.0.50; macOS: libgccjit was not found: Homebrew libgccjit 12.1.0

From: Naofumi Yasufuku <[email-masked]>
Date: Sun, 07 Aug 2022 03:30:08 +0900

Eli Zaretskii <[email-masked]> writes:
>> From: Naofumi Yasufuku <[email-masked]>
>> Cc: [email-masked]
>> Date: Sun, 07 Aug 2022 01:36:39 +0900
>> 
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -3843,8 +3843,15 @@ AC_DEFUN
>>          if test -n "`$BREW --prefix --installed libgccjit 2>/dev/null`"; then
>>            MAC_CFLAGS="-I$(dirname $($BREW ls -v libgccjit | \
>>                                                  grep libgccjit.h))"
>> -          MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit| \
>> -                                            grep -E 'libgccjit\.(so|dylib)$'))"
>> +          MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit | \
>> +                                  grep -E 'current/libgccjit\.(so|dylib)$' | \
>> +                                  head -1))"
>> +          if test "x${MAC_LIBS}" = "x-L"; then
>> +            # Try for Homebrew libgccjit < 12.1.0.
>> +            MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit | \
>> +                                    grep -E 'libgccjit\.(so|dylib)$' | \
>> +                                    head -1))"
>> +          fi
>>          fi
>>        fi
>>  
>
> Is 'dirname' guaranteed to be available?

I suppose so, but at least Homebrew's 'brew' shell script also
uses 'dirname':

--8<---------------cut here---------------start------------->8---
sh-3.2$ type dirname
dirname is /usr/bin/dirname
sh-3.2$
sh-3.2$ type brew
brew is /usr/local/bin/brew
sh-3.2$
sh-3.2$ ls -l /usr/local/bin/brew
lrwxr-xr-x  1 naofumi  admin  28 Jan 20  2017 /usr/local/bin/brew -> /usr/local/Homebrew/bin/brew
sh-3.2$
sh-3.2$ file /usr/local/Homebrew/bin/brew
/usr/local/Homebrew/bin/brew: Bourne-Again shell script text executable, ASCII text
sh-3.2$
sh-3.2$ grep -n dirname /usr/local/Homebrew/bin/brew
26:  local target target_dirname
28:  target_dirname="$(dirname "${target}")"
30:  quiet_cd "${directory}" && quiet_cd "${target_dirname}" && pwd -P
sh-3.2$
sh-3.2$ less /usr/local/Homebrew/bin/brew
..
symlink_target_directory() {
  local target target_dirname
  target="$(readlink "$1")"
  target_dirname="$(dirname "${target}")"
  local directory="$2"
  quiet_cd "${directory}" && quiet_cd "${target_dirname}" && pwd -P
}
..
--8<---------------cut here---------------end--------------->8---

https://github.com/Homebrew/brew/blob/3.5.8/bin/brew#L25

Regards,
  Naofumi