Subject: Re: bug#36332: non-GUI build broken on macOS

From: Alan Third <[email-masked]>
Date: Sat, 22 Jun 2019 21:19:43 +0100

On Sat, Jun 22, 2019 at 12:44:40PM -0700, Paul Eggert wrote:
> Alan Third wrote:
> > It is. What doesn’t work is defining HAVE_NS but not setting the
> > requirements for an NS build.
> > 
> > './configure --without-ns' works fine as is.
> 
> OK, thanks, in that case I guess that the problem is only that after one
> does 'make extraclean' then one cannot build with the current master without
> manually specifying './configure --without-ns' at some point. This makes the
> bug less urgent to fix.

I haven’t been following the clean build chat on emacs-devel, does
make extraclean delete macuvs.h?

We could try returning a useful message at configure time instead of
just failing during the build. Do you think the attached patch is OK?

I’d rather not just build headless as the usual build process on the
Mac is to do ’make; make install’, which just builds the NS app
directory. If we were to configure headless then run that same command
it would attempt to install a headless Emacs to /usr or somewhere. It
would probably fail due to permissions, but I’d prefer to avoid any
confusion in the first place.
-- 
Alan Third
>From 8ece63cd67d158b0349dda83c303e1f02a947f40 Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Sat, 22 Jun 2019 21:13:50 +0100
Subject: [PATCH] Provide a useful message if macuvs.h doesn't exist
 (bug#36332)

* configure.ac (with-ns): Error out if attempting to configure with
Cocoa but macuvs.h doesn't exist.
---
 configure.ac | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 0507f58054..d7efe467fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1963,7 +1963,12 @@ AC_DEFUN
   # macfont.o requires macuvs.h which is absent after 'make extraclean',
   # so avoid NS_IMPL_COCOA if macuvs.h is absent.
   # Even a headless Emacs can build macuvs.h, so this should let you bootstrap.
-  if test "${opsys}" = darwin && test -f "$srcdir/src/macuvs.h"; then
+  if test "${opsys}" = darwin; then
+     if test \! -f "$srcdir/src/macuvs.h"; then
+       AC_MSG_ERROR([Cocoa build requested, however macuvs.h is missing.
+Rerun configure with the option '--without-ns' and run make before
+configuring '--with-ns'.])
+     fi
      NS_IMPL_COCOA=yes
      ns_appdir=`pwd`/nextstep/Emacs.app
      ns_appbindir=${ns_appdir}/Contents/MacOS
-- 
2.21.0