-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
125 lines (106 loc) · 4.21 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
#**************************************************************************
#* *
#* OCaml *
#* *
#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
#* *
#* Copyright 1997 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU General Public License. *
#* *
#**************************************************************************
VERSION = $(shell grep "^;; *Version" caml.el \
| sed -e 's/;; *Version: *\([^ \t]*\)/\1/')
SYNOPSIS = $(shell grep ';;; caml.el ---' caml.el \
| sed 's/[^-]*--- *\([^-]\+\) \+.*/\1/')
DIST_NAME = caml-mode-$(VERSION)
TARBALL = caml-mode-$(VERSION).tgz
OPAM_FILE = packages/caml-mode/caml-mode.$(VERSION)/opam
# Files to install
FILES= caml-font.el caml.el camldebug.el \
inf-caml.el caml-help.el caml-types.el
INSTALL_DIR ?= $(shell opam var share)/emacs/site-lisp
INSTALL_BIN ?= $(shell opam var bin)
DIST_FILES = $(FILES) Makefile README* COPYING* CHANGES.md ocamltags.in
# Name of Emacs executable
EMACSFORMACOSX = /Applications/Emacs.app/Contents/MacOS/Emacs
EMACSMACPORTS = /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs
AQUAMACS = $(shell test -d /Applications \
&& find /Applications -type f | grep 'Aquamacs$$')
ifeq ($(wildcard $(EMACSFORMACOSX)),$(EMACSFORMACOSX))
EMACS ?= $(EMACSFORMACOSX)
else
ifeq ($(wildcard $(EMACSMACPORTS)),$(EMACSMACPORTS))
EMACS ?= $(EMACSMACPORTS)
else
ifneq ($(strip $(AQUAMACS)),)
ifeq ($(wildcard $(AQUAMACS)),$(AQUAMACS))
EMACS ?= $(AQUAMACS)
endif
endif
endif
endif
EMACS ?= emacs
INSTALL_MKDIR = mkdir -p
INSTALL_DATA = cp
INSTALL_RM_R = $(RM) -r
# Command for byte-compiling the files
COMPILECMD=(progn \
(setq load-path (cons "." load-path)) \
(byte-compile-file "caml.el") \
(byte-compile-file "inf-caml.el") \
(byte-compile-file "caml-help.el") \
(byte-compile-file "caml-types.el") \
(byte-compile-file "caml-font.el") \
(byte-compile-file "camldebug.el"))
# This is for testing purposes
compile-only:
$(EMACS) --batch --eval '$(COMPILECMD)'
# install the .el files, but do not compile them.
install-el:
$(MAKE) NOCOMPILE=true install
install:
@echo "Installing in $(INSTALL_DIR)..."
$(INSTALL_MKDIR) $(INSTALL_DIR)
$(INSTALL_DATA) $(FILES) $(INSTALL_DIR)
if [ -z "$(NOCOMPILE)" ]; then \
cd $(INSTALL_DIR); $(EMACS) --batch --eval '$(COMPILECMD)'; \
fi
uninstall:
cd $(INSTALL_DIR) && $(INSTALL_RM_R) $(FILES) $(FILES:.el=.elc)
ocamltags: ocamltags.in
sed -e 's:@EMACS@:$(EMACS):' ocamltags.in >ocamltags
chmod a+x ocamltags
install-ocamltags: ocamltags
$(INSTALL_DATA) ocamltags $(INSTALL_BIN)/ocamltags
uninstall-ocamltags:
$(INSTALL_RM_R) $(INSTALL_BIN)/ocamltags
tarball: $(TARBALL)
$(TARBALL): $(DIST_FILES)
$(INSTALL_MKDIR) $(DIST_NAME)
for f in $(DIST_FILES); do cp $$f $(DIST_NAME); done
echo "(define-package \"caml\" \"$(VERSION)\" \"$(SYNOPSIS)\")" \
> $(DIST_NAME)/caml-pkg.el
tar acvf $@ $(DIST_NAME)
$(INSTALL_RM_R) $(DIST_NAME)
submit: $(TARBALL)
@if [ ! -d packages/ ]; then \
echo "Make a symbolic link packages → OPAM repository/packages"; \
exit 1; \
fi
$(INSTALL_MKDIR) $(dir $(OPAM_FILE))
sed -e "s/VERSION/$(VERSION)/" -e 's/SYNOPSIS/$(SYNOPSIS)/' \
caml-mode.opam > $(OPAM_FILE)
echo "url {" >> $(OPAM_FILE)
echo " src: \"https://github.com/ocaml/caml-mode/releases/download/$(VERSION)/$(TARBALL)\"" >> $(OPAM_FILE)
echo " checksum: \"md5=`md5sum $(TARBALL) | cut -d ' ' -f 1`\"" \
>> $(OPAM_FILE)
echo "}" >> $(OPAM_FILE)
clean:
rm -f ocamltags *~ \#*# *.elc
$(RM) -r $(TARBALL)
.PHONY: install uninstall install-el \
ocamltags install-ocamltags uninstall-ocamltags \
tarball submit compile-only clean