pkg/60023: editors/emacs30: Fix broken Darwin build

"[email protected] via gnats" <[email protected]>
Newsgroups gmane.os.netbsd.devel.pkgsrc.bugs
Message-ID <[email protected]>
>Number:         60023
>Category:       pkg
>Synopsis:       editors/emacs30: Fix broken Darwin build
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 21 01:30:00 +0000 2026
>Originator:     Brian Callahan
>Release:        HEAD
>Organization:
>Environment:
Darwin Brians-MBP-2 22.6.0 Darwin Kernel Version 22.6.0: Tue Jul 15 08:22:28 PDT 2025; root:xnu-8796.141.3.713.2~2/RELEASE_X86_64 x86_64
>Description:
When building emacs-30.2 on macOS with devel/libgetopt buildlink enabled in Makefile.common, the build fails. You get these errors:

--
getopt1.c:28:50: error: expected ')'
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
                                                 ^
getopt1.c:28:13: note: to match this '('
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
            ^
getopt1.c:28:1: error: conflicting types for 'getopt_long'
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
^
/Users/briancallahan/pkgsrc/editors/emacs30/work/.buildlink/include/getopt.h:62:5: note: previous declaration is here
int getopt_long(int, char * const *, const char *,
    ^
getopt1.c:31:44: error: use of undeclared identifier 'argv'
  return _getopt_internal (argc, (char **) argv, options, long_options,
                                           ^
getopt1.c:31:50: error: use of undeclared identifier 'options'; did you mean 'optind'?
  return _getopt_internal (argc, (char **) argv, options, long_options,
                                                 ^~~~~~~
                                                 optind
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:512:12: note: 'optind' declared here
extern int optind, opterr, optopt;
           ^
getopt1.c:31:59: error: use of undeclared identifier 'long_options'
  return _getopt_internal (argc, (char **) argv, options, long_options,
                                                          ^
getopt1.c:32:7: error: use of undeclared identifier 'opt_index'; did you mean 'optind'?
                           opt_index, 0, 0);
                           ^~~~~~~~~
                           optind
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:512:12: note: 'optind' declared here
extern int optind, opterr, optopt;
           ^
getopt1.c:50:55: error: expected ')'
getopt_long_only (int argc, char *__getopt_argv_const *argv,
                                                      ^
getopt1.c:50:18: note: to match this '('
getopt_long_only (int argc, char *__getopt_argv_const *argv,
                 ^
getopt1.c:54:44: error: use of undeclared identifier 'argv'
  return _getopt_internal (argc, (char **) argv, options, long_options,
                                           ^
getopt1.c:54:50: error: use of undeclared identifier 'options'; did you mean 'optind'?
  return _getopt_internal (argc, (char **) argv, options, long_options,
                                                 ^~~~~~~
                                                 optind
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:512:12: note: 'optind' declared here
extern int optind, opterr, optopt;
           ^
getopt1.c:54:59: error: use of undeclared identifier 'long_options'
  return _getopt_internal (argc, (char **) argv, options, long_options,
                                                          ^
getopt1.c:55:7: error: use of undeclared identifier 'opt_index'; did you mean 'optind'?
                           opt_index, 1, 0);
                           ^~~~~~~~~
                           optind
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:512:12: note: 'optind' declared here
extern int optind, opterr, optopt;
           ^
11 errors generated.
gmake[2]: *** [Makefile:103: getopt1.o] Error 1
--

Removing the buildlink hookup allows emacs-30.2 to build and run correctly on macOS.
>How-To-Repeat:
Try to build emacs-30.2 on macOS.
>Fix:
diff --git a/editors/emacs30/Makefile.common b/editors/emacs30/Makefile.common
index 7ab3c3c12b19..31c707fed449 100644
--- a/editors/emacs30/Makefile.common
+++ b/editors/emacs30/Makefile.common
@@ -86,4 +86,6 @@ post-install:
 	cd ${DESTDIR}${PREFIX}/libexec/emacs/${PKGVERSION_NOREV}/${MACHINE_GNU_PLATFORM} && \
 		mv emacs-*.pdmp emacs.pdmp
 
+.if ${OPSYS} != "Darwin"
 .include "../../devel/libgetopt/buildlink3.mk"
+.endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.