-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
136 lines (95 loc) · 4.3 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
#-----------------------------------------------------------------------------
# Safety checks...
ifndef PCJD_MODE
PCJD_MODE = development
endif
ifeq ($(PCJD_MODE), production)
$(error Refusing to run in production environment)
endif
#-----------------------------------------------------------------------------
APP = pcjd
PORT = 5555
CPAN = cpan
LOCAL = $(PWD)/local
PROVE = prove
PINTO = pinto
PERL = perl
REPLY = reply
IDE = '/Applications/Sublime Text.app'
PLACKUP = plackup
PLACK_FLAG_PORT = -port $(PORT)
PLACK_FLAG_SERVER = -server HTTP::Server::PSGI
PLACK_FLAGS = $(PLACK_FLAG_PORT) $(PLACK_FLAG_SERVER)
MORBO = $(LOCAL)/bin/morbo
MORBO_FLAG_LISTEN = --listen http://*:$(PORT)
MORBO_FLAG_VERBOSE = --verbose
MORBO_FLAG_WATCH =
MORBO_FLAGS = $(MORBO_FLAG_LISTEN) $(MORBO_FLAG_WATCH) $(MORBO_FLAG_VERBOSE)
CPANM = cpanm
CPANM_FLAG_MIRROR = --mirror-only --mirror file://$(PWD)/cpan
CPANM_FLAG_LOCAL_LIB = --local-lib-contained $(LOCAL)
CPANM_FLAG_CPANFILE = --cpanfile etc/cpanfile
CPANM_FLAGS = $(CPANM_FLAG_MIRROR) $(CPANM_FLAG_LOCAL_LIB) $(CPANM_FLAG_CPANFILE)
MOJO_MODE = $(PCJD_MODE)
#-----------------------------------------------------------------------------
export MOJO_MODE := $(MOJO_MODE)
export PERL5LIB := $(PWD)/lib:$(LOCAL)/lib/perl5
export MANPATH := $(LOCAL)/man:$(MANPATH)
export PATH := $(LOCAL)/bin:$(PATH)
unexport PINTO_HOME
unexport PERL_CPANM_OPT
#-----------------------------------------------------------------------------
help:
@echo Available targets are:
@echo 'all Does dependencies, database, test, start'
@echo 'clean Deletes all application data'
@echo 'debug Starts the app under debugger (perl -d)'
@echo 'dependencies Does all dependency targets (run, test, develop)'
@echo 'dependencies-run Installs prerequisite Perl modules for runtime into local/'
@echo 'dependencies-test Installs prerequisite Perl modules for testing into local/'
@echo 'dependencies-develop Installs prerequisite Perl modules for development into local/'
@echo 'ide Spawn an editor ($$IDE) with the application environment'
@echo 'help Display this lovely message'
@echo 'realclean Restore everything to a pristine state'
@echo 'shell Spawn a shell ($$SHELL) with the application environment'
@echo 'start Launches the app under morbo'
@echo 'reply Load app in a read-eval-print loop'
@echo 'test Runs unit tests'
#-----------------------------------------------------------------------------
all: dependencies test start
#-----------------------------------------------------------------------------
shell:
-@$(SHELL)
#-----------------------------------------------------------------------------
dependencies-run:
$(CPANM) $(CPANM_FLAGS) --notest --quiet --installdeps .
#-----------------------------------------------------------------------------
dependencies-test:
$(CPANM) $(CPANM_FLAGS) --quiet --installdeps .
#-----------------------------------------------------------------------------
dependencies-develop:
$(CPANM) $(CPANM_FLAGS) --notest --with-develop --quiet --installdeps .
#-----------------------------------------------------------------------------
dependencies: dependencies-test dependencies-develop
#-----------------------------------------------------------------------------
start:
$(MORBO) $(MORBO_FLAGS) bin/$(APP)
#-----------------------------------------------------------------------------
debug:
$(PERL) -d -S $(PLACKUP) $(PLACK_FLAGS) bin/$(APP)
#-----------------------------------------------------------------------------
test: dependencies-test
$(PERL) -MCarp::Always -S $(PROVE) --color -r test
#-----------------------------------------------------------------------------
clean:
rm -rf log/*
rm -rf tmp/*
#-----------------------------------------------------------------------------
realclean: clean
rm -rf $(LOCAL)
#-----------------------------------------------------------------------------
reply:
$(REPLY) -MCarp::Always -MPerl::Critic::Jed
#-----------------------------------------------------------------------------
ide:
open $(IDE)