Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151625760
D56001.id174597.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
27 KB
Referenced Files
None
Subscribers
None
D56001.id174597.diff
View Options
diff --git a/Mk/Uses/emacs.mk b/Mk/Uses/emacs.mk
--- a/Mk/Uses/emacs.mk
+++ b/Mk/Uses/emacs.mk
@@ -1,49 +1,28 @@
-# Provide support for ports requiring Emacs. This includes flavors with proper
-# dependencies and useful variables.
+# Provide support for ports requiring Emacs.
#
# Feature: emacs
# Usage: USES=emacs or USES=emacs:args
-# Valid ARGS: build, run, noflavors
+# Valid ARGS: build
#
# build Indicates that Emacs is required at build time.
-# run Indicates that Emacs is required at run time.
-# noflavors Prevents flavors. This is implied when there is no run
-# dependency on Emacs.
#
-# If build and run are omitted from the argument list, Emacs will be added to
-# BUILD_DEPENDS and RUN_DEPENDS. EMACS_NO_DEPENDS can be set to prevent both
-# dependencies.
-#
-# Variables, which can be set in make.conf:
-# DEFAULT_VERSIONS+= The default flavor for ports with
-# USES=emacs can be added to DEFAULT_VERSIONS.
-# For example: DEFAULT_VERSIONS+= emacs=nox
-# Valid flavors: full canna nox wayland
-# devel_full devel_nox
-# Flavors specified on the command line take
-# precedence.
-#
-# Variables, which can be set by ports:
-# EMACS_FLAVORS_EXCLUDE: Do NOT build these Emacs flavors.
-# If EMACS_FLAVORS_EXCLUDE is not defined and
-# - there is a run dependency on Emacs
-# - the noflavors argument is not specified
-# then all valid Emacs flavors are assumed.
-#
-# EMACS_NO_DEPENDS: Do NOT add build or run dependencies on Emacs.
-# This will prevent flavors, and no byte code files
-# will be generated as part of the package.
+# If build is omitted from the argument list, Emacs will not be added to
+# BUILD_DEPENDS.
#
# Variables, which can be read by ports:
# EMACS_CMD: Emacs command with full path (e.g. /usr/local/bin/emacs-30.2)
-# EMACS_FLAVOR: Used for dependencies (e.g. BUILD_DEPENDS= dash.el${EMACS_PKGNAMESUFFIX}>0:devel/dash@${EMACS_FLAVOR})
-# EMACS_LIBDIR: Emacs Library directory without ${PREFIX} (e.g. share/emacs)
-# EMACS_LIBDIR_WITH_VER: Library directory without ${PREFIX} including version (e.g. share/emacs/30.2)
+# EMACS_VER: Emacs version (e.g. 30.2)
# EMACS_MAJOR_VER: Emacs major version (e.g. 30)
-# EMACS_PKGNAMESUFFIX: PKGNAMESUFFIX to distinguish Emacs flavors
+# EMACS_LIBDIR: Emacs Library directory without ${PREFIX} (e.g. share/emacs)
# EMACS_SITE_LISPDIR: Emacs site-lisp directory without ${PREFIX} (e.g. share/emacs/site-lisp)
-# EMACS_VER: Emacs version (e.g. 30.2)
-# EMACS_VERSION_SITE_LISPDIR: Include version (e.g. share/emacs/30.2/site-lisp)
+#
+# Note: EMACS_CMD, EMACS_MAJOR_VER, and EMACS_VER are only set if the build
+# argument is supplied.
+#
+# Note: No Emacs runtime dependency is declared here. USES=emacs ports now
+# install only .el source files, avoiding the combinatorial explosion of
+# flavor-specific packages. Native compilation is handled at runtime by the
+# site-wide configuration shipped with editors/emacs and editors/emacs-devel.
#-------------------------------------------------------------------------------
#
# MAINTAINER: emacs@FreeBSD.org
@@ -54,102 +33,29 @@
# Make sure that no dependency or some other environment variable
# pollutes the build/run dependency detection
.undef _EMACS_BUILD_DEP
-.undef _EMACS_RUN_DEP
-.undef _EMACS_NOFLAVORS
_EMACS_ARGS= ${emacs_ARGS:S/,/ /g}
. if ${_EMACS_ARGS:Mbuild}
_EMACS_BUILD_DEP= yes
_EMACS_ARGS:= ${_EMACS_ARGS:Nbuild}
. endif
-. if ${_EMACS_ARGS:Mrun}
-_EMACS_RUN_DEP= yes
-_EMACS_ARGS:= ${_EMACS_ARGS:Nrun}
-. endif
-. if ${_EMACS_ARGS:Mnoflavors}
-_EMACS_NOFLAVORS= yes
-_EMACS_ARGS:= ${_EMACS_ARGS:Nnoflavors}
-. endif
-# If the port does not specify a build or run dependency, and does not define
-# EMACS_NO_DEPENDS, assume both dependencies are required.
-. if !defined(_EMACS_BUILD_DEP) && !defined(_EMACS_RUN_DEP) && \
- !defined(EMACS_NO_DEPENDS)
-_EMACS_BUILD_DEP= yes
-_EMACS_RUN_DEP= yes
-. endif
-
-# Only set FLAVORS when...
-. if defined(_EMACS_RUN_DEP) && !defined(_EMACS_NOFLAVORS)
-FLAVORS= full canna nox wayland devel_full devel_nox
-# Sort the default to be first
-. if defined(EMACS_DEFAULT)
-FLAVORS:= ${EMACS_DEFAULT} ${FLAVORS:N${EMACS_DEFAULT}}
-. endif
-. for flavor in ${EMACS_FLAVORS_EXCLUDE}
-FLAVORS:= ${FLAVORS:N${flavor}}
-. endfor
-. endif
-
-# Only set FLAVOR when...
-. if defined(_EMACS_RUN_DEP) && !defined(_EMACS_NOFLAVORS) && empty(FLAVOR)
-. if defined(EMACS_DEFAULT)
-FLAVOR= ${EMACS_DEFAULT}
-. else
-FLAVOR= ${FLAVORS:[1]}
-. endif # defined(EMACS_DEFAULT)
-. endif # !defined(_EMACS_NOFLAVORS) && defined(_EMACS_RUN_DEP) && empty(FLAVOR)
-
-. if !empty(FLAVOR)
-EMACS_FLAVOR= ${FLAVOR}
-. else
-EMACS_FLAVOR= full
-. endif
-
-. if ${FLAVOR:Mdevel*}
-EMACS_VER= 31.0.50
-EMACS_PORTDIR= editors/emacs-devel
-. else
-EMACS_VER= 30.2
-EMACS_PORTDIR= editors/emacs
-. endif
-
-EMACS_MAJOR_VER= ${EMACS_VER:C/\..*//}
EMACS_LIBDIR= share/emacs
-EMACS_LIBDIR_WITH_VER= share/emacs/${EMACS_VER}
-EMACS_PORT_NAME= emacs${EMACS_MAJOR_VER}
-
-. if ${EMACS_FLAVOR} == "devel_full"
-EMACS_PKGNAMESUFFIX= -emacs_devel
-. elif ${EMACS_FLAVOR} == "devel_nox"
-EMACS_PKGNAMESUFFIX= -emacs_devel_nox
-. elif ${EMACS_FLAVOR} == "full"
-EMACS_PKGNAMESUFFIX=
-. else
-EMACS_PKGNAMESUFFIX= -emacs_${EMACS_FLAVOR}
-. endif
-
-EMACS_CMD= ${PREFIX}/bin/emacs-${EMACS_VER}
EMACS_SITE_LISPDIR= ${EMACS_LIBDIR}/site-lisp
-EMACS_VERSION_SITE_LISPDIR= ${EMACS_LIBDIR_WITH_VER}/site-lisp
. if defined(_EMACS_BUILD_DEP)
-BUILD_DEPENDS+= ${EMACS_CMD}:${EMACS_PORTDIR}@${EMACS_FLAVOR:C/devel_//}
-. endif
-. if defined(_EMACS_RUN_DEP)
-RUN_DEPENDS+= ${EMACS_CMD}:${EMACS_PORTDIR}@${EMACS_FLAVOR:C/devel_//}
+EMACS_CMD= ${PREFIX}/bin/emacs-${EMACS_VER}
+EMACS_MAJOR_VER= ${EMACS_VER:C/\..*//}
+EMACS_VER= 30.2
+MAKE_ARGS+= EMACS=${EMACS_CMD}
+BUILD_DEPENDS+= ${EMACS_CMD}:editors/emacs
. endif
-MAKE_ARGS+= EMACS=${EMACS_CMD}
SCRIPTS_ENV+= EMACS_LIBDIR=${EMACS_LIBDIR} \
EMACS_VER=${EMACS_VER} \
- EMACS_LIBDIR_WITH_VER=${EMACS_LIBDIR_WITH_VER} \
- EMACS_SITE_LISPDIR=${EMACS_SITE_LISPDIR} \
- EMACS_VERSION_SITE_LISPDIR=${EMACS_VERSION_SITE_LISPDIR}
+ EMACS_SITE_LISPDIR=${EMACS_SITE_LISPDIR}
PLIST_SUB+= EMACS_LIBDIR=${EMACS_LIBDIR} \
EMACS_VER=${EMACS_VER} \
- EMACS_LIBDIR_WITH_VER=${EMACS_LIBDIR_WITH_VER} \
- EMACS_SITE_LISPDIR=${EMACS_SITE_LISPDIR} \
- EMACS_VERSION_SITE_LISPDIR=${EMACS_VERSION_SITE_LISPDIR}
+ EMACS_SITE_LISPDIR=${EMACS_SITE_LISPDIR}
.endif # _INCLUDE_USES_EMACS_MK
diff --git a/editors/emacs-devel/Makefile b/editors/emacs-devel/Makefile
--- a/editors/emacs-devel/Makefile
+++ b/editors/emacs-devel/Makefile
@@ -1,5 +1,6 @@
PORTNAME= emacs
DISTVERSION= 31.0.50.20260316
+PORTREVISION= 1
PORTEPOCH= 3
CATEGORIES= editors
PKGNAMESUFFIX= -devel
@@ -63,7 +64,7 @@
CONFLICTS_INSTALL= emacs emacs-canna emacs-nox
-SUB_FILES= pkg-message sources.el
+SUB_FILES= default.el pkg-message site-start.el
SUB_LIST= EMACS_VER=${DISTVERSION:R} \
NATIVECOMP_COMMENT_END=${NATIVECOMP_COMMENT_END} \
NATIVECOMP_COMMENT_START=${NATIVECOMP_COMMENT_START}
@@ -88,9 +89,6 @@
HARFBUZZ JPEG KQUEUE LCMS2 MAILUTILS MODULES \
NATIVECOMP OSS PGTK PNG SCROLLBARS SOURCES \
SQLITE3 SVG THREADS TIFF TREESITTER WEBP XML
-OPTIONS_EXCLUDE_powerpc= NATIVECOMP
-OPTIONS_EXCLUDE_powerpc64= NATIVECOMP
-OPTIONS_EXCLUDE_powerpc64le= NATIVECOMP
OPTIONS_GROUP= GRAPHICS
OPTIONS_GROUP_GRAPHICS= CAIRO GIF JPEG MAGICK PNG SVG TIFF WEBP XPM
OPTIONS_RADIO= FILENOTIFY SOUND X11TOOLKIT
@@ -104,6 +102,9 @@
XIM XPM XWIDGETS
.endif
OPTIONS_EXCLUDE_armv7= NATIVECOMP
+OPTIONS_EXCLUDE_powerpc= NATIVECOMP
+OPTIONS_EXCLUDE_powerpc64= NATIVECOMP
+OPTIONS_EXCLUDE_powerpc64le= NATIVECOMP
OPTIONS_SUB= YES
ACL_DESC= Access control list support
@@ -273,6 +274,7 @@
post-install:
@${RM} -r ${STAGEDIR}${PREFIX}/lib/systemd
@(cd ${STAGEDIR}${PREFIX} && ${FIND} libexec/emacs/${DISTVERSION:R}/${CONFIGURE_TARGET}/ -name emacs-*.pdmp >> ${TMPPLIST})
+ ${INSTALL_DATA} ${WRKDIR}/default.el ${WRKDIR}/site-start.el ${STAGEDIR}${DATADIR}/site-lisp/
post-install-MAILUTILS-on:
${LN} -sf ${PREFIX}/bin/movemail \
@@ -287,6 +289,5 @@
post-install-SOURCES-on:
@${MKDIR} ${STAGEDIR}${DATADIR}/${DISTVERSION:R}/src
${INSTALL_DATA} ${WRKSRC}/src/*.[ch] ${STAGEDIR}${DATADIR}/${DISTVERSION:R}/src
- ${INSTALL_DATA} ${WRKDIR}/sources.el ${STAGEDIR}${DATADIR}/${DISTVERSION:R}/site-lisp/site-start.el
.include <bsd.port.mk>
diff --git a/editors/emacs-devel/files/default.el.in b/editors/emacs-devel/files/default.el.in
new file mode 100644
--- /dev/null
+++ b/editors/emacs-devel/files/default.el.in
@@ -0,0 +1,133 @@
+;;; default.el --- Site-wide Initialization -*- lexical-binding: t -*-
+
+;; Installed by editors/emacs and editors/emacs-devel.
+;;
+;; This file is interpreted after user configuration.
+;;
+;; FreeBSD elisp (USES=emacs) ports only install .el source files under
+;; %%PREFIX%%/share/emacs/site-lisp/. This file arranges for those files to be
+;; compiled and cached per-user, following the same pattern used by ELPA. No
+;; root privileges are required after package installation.
+;;
+;; For Emacs builds with native compilation: .eln files are cached in
+;; ~/.emacs.d/eln-cache/ by Emacs's existing machinery.
+;;
+;; For Emacs builds without native compilation: .elc files are cached in
+;; ~/.emacs.d/freebsd-elc-cache/, with the cache directory prepended to
+;; load-path so compiled files take precedence over .el source.
+;;
+;; To disable native compilation of ports elisp, add the following to your Emacs
+;; configuration:
+;;
+;; (setq freebsd-inhibit-native-compile t)
+;;
+;; To disable byte-compilation of ports elisp (non-native-compilation builds
+;; only):
+;;
+;; (setq freebsd-inhibit-byte-compile t)
+
+;;; Code:
+
+(defun freebsd--elc-cache-dest (el-file)
+ "Map EL-FILE under `freebsd-site-lisp-dir' to its cache path.
+The subdirectory structure of `freebsd-site-lisp-dir' is mirrored
+under `freebsd-elc-cache-dir' to avoid filename collisions across
+ports and to allow per-subdirectory load-path entries."
+ (let* ((relative (file-relative-name el-file freebsd-site-lisp-dir))
+ (dest-el (expand-file-name relative freebsd-elc-cache-dir)))
+ (concat (file-name-sans-extension dest-el) ".elc")))
+
+(defun freebsd--elc-cache-valid-p ()
+ "Return non-nil if the elc cache was built by the current Emacs version.
+Reads a version stamp file from `freebsd-elc-cache-dir' and compares
+it to `emacs-version'. If missing or mismatched, the cache is
+considered stale and is cleared."
+ (let ((stamp (expand-file-name "emacs-version" freebsd-elc-cache-dir)))
+ (if (file-exists-p stamp)
+ (string= (with-temp-buffer
+ (insert-file-contents stamp)
+ (buffer-string))
+ emacs-version)
+ nil)))
+
+(defun freebsd--elc-cache-clear ()
+ "Remove all .elc files from `freebsd-elc-cache-dir'."
+ (when (file-directory-p freebsd-elc-cache-dir)
+ (dolist (elc (directory-files-recursively
+ freebsd-elc-cache-dir "\\.elc$"))
+ (delete-file elc))))
+
+(defun freebsd--elc-cache-write-stamp ()
+ "Write the current Emacs version to the cache stamp file."
+ (let ((stamp (expand-file-name "emacs-version" freebsd-elc-cache-dir)))
+ (with-temp-file stamp
+ (insert emacs-version))))
+
+(defun freebsd--setup-byte-compile-cache ()
+ "Set up the byte-compilation cache and prepend it to `load-path'.
+Creates `freebsd-elc-cache-dir' mirroring the subdirectory structure
+of `freebsd-site-lisp-dir', then prepends the cache root and all
+subdirectories to `load-path' so cached .elc files take precedence
+over .el source files."
+ (make-directory freebsd-elc-cache-dir t)
+ (when (file-directory-p freebsd-site-lisp-dir)
+ (dolist (dir (directory-files freebsd-site-lisp-dir t "^[^.]"))
+ (when (file-directory-p dir)
+ (make-directory
+ (expand-file-name
+ (file-relative-name dir freebsd-site-lisp-dir)
+ freebsd-elc-cache-dir)
+ t))))
+ (add-to-list 'load-path freebsd-elc-cache-dir)
+ (let ((default-directory freebsd-elc-cache-dir))
+ (normal-top-level-add-subdirs-to-load-path)))
+
+(defun freebsd--byte-compile-site-lisp ()
+ "Byte-compile FreeBSD ports elisp into `freebsd-elc-cache-dir'.
+Runs once on an idle timer to avoid blocking Emacs startup. First
+removes any stale .elc files whose corresponding .el source no longer
+exists in `freebsd-site-lisp-dir', then recompiles any .el files that
+are newer than their cached .elc, following the same pattern used
+by ELPA."
+ (run-with-idle-timer
+ 3 nil
+ (lambda ()
+ (unless (freebsd--elc-cache-valid-p)
+ (freebsd--elc-cache-clear))
+ (freebsd--elc-cache-write-stamp)
+ (when (file-directory-p freebsd-elc-cache-dir)
+ (dolist (elc (directory-files-recursively
+ freebsd-elc-cache-dir "\\.elc$"))
+ (let* ((relative (file-relative-name elc freebsd-elc-cache-dir))
+ (el (expand-file-name
+ (concat (file-name-sans-extension relative) ".el")
+ freebsd-site-lisp-dir)))
+ (unless (file-exists-p el)
+ (delete-file elc)))))
+ (let ((byte-compile-dest-file-function
+ #'freebsd--elc-cache-dest))
+ (dolist (el (directory-files-recursively
+ freebsd-site-lisp-dir "\\.el$"))
+ (let ((base (file-name-nondirectory el)))
+ (unless (member base '("site-start.el" "subdirs.el"))
+ (let ((elc (freebsd--elc-cache-dest el)))
+ (when (or (not (file-exists-p elc))
+ (file-newer-than-file-p el elc))
+ (let ((byte-compile-log-level 0)
+ (byte-compile-dest-file-function
+ #'freebsd--elc-cache-dest))
+ (byte-compile-file el)))))))))))
+
+;;; Entry point
+
+;; When running in batch mode (e.g. during port builds), skip all
+;; compilation machinery to avoid interference with the build environment.
+(unless noninteractive
+ (if (native-comp-available-p)
+ (unless freebsd-inhibit-native-compile
+ (native-compile-async freebsd-site-lisp-dir 'recursively))
+ (unless freebsd-inhibit-byte-compile
+ (freebsd--setup-byte-compile-cache)
+ (freebsd--byte-compile-site-lisp))))
+
+;;; default.el ends here
diff --git a/editors/emacs-devel/files/site-start.el.in b/editors/emacs-devel/files/site-start.el.in
new file mode 100644
--- /dev/null
+++ b/editors/emacs-devel/files/site-start.el.in
@@ -0,0 +1,36 @@
+;;; site-start.el --- Site-wide Initialization -*- lexical-binding: t -*-
+
+;; Installed by editors/emacs and editors/emacs-devel.
+;;
+;; This file is interpreted before user configuration.
+;; See the header of %%PREFIX%%/share/emacs/site-lisp/default.el for
+;; documentation on FreeBSD's site-wide Emacs startup configuration.
+
+;;; Code:
+
+(defvar freebsd-inhibit-native-compile nil
+ "When non-nil, inhibit native compilation of FreeBSD ports elisp.")
+
+(defvar freebsd-inhibit-byte-compile nil
+ "When non-nil, inhibit byte-compilation of FreeBSD ports elisp.
+Only applies to Emacs builds without native compilation support.")
+
+(defvar freebsd-site-lisp-dir "%%PREFIX%%/share/emacs/site-lisp"
+ "Root directory for FreeBSD ports-installed elisp files.
+This value is substituted at package build time by the FreeBSD
+ports infrastructure.")
+
+(defvar freebsd-elc-cache-dir
+ (expand-file-name "freebsd-elc-cache" user-emacs-directory)
+ "Per-user cache directory for byte-compiled FreeBSD ports elisp.
+Byte-compiled .elc files are stored here mirroring the subdirectory
+structure of `freebsd-site-lisp-dir', allowing load-path priority
+to select compiled files over .el source files.")
+
+;;; Path to Emacs C Sources, which is used by `find-function' for C-defined
+;;; symbols.
+(when (string-match (regexp-quote "%%EMACS_VER%%") emacs-version)
+ (setq find-function-C-source-directory
+ "%%DATADIR%%/%%EMACS_VER%%/src"))
+
+;;; site-start.el ends here
diff --git a/editors/emacs-devel/files/sources.el.in b/editors/emacs-devel/files/sources.el.in
deleted file mode 100644
--- a/editors/emacs-devel/files/sources.el.in
+++ /dev/null
@@ -1,6 +0,0 @@
-;;; site-start.el --- Site-wide Initialization -*- lexical-binding: t -*-
-
-;;; Path to Emacs C Sources.
-(when (string-match (regexp-quote "%%EMACS_VER%%") emacs-version)
- (setq find-function-C-source-directory
- "%%DATADIR%%/%%EMACS_VER%%/src"))
diff --git a/editors/emacs-devel/pkg-plist b/editors/emacs-devel/pkg-plist
--- a/editors/emacs-devel/pkg-plist
+++ b/editors/emacs-devel/pkg-plist
@@ -4309,7 +4309,6 @@
%%DATADIR%%/%%EMACS_VER%%/lisp/xwidget.elc
%%DATADIR%%/%%EMACS_VER%%/lisp/yank-media.el.gz
%%DATADIR%%/%%EMACS_VER%%/lisp/yank-media.elc
-%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/site-lisp/site-start.el
%%DATADIR%%/%%EMACS_VER%%/site-lisp/subdirs.el
%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/src/alloc.c
%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/src/android-asset.h
@@ -4567,6 +4566,8 @@
%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/src/xwidget.h
%%DATADIR%%/info/elisp_type_hierarchy.jpg
%%DATADIR%%/info/elisp_type_hierarchy.txt
+%%DATADIR%%/site-lisp/default.el
+%%DATADIR%%/site-lisp/site-start.el
%%DATADIR%%/site-lisp/subdirs.el
share/icons/hicolor/128x128/apps/emacs.png
share/icons/hicolor/16x16/apps/emacs.png
diff --git a/editors/emacs/Makefile b/editors/emacs/Makefile
--- a/editors/emacs/Makefile
+++ b/editors/emacs/Makefile
@@ -78,7 +78,7 @@
CONFLICTS_INSTALL= emacs-devel emacs-devel-nox
BINARY_ALIAS= makeinfo=true
-SUB_FILES= pkg-message sources.el
+SUB_FILES= default.el pkg-message site-start.el
SUB_LIST= EMACS_VER=${DISTVERSION} \
NATIVECOMP_COMMENT_END=${NATIVECOMP_COMMENT_END} \
NATIVECOMP_COMMENT_START=${NATIVECOMP_COMMENT_START}
@@ -296,6 +296,7 @@
post-install:
@${RM} -r ${STAGEDIR}${PREFIX}/lib/systemd
@(cd ${STAGEDIR}${PREFIX} && ${FIND} libexec/emacs/${DISTVERSION}/${CONFIGURE_TARGET}/ -name emacs-*.pdmp >> ${TMPPLIST})
+ ${INSTALL_DATA} ${WRKDIR}/default.el ${WRKDIR}/site-start.el ${STAGEDIR}${DATADIR}/site-lisp/
post-install-MAILUTILS-on:
${LN} -sf ${PREFIX}/bin/movemail \
@@ -310,6 +311,5 @@
post-install-SOURCES-on:
@${MKDIR} ${STAGEDIR}${DATADIR}/${DISTVERSION}/src
${INSTALL_DATA} ${WRKSRC}/src/*.[ch] ${STAGEDIR}${DATADIR}/${DISTVERSION}/src
- ${INSTALL_DATA} ${WRKDIR}/sources.el ${STAGEDIR}${DATADIR}/${DISTVERSION}/site-lisp/site-start.el
.include <bsd.port.mk>
diff --git a/editors/emacs/files/default.el.in b/editors/emacs/files/default.el.in
new file mode 100644
--- /dev/null
+++ b/editors/emacs/files/default.el.in
@@ -0,0 +1,133 @@
+;;; default.el --- Site-wide Initialization -*- lexical-binding: t -*-
+
+;; Installed by editors/emacs and editors/emacs-devel.
+;;
+;; This file is interpreted after user configuration.
+;;
+;; FreeBSD elisp (USES=emacs) ports only install .el source files under
+;; %%PREFIX%%/share/emacs/site-lisp/. This file arranges for those files to be
+;; compiled and cached per-user, following the same pattern used by ELPA. No
+;; root privileges are required after package installation.
+;;
+;; For Emacs builds with native compilation: .eln files are cached in
+;; ~/.emacs.d/eln-cache/ by Emacs's existing machinery.
+;;
+;; For Emacs builds without native compilation: .elc files are cached in
+;; ~/.emacs.d/freebsd-elc-cache/, with the cache directory prepended to
+;; load-path so compiled files take precedence over .el source.
+;;
+;; To disable native compilation of ports elisp, add the following to your Emacs
+;; configuration:
+;;
+;; (setq freebsd-inhibit-native-compile t)
+;;
+;; To disable byte-compilation of ports elisp (non-native-compilation builds
+;; only):
+;;
+;; (setq freebsd-inhibit-byte-compile t)
+
+;;; Code:
+
+(defun freebsd--elc-cache-dest (el-file)
+ "Map EL-FILE under `freebsd-site-lisp-dir' to its cache path.
+The subdirectory structure of `freebsd-site-lisp-dir' is mirrored
+under `freebsd-elc-cache-dir' to avoid filename collisions across
+ports and to allow per-subdirectory load-path entries."
+ (let* ((relative (file-relative-name el-file freebsd-site-lisp-dir))
+ (dest-el (expand-file-name relative freebsd-elc-cache-dir)))
+ (concat (file-name-sans-extension dest-el) ".elc")))
+
+(defun freebsd--elc-cache-valid-p ()
+ "Return non-nil if the elc cache was built by the current Emacs version.
+Reads a version stamp file from `freebsd-elc-cache-dir' and compares
+it to `emacs-version'. If missing or mismatched, the cache is
+considered stale and is cleared."
+ (let ((stamp (expand-file-name "emacs-version" freebsd-elc-cache-dir)))
+ (if (file-exists-p stamp)
+ (string= (with-temp-buffer
+ (insert-file-contents stamp)
+ (buffer-string))
+ emacs-version)
+ nil)))
+
+(defun freebsd--elc-cache-clear ()
+ "Remove all .elc files from `freebsd-elc-cache-dir'."
+ (when (file-directory-p freebsd-elc-cache-dir)
+ (dolist (elc (directory-files-recursively
+ freebsd-elc-cache-dir "\\.elc$"))
+ (delete-file elc))))
+
+(defun freebsd--elc-cache-write-stamp ()
+ "Write the current Emacs version to the cache stamp file."
+ (let ((stamp (expand-file-name "emacs-version" freebsd-elc-cache-dir)))
+ (with-temp-file stamp
+ (insert emacs-version))))
+
+(defun freebsd--setup-byte-compile-cache ()
+ "Set up the byte-compilation cache and prepend it to `load-path'.
+Creates `freebsd-elc-cache-dir' mirroring the subdirectory structure
+of `freebsd-site-lisp-dir', then prepends the cache root and all
+subdirectories to `load-path' so cached .elc files take precedence
+over .el source files."
+ (make-directory freebsd-elc-cache-dir t)
+ (when (file-directory-p freebsd-site-lisp-dir)
+ (dolist (dir (directory-files freebsd-site-lisp-dir t "^[^.]"))
+ (when (file-directory-p dir)
+ (make-directory
+ (expand-file-name
+ (file-relative-name dir freebsd-site-lisp-dir)
+ freebsd-elc-cache-dir)
+ t))))
+ (add-to-list 'load-path freebsd-elc-cache-dir)
+ (let ((default-directory freebsd-elc-cache-dir))
+ (normal-top-level-add-subdirs-to-load-path)))
+
+(defun freebsd--byte-compile-site-lisp ()
+ "Byte-compile FreeBSD ports elisp into `freebsd-elc-cache-dir'.
+Runs once on an idle timer to avoid blocking Emacs startup. First
+removes any stale .elc files whose corresponding .el source no longer
+exists in `freebsd-site-lisp-dir', then recompiles any .el files that
+are newer than their cached .elc, following the same pattern used
+by ELPA."
+ (run-with-idle-timer
+ 3 nil
+ (lambda ()
+ (unless (freebsd--elc-cache-valid-p)
+ (freebsd--elc-cache-clear))
+ (freebsd--elc-cache-write-stamp)
+ (when (file-directory-p freebsd-elc-cache-dir)
+ (dolist (elc (directory-files-recursively
+ freebsd-elc-cache-dir "\\.elc$"))
+ (let* ((relative (file-relative-name elc freebsd-elc-cache-dir))
+ (el (expand-file-name
+ (concat (file-name-sans-extension relative) ".el")
+ freebsd-site-lisp-dir)))
+ (unless (file-exists-p el)
+ (delete-file elc)))))
+ (let ((byte-compile-dest-file-function
+ #'freebsd--elc-cache-dest))
+ (dolist (el (directory-files-recursively
+ freebsd-site-lisp-dir "\\.el$"))
+ (let ((base (file-name-nondirectory el)))
+ (unless (member base '("site-start.el" "subdirs.el"))
+ (let ((elc (freebsd--elc-cache-dest el)))
+ (when (or (not (file-exists-p elc))
+ (file-newer-than-file-p el elc))
+ (let ((byte-compile-log-level 0)
+ (byte-compile-dest-file-function
+ #'freebsd--elc-cache-dest))
+ (byte-compile-file el)))))))))))
+
+;;; Entry point
+
+;; When running in batch mode (e.g. during port builds), skip all
+;; compilation machinery to avoid interference with the build environment.
+(unless noninteractive
+ (if (native-comp-available-p)
+ (unless freebsd-inhibit-native-compile
+ (native-compile-async freebsd-site-lisp-dir 'recursively))
+ (unless freebsd-inhibit-byte-compile
+ (freebsd--setup-byte-compile-cache)
+ (freebsd--byte-compile-site-lisp))))
+
+;;; default.el ends here
diff --git a/editors/emacs/files/site-start.el.in b/editors/emacs/files/site-start.el.in
new file mode 100644
--- /dev/null
+++ b/editors/emacs/files/site-start.el.in
@@ -0,0 +1,36 @@
+;;; site-start.el --- Site-wide Initialization -*- lexical-binding: t -*-
+
+;; Installed by editors/emacs and editors/emacs-devel.
+;;
+;; This file is interpreted before user configuration.
+;; See the header of %%PREFIX%%/share/emacs/site-lisp/default.el for
+;; documentation on FreeBSD's site-wide Emacs startup configuration.
+
+;;; Code:
+
+(defvar freebsd-inhibit-native-compile nil
+ "When non-nil, inhibit native compilation of FreeBSD ports elisp.")
+
+(defvar freebsd-inhibit-byte-compile nil
+ "When non-nil, inhibit byte-compilation of FreeBSD ports elisp.
+Only applies to Emacs builds without native compilation support.")
+
+(defvar freebsd-site-lisp-dir "%%PREFIX%%/share/emacs/site-lisp"
+ "Root directory for FreeBSD ports-installed elisp files.
+This value is substituted at package build time by the FreeBSD
+ports infrastructure.")
+
+(defvar freebsd-elc-cache-dir
+ (expand-file-name "freebsd-elc-cache" user-emacs-directory)
+ "Per-user cache directory for byte-compiled FreeBSD ports elisp.
+Byte-compiled .elc files are stored here mirroring the subdirectory
+structure of `freebsd-site-lisp-dir', allowing load-path priority
+to select compiled files over .el source files.")
+
+;;; Path to Emacs C Sources, which is used by `find-function' for C-defined
+;;; symbols.
+(when (string-match (regexp-quote "%%EMACS_VER%%") emacs-version)
+ (setq find-function-C-source-directory
+ "%%DATADIR%%/%%EMACS_VER%%/src"))
+
+;;; site-start.el ends here
diff --git a/editors/emacs/files/sources.el.in b/editors/emacs/files/sources.el.in
deleted file mode 100644
--- a/editors/emacs/files/sources.el.in
+++ /dev/null
@@ -1,6 +0,0 @@
-;;; site-start.el --- Site-wide Initialization -*- lexical-binding: t -*-
-
-;;; Path to Emacs C Sources.
-(when (string-match (regexp-quote "%%EMACS_VER%%") emacs-version)
- (setq find-function-C-source-directory
- "%%DATADIR%%/%%EMACS_VER%%/src"))
diff --git a/editors/emacs/pkg-plist b/editors/emacs/pkg-plist
--- a/editors/emacs/pkg-plist
+++ b/editors/emacs/pkg-plist
@@ -4291,8 +4291,9 @@
%%DATADIR%%/%%EMACS_VER%%/site-lisp/subdirs.el
%%DATADIR%%/info/elisp_type_hierarchy.jpg
%%DATADIR%%/info/elisp_type_hierarchy.txt
+%%DATADIR%%/site-lisp/default.el
+%%DATADIR%%/site-lisp/site-start.el
%%DATADIR%%/site-lisp/subdirs.el
-%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/site-lisp/site-start.el
%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/src/alloc.c
%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/src/android-asset.h
%%SOURCES%%%%DATADIR%%/%%EMACS_VER%%/src/android-emacs.c
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 10, 2:36 PM (6 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31231414
Default Alt Text
D56001.id174597.diff (27 KB)
Attached To
Mode
D56001: Emacs infrastructure: Overhaul
Attached
Detach File
Event Timeline
Log In to Comment