-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
101 lines (85 loc) · 2.87 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
PROFILE_FLAGS=-Q -l ./.emacs.d/lisp/vendor/profile-dotemacs.el -f profile-dotemacs
COMPILE_FLAGS=-batch --eval "(require 'package)" --eval "(package-initialize)" --eval "(byte-compile-file (expand-file-name \"~/.emacs.d/lisp/$(file)\")0)"
CUSTOM_ELISP=init-cc.el init-js.el init-package.el init-python.el init-ruby.el
ifeq ($(OS),Windows_NT)
CP=@copy
ECHO=@echo
EMACS=@ # echo off
EMACS+=C:\Dev\Emacs\Bin\emacs.exe # figure out a one-liner
INSTALLDIR=${APPDATA}
NORMALIZE_PATH=$(subst /,\,$1)
RM=del
RMDIR=rmdir /s /q
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),$(filter $(UNAME_S),Linux FreeBSD Darwin))
CP=cp
ECHO=echo
INSTALLDIR=~
NORMALIZE_PATH=$1
RM=rm
RMDIR=rm -rf
EMACS=$(shell which emacs)
else
ERROR_OS=yes
endif
endif
all: install compile
install:
ifeq ($(ERROR_OS),yes)
$(error Error: Unknown OS.)
endif
ifeq ("$(wildcard ${INSTALLDIR})","")
$(error Error: Unknown path.)
endif
ifeq ("$(wildcard ${EMACS})","")
$(error Error: Emacs not found.)
endif
ifneq ("$(wildcard ${INSTALLDIR}/.emacs.d/*.elc)","")
${ECHO} Deleting ${INSTALLDIR}/.emacs.d/*.elc files.
${RM} $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/*.elc)
endif
ifneq ("$(wildcard ${INSTALLDIR}/.emacs.d/lisp/*.elc)","")
${ECHO} Deleting ${INSTALLDIR}/.emacs.d/lisp/*.elc files.
${RM} $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/lisp/*.elc)
endif
ifeq ("$(wildcard ${INSTALLDIR}/.emacs.d/)","")
${ECHO} Creating directory .emacs.d/
mkdir $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/)
endif
ifeq ("$(wildcard ${INSTALLDIR}/.emacs.d/elpa)","")
${ECHO} Creating directory .emacs.d/elpa/
mkdir $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/elpa)
endif
ifeq ("$(wildcard ${INSTALLDIR}/.emacs.d/lisp)","")
${ECHO} Creating directory .emacs.d/lisp/
mkdir $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/lisp)
endif
ifeq ("$(wildcard ${INSTALLDIR}/.emacs.d/lisp/vendor)","")
${ECHO} Creating directory .emacs.d/lisp/vendor/
mkdir $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/lisp/vendor)
endif
ifeq ("$(wildcard ${INSTALLDIR}/.emacs.d/snippets)","")
${ECHO} Creating directory .emacs.d/snippets/
mkdir $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/snippets)
endif
${ECHO} Copying emacs files.
${CP} .emacs $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs)
${CP} $(call NORMALIZE_PATH,.emacs.d/lisp/*.el) $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/lisp)
${CP} $(call NORMALIZE_PATH,.emacs.d/lisp/vendor/*.el) $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d/lisp/vendor)
compile:
ifneq ("$(wildcard ${EMACS})","")
${ECHO} Byte compiling scripts.
$(foreach file,$(CUSTOM_ELISP),${EMACS} ${COMPILE_FLAGS})
else
$(error Error: Emacs not found (${EMACS}).)
endif
clean:
${RMDIR} $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs.d)
${RM} $(call NORMALIZE_PATH,${INSTALLDIR}/.emacs)
profile:
ifneq ("$(wildcard ${EMACS})","")
${EMACS} ${PROFILE_FLAGS}
else
$(error Error: Emacs not found (${EMACS}).)
endif