-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
101 lines (74 loc) · 2.64 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
# Copyright 2014 Jean Parpaillon, all rights reserved
#
# This file is provided to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
PROJECT = averell
VERSION = 1.2.1
DESTDIR ?=
define localdep =
$(shell erl -noshell -eval "case application:ensure_all_started($1) of {ok, _} -> halt(0); _ -> halt(1) end." && echo ok || true)
endef
ALL_DEPS = cowboy getopt
$(foreach dep,$(ALL_DEPS),$(if $(call localdep,$(dep)),$(eval LOCAL_DEPS+=$(dep)),$(eval DEPS+=$(dep))))
dep_cowboy_commit = 2.0.0-pre.1
dep_getopt = git https://github.com/jcomellas/getopt.git v0.8.2
ESCRIPT_EMU_ARGS = -smp auto -pa . -noshell -noinput -sasl errlog_type error -escript main averell
DB2MAN = /usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/manpages/docbook.xsl
XP = xsltproc -''-nonet -''-param man.charmap.use.subset "0"
MANS = $(PROJECT).1
VSN = $(shell $(CURDIR)/version.sh $(VERSION))
ARCHIVE = $(PROJECT)-$(VSN).tar.xz
prefix ?= /usr/local
bindir ?= $(prefix)/bin
subst = sed -e 's|@VSN[@]|$(VSN)|g'
include erlang.mk
all:: escript
doc: man
test-build:: escript
escript::
man: $(MANS)
%.1: %.1.xml
$(XP) $(DB2MAN) $<
ebin/$(PROJECT).app:: src/$(PROJECT).app.src
src/$(PROJECT).app.src: src/$(PROJECT).app.src.in
$(gen_verbose) $(subst) $< > $@
dist: $(PROJECT)-$(VSN).tar.xz
debian-dist: $(PROJECT)_$(VSN).orig.tar.xz
$(PROJECT)_$(VSN).orig.tar.xz: $(PROJECT)-$(VSN).tar.xz
ln -s $< $@
$(PROJECT)-$(VSN).tar.xz:
-rm -f src/$(PROJECT).app.src
@$(MAKE) --no-print-directory src/$(PROJECT).app.src
$(gen_verbose) git archive --prefix=$(PROJECT)-$(VSN)/ HEAD . | \
tar xf - && \
cp src/$(PROJECT).app.src $(PROJECT)-$(VSN)/src && \
tar cf - $(PROJECT)-$(VSN) | xz > $@ && \
rm -rf $(PROJECT)-$(VSN)
install: all
mkdir -p $(DESTDIR)$(bindir)
install -m 755 $(PROJECT) $(DESTDIR)$(bindir)/$(PROJECT)
clean:: clean-deps clean-local
clean-deps:
@for dep in $(wildcard deps/*) ; do \
if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
$(MAKE) -C $$dep clean ; \
else \
echo "include $(CURDIR)/erlang.mk" | ERLC_OPTS=+debug_info $(MAKE) -f - -C $$dep clean ; \
fi ; \
done
clean-local:
- rm -f $(MANS)
- rm -f $(PROJECT)
.PHONY: install