Skip to content

Commit

Permalink
Merge branch 'load-path' [#126]
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Dec 4, 2023
2 parents ab1a53a + ad62876 commit 373defa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
DESTDIR ?=
PREFIX ?= /usr
DATADIR ?= $(PREFIX)/share
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
ELDIR ?= $(DATADIR)/emacs/site-lisp
DYNMODDRIR ?= $(LIBDIR)/emacs/site-lisp

BUILD_OPTIONS=-DCMAKE_BUILD_TYPE=Debug

ifeq '$(findstring ;,$(PATH))' ';'
Expand Down Expand Up @@ -54,7 +62,7 @@ EMACS_ARGS ?=

LOAD_PATH ?= -L . -L build

.PHONY: test libgit2 submodule-update
.PHONY: test submodule-update install

all: lisp

Expand Down Expand Up @@ -135,3 +143,17 @@ $(PKG)-autoloads.el: $(ELS)
(update-directory-autoloads default-directory))"

endif

install-%-dynamic-module:
$(if $<, install -m755 -d $(DESTDIR)$(DYNMODDRIR))
$(if $<, install -m755 $^ $(DESTDIR)$(DYNMODDRIR))

install-%-el:
$(if $<, install -m755 -d $(DESTDIR)$(ELDIR))
$(if $<, install -m644 $^ $(DESTDIR)$(ELDIR))

install: $(addprefix install-, libgit-el libgit-dynamic-module)

install-libgit-el: $(ELS) $(ELCS) $(PKG)-autoloads.el

install-libgit-dynamic-module: build/libegit2.so
18 changes: 13 additions & 5 deletions libgit.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@
(expand-file-name "build" libgit--root)
"Directory where the libegit2 dynamic module file should be built.")

(defvar libgit--module-file
(expand-file-name "libegit2.so" libgit--build-dir)
(defvar libgit--module-file-name
(file-name-with-extension "libegit2" module-file-suffix)
"Name of the libegit2 dynamic module file.")

(defvar libgit--module-file-name-path
(expand-file-name libgit--module-file-name
libgit--build-dir)
"Path to the libegit2 dynamic module file.")

(defun libgit--configure ()
Expand Down Expand Up @@ -90,7 +95,7 @@ On successful exit, pass control on to the load step."
"Load the `libegit2' dynamic module.
If that fails, then raise an error."
(unless (featurep 'libegit2)
(load libgit--module-file nil t t))
(load libgit--module-file-name-path nil t t))
(unless (featurep 'libegit2)
(error "libgit: unable to load the libegit2 dynamic module")))

Expand All @@ -100,8 +105,11 @@ If that fails, then raise an error."
If the module is not available, then offer to build it."
(interactive)
(cond
((file-exists-p libgit--module-file)
(libgit--load))
((file-exists-p libgit--module-file-name-path)
(libgit--load))
((locate-library libgit--module-file-name t)
(setq libgit--module-file-name-path (locate-library libgit--module-file-name t))
(libgit--load))
(libgit-auto-rebuild
(libgit--configure))
((and (not noninteractive)
Expand Down

0 comments on commit 373defa

Please sign in to comment.