Subject: Re: bug#66111: is there a problem with --prefix?

From: Eli Zaretskii <[email-masked]>
Date: Wed, 20 Sep 2023 15:30:52 +0300

> From: Ambrose Kofi Laing <[email-masked]>
> Date: Tue, 19 Sep 2023 13:59:26 -0400
> 
> I'm trying to install emacs_29.1 at a nonstandard location, with the following commands:
> 
>  cd src/emacs-29.1
>  ./autogen.sh
>  ./configure --prefix=/home/myname/my/custom/emacs29 --with-native-compilation=aot -
>  -with-imagemagick --with-json --with-tree-sitter --with-xft --without-compress-install
>  make -j 4
> 
> and I get an error message because of permission denied while trying to write under /usr/local (that is
> where the script stops).  In addition, there are two locations where it says the following:
> 
> make -C src BIN_DESTDIR=''/usr/local/bin/'' \
> ELN_DESTDIR='/usr/local/lib/emacs/29.1/' all

I don't see how this could have happened.  BIN_DESTDIR and ELN_DESTDIR
are set in the top-level Makefile.ion like this:

  ifeq (${ns_self_contained},no)
  BIN_DESTDIR='$(DESTDIR)${bindir}/'
  ELN_DESTDIR = $(DESTDIR)${libdir}/emacs/${version}/
  else
  BIN_DESTDIR='${ns_appbindir}/'
  ELN_DESTDIR = ${ns_applibdir}/
  endif

Are you building the NS build on macOS?  If not, the upper part of the
conditional above should be true for you, and the values should have
obeyed the --prefix value you used at configure time.

However, I don't understand why you ran autogen.sh.  Are you building
from the Emacs 29.1 release tarball?  If so, the configure script is
already produced and provided in the tarball, you just need to run it.
Could you please unpack the Emacs 29.1 tarball in a fresh directory,
run the configure script without running autogen.sh, and then say
"make" and "make install", and see if the problem still happens.

> This happens twice (please see below the ps under my signature for the full transcript of "make
> install" to see the exact context in which it happens).  It seems to be that the --prefix does not override
> certain locations that it is supposed to?

It should, and I see the code to do that in Makefile.in, so I wonder
why it didn't happen for you.

> Are there other variables I need to set (other than the --prefix option to configure) that will ensure that
> the compilation and installation will not try to write under /usr/local ?

Please show the part of top-level Makefile where bindir and other
variables are set.