-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (100 loc) · 2.74 KB
/
Makefile
File metadata and controls
130 lines (100 loc) · 2.74 KB
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
# Makefile for LFE
# This simple Makefile uses rebar (in Unix) or rebar.cmd (in Windows)
# to compile/clean if it exists, else does it explicitly.
BINDIR = bin
EBINDIR = ebin
SRCDIR = src
CSRCDIR = c_src
INCDIR = include
DOCDIR = doc
EMACSDIR = emacs
VPATH = $(SRCDIR)
ERLCFLAGS = -W1
ERLC = erlc
EXPM=$(BINDIR)/expm
LIB=lfe
# To run erl as bash
FINISH=-run init stop -noshell
# Scripts to be evaluated
MAPS_MK = 'Has=erl_internal:bif(is_map,1), \
HasMaps=if Has -> "-DHAS_MAPS=true\n" ; true -> "\n" end, \
file:write_file("maps.mk", "HAS_MAPS = " ++ HasMaps)' \
$(FINISH)
GET_VERSION = '{ok,[App]}=file:consult("src/$(LIB).app.src"), \
V=proplists:get_value(vsn,element(3,App)), \
io:format("~p~n",[V])' \
$(FINISH)
## The .erl, .xrl, .yrl and .beam files
ESRCS = $(notdir $(wildcard $(SRCDIR)/*.erl))
XSRCS = $(notdir $(wildcard $(SRCDIR)/*.xrl))
YSRCS = $(notdir $(wildcard $(SRCDIR)/*.yrl))
EBINS = $(ESRCS:.erl=.beam) $(XSRCS:.xrl=.beam) $(YSRCS:.yrl=.beam)
CSRCS = $(notdir $(wildcard $(CSRCDIR)/*.c))
BINS = $(CSRCS:.c=)
## Where we install links to the LFE binaries.
DESTBINDIR = $(PREFIX)$(shell dirname `which erl` 2> /dev/null || echo "/usr/local/bin" )
.SUFFIXES: .erl .beam
$(BINDIR)/%: $(CSRCDIR)/%.c
cc -o $@ $<
$(EBINDIR)/%.beam: $(SRCDIR)/%.erl
$(ERLC) -I $(INCDIR) -o $(EBINDIR) $(HAS_MAPS) $(ERLCFLAGS) $<
%.erl: %.xrl
$(ERLC) -o $(SRCDIR) $<
%.erl: %.yrl
$(ERLC) -o $(SRCDIR) $<
all: compile docs
.PHONY: compile erlc_compile install docs clean
## Compile using rebar if it exists else using make
compile: maps.mk
if which rebar.cmd > /dev/null; \
then rebar.cmd compile; \
elif which rebar > /dev/null; \
then rebar compile; \
else $(MAKE) $(MFLAGS) erlc_compile; \
fi
## Compile using erlc
erlc_compile: $(addprefix $(EBINDIR)/, $(EBINS)) $(addprefix $(BINDIR)/, $(BINS))
maps.mk:
erl -eval $(MAPS_MK)
-include maps.mk
install:
ln -s `pwd`/bin/lfe $(DESTBINDIR)
ln -s `pwd`/bin/lfec $(DESTBINDIR)
ln -s `pwd`/bin/lfescript $(DESTBINDIR)
docs:
clean:
if which rebar.cmd > /dev/null; \
then rebar.cmd clean; \
elif which rebar > /dev/null; \
then rebar clean; \
else rm -rf $(EBINDIR)/*.beam; \
fi
rm maps.mk
rm -rf erl_crash.dump
echo:
@ echo $(ESRCS)
@ echo $(XSRCS)
@ echo $(YSRCS)
@ echo $(EBINS)
$(EXPM): $(BINDIR)
curl -o $(EXPM) http://expm.co/__download__/expm
chmod +x $(EXPM)
get-deps: $(EXPM)
if which rebar.cmd > /dev/null; \
then rebar.cmd get-deps; \
elif which rebar > /dev/null; \
then rebar get-deps; \
fi
get-version:
@echo
@echo "Getting version info ..."
@echo
@echo -n app.src: ''
@erl -eval $(GET_VERSION)
@echo -n package.exs: ''
@grep version package.exs | awk '{print $$2}'| sed -e 's/,//g'
upload: get-deps get-version
@echo
@echo "Continue with upload? "
@read
$(EXPM) publish