-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
159 lines (121 loc) · 3.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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))' ';'
UNAME := Windows
else
UNAME := $(shell uname 2>/dev/null || echo Unknown)
UNAME := $(patsubst CYGWIN%,Cygwin,$(UNAME))
UNAME := $(patsubst MSYS%,MSYS,$(UNAME))
UNAME := $(patsubst MINGW%,MSYS,$(UNAME))
endif
ifeq ($(UNAME),MSYS)
BUILD_OPTIONS+= -G "MSYS Makefiles"
endif
# If the variable USE_SYSTEM_LIBGIT2 is set to *any* value, use the
# system provided libgit2 library.
USE_SYSTEM_LIBGIT2? := \
$(if $(or $(USE_SYSTEM_LIBGIT2),\
$(findstring USE_SYSTEM_LIBGIT2,$(BUILD_OPTIONS))),\
true)
ifeq "$(TRAVIS)" "true"
## Makefile for Travis ###################################################
#
# TODO Move this to a separate file ".travis.mk" once Emake supports
# that. (Apparently it already does, but I couldn't get it to work.)
EMAKE_SHA1 ?= 1b23379eb5a9f82d3e2d227d0f217864e40f23e0
PACKAGE_BASENAME := libgit
include emake.mk
build/libegit2.so:
git submodule update --init
mkdir -p build
cd build && cmake .. $(BUILD_OPTIONS) && make
test: EMACS_ARGS += -L build/ -l libegit2
test: build/libegit2.so test-ert
else
## Makefile for local use ################################################
-include .config.mk
PKG = libgit
ELS = $(PKG).el
ELCS = $(ELS:.el=.elc)
EMACS ?= emacs
EMACS_ARGS ?=
LOAD_PATH ?= -L . -L build
.PHONY: test submodule-update install
all: lisp
help:
$(info make all - build everything)
$(info make module - generate module)
$(info make lisp - generate byte-code and autoloads)
$(info make submodule-init - update the submodule)
$(info make submodule-update - update the submodule)
$(info make test - run tests)
$(info make clean - remove generated files)
@printf "\n"
module: build/libegit2.so
build/libegit2.so: libgit2
@printf "Building $<\n"
@mkdir -p build
@cd build && cmake .. $(BUILD_OPTIONS) && make
lisp: $(ELCS) loaddefs module
loaddefs: $(PKG)-autoloads.el
%.elc: %.el
@printf "Compiling $<\n"
@$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) -f batch-byte-compile $<
test: libgit.elc build/libegit2.so
$(EMACS) -Q --batch $(LOAD_PATH) -l libgit \
$(addprefix -l test/,$(shell ls test)) \
-f ert-run-tests-batch-and-exit
submodule-init: libgit2
submodule-update:
@git submodule update
libgit2:
ifeq ($(USE_SYSTEM_LIBGIT2?),)
@git submodule update --init
else
@echo "Using the system provided libgit2 library"
endif
CLEAN = $(ELCS) $(PKG)-autoloads.el build
clean:
@printf "Cleaning...\n"
@rm -rf $(CLEAN)
define LOADDEFS_TMPL
;;; $(PKG)-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name \
(or (file-name-directory #$$) (car load-path))))
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:
;;; $(PKG)-autoloads.el ends here
endef
export LOADDEFS_TMPL
#'
$(PKG)-autoloads.el: $(ELS)
@printf "Generating $@\n"
@printf "%s" "$$LOADDEFS_TMPL" > $@
@$(EMACS) -Q --batch --eval "(progn\
(setq make-backup-files nil)\
(setq vc-handled-backends nil)\
(setq default-directory (file-truename default-directory))\
(setq generated-autoload-file (expand-file-name \"$@\"))\
(setq find-file-visit-truename t)\
(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