homebrew-tap icon indicating copy to clipboard operation
homebrew-tap copied to clipboard

'makedepend: command not found' when installing on M1

Open jlugner opened this issue 1 year ago • 5 comments

I'm unable to run brew install rbenv/tap/[email protected] on my M1, with or without makedepend linked to homebrew. Getting the following output:

➜  ruby_project git:(master) ✗ brew install rbenv/tap/[email protected]
Running `brew update --auto-update`... ==> Auto-updated Homebrew!
Updated 3 taps (homebrew/cask-versions, homebrew/services and homebrew/core). ==> New Formulae
opensca-cli

You have 4 outdated formulae installed. ==> Fetching rbenv/tap/[email protected] ==> Downloading https://www.openssl.org/source/openssl-1.0.2u.tar.gz
Already downloaded: /Users/me/Library/Caches/Homebrew/downloads/cb69ca61319d7186eb55397eb90cec0c2f56d8722af71a851bb35194ecaf3359--openssl-1.0.2u.tar.gz ==> Installing [email protected] from rbenv/tap ==> Patching
==> perl ./Configure --prefix=/opt/homebrew/Cellar/[email protected]/1.0.2u --openssldir=/opt/homebrew/etc/openssl no-ssl2 no-ss ==> make depend
Last 15 lines from /Users/me/Library/Logs/Homebrew/[email protected]/02.make:
2023-12-16 08:00:28 +0000

make
depend

making depend in crypto...
../util/domd: line 23: makedepend: command not found
mv: Makefile.new: No such file or directory
make[1]: *** [local_depend] Error 127
make: *** [depend] Error 1

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/rbenv/homebrew-tap/issues

jlugner avatar Dec 17 '23 19:12 jlugner

I found evidence of other people having this exact issue in the past; I'm not sure if it was ever solved for them: https://github.com/rbenv/homebrew-tap/issues/4#issuecomment-1090850799

Apparently gcc -M should be equivalent of makedepend on systems that have none. Not sure why make depend would fail on systems with gcc.

mislav avatar Dec 21 '23 09:12 mislav

I saw that, but didn't find anyone mentioning solving it. I somewhat assumed the fix you mentioned in the bottom of the thread had worked for them.

I saw gcc -M mentioned a couple of times, but not sure if it's something I can make use of to proceed here?

jlugner avatar Dec 21 '23 12:12 jlugner

You could try brew install with --keep-tmp and then, after failure, open the temporary directory and look at the Makefile generated by the Configure step. Here's mine: https://gist.github.com/mislav/fd2a8d9deb404399acabe055b26719bc

$ grep MAKEDEP /private/tmp/opensslA1.0-20231222-15977-tyt2qu/openssl-1.0.2u/Makefile
MAKEDEPPROG= clang
		MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
		MAKEDEPPROG='$(MAKEDEPPROG)'

mislav avatar Dec 22 '23 15:12 mislav

You could try brew install with --keep-tmp and then, after failure, open the temporary directory and look at the Makefile generated by the Configure step. Here's mine: https://gist.github.com/mislav/fd2a8d9deb404399acabe055b26719bc

$ grep MAKEDEP /private/tmp/opensslA1.0-20231222-15977-tyt2qu/openssl-1.0.2u/Makefile
MAKEDEPPROG= clang
		MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
		MAKEDEPPROG='$(MAKEDEPPROG)'

That's interesting. The grep result for me is the same:

 ✗ grep MAKEDEP /private/tmp/opensslA1.0-20231222-49466-66c9fh/openssl-1.0.2u/Makefile
MAKEDEPPROG=makedepend
		MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
		MAKEDEPPROG='$(MAKEDEPPROG)'

My makefile differs however. Where you have MAKEDEPPROG= clang, I have MAKEDEPPROG=makedepend.

I don't really know how homebrew works with stuff like this. Can I alter the makefile and reinitiate the install using the stored temp output, or can I inject what MAKEDEPPROG I want to use when installing?

jlugner avatar Dec 22 '23 22:12 jlugner

My makefile differs however. Where you have MAKEDEPPROG= clang, I have MAKEDEPPROG=makedepend.

I strongly suspect this is what causes the failure on your system and what makes it work on mine. I do not know why the Perl Configure script generates it that way, though. Here is the relevant logic from the script:

# collect compiler pre-defines from gcc or gcc-alike...
open(PIPE, "$cross_compile_prefix$cc -dM -E -x c /dev/null 2>&1 |");
while (<PIPE>) {
  m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last;
  $predefined{$1} = defined($2) ? $2 : "";
}
close(PIPE);

# Xcode did not handle $cc -M before clang support
my $cc_as_makedepend = 0;
if ($predefined{__GNUC__} >= 3 && !(defined($predefined{__APPLE_CC__})
                                    && !defined($predefined{__clang__}))) {
  $cc_as_makedepend = 1;
}

I think that either clang behaves differently on your system, or that you have the CC environment variable set to something else.

$ clang -dM -E -x c /dev/null 2>&1 | grep -E '__(GNUC|APPLE_CC|clang)__'
#define __APPLE_CC__ 6000
#define __GNUC__ 4
#define __clang__ 1

Note that we're trying to debug a build script issue in a version of OpenSSL that is no longer maintained. It's quite possible that this issue was known and fixed in future versions of OpenSSL. If you do manage to find the cause of the bug, I'm open to patching it in this repo.

mislav avatar Dec 26 '23 19:12 mislav