forked from seoulpm/seoulpm-advent-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common
57 lines (44 loc) · 1.44 KB
/
Makefile.common
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
DEFAULT_CONFIG := $(YEAR)/advent.ini
PATCH_LIB := PERL5LIB=./patch/lib/:$(PERL5LIB)
DEPEND_CPAN_MODULES := \
App::HTTPThis \
HTML::Escape \
Mojo::DOM \
Text::MultiMarkdown \
URI::Escape \
WWW::AdventCalendar
ADVCAL := $(PATCH_LIB) advcal
ADVCAL_CONFIG := advent.ini
ADVCAL_OUT := output-$(YEAR)
ADVCAL_OUT_TGZ := $(ADVCAL_OUT).tgz
ADVCAL_SHARE := $(YEAR)/share
ADVCAL_ARTICLE := $(YEAR)/articles
ADVCAL_FLAGS += --config $(ADVCAL_CONFIG)
ADVCAL_FLAGS += --output-dir $(ADVCAL_OUT)
ADVCAL_FLAGS += --article-dir $(ADVCAL_ARTICLE)
ADVCAL_FLAGS += --share-dir $(ADVCAL_SHARE)
#
# Please set your environment variable for release
#
ADV_UPLOAD_USER ?=
ADV_UPLOAD_SERVER ?=
ADV_UPLOAD_COMMAND ?=
IFCONFIG ?= ifconfig
CPAN ?= cpan
all: build
build:
perl -E 'symlink "$(DEFAULT_CONFIG)", "$(ADVCAL_CONFIG)" unless -e "$(ADVCAL_CONFIG)"'
$(ADVCAL) $(ADVCAL_FLAGS)
clean:
rm -rf $(ADVCAL_OUT) $(ADVCAL_OUT_TGZ)
perl -E 'unlink "$(ADVCAL_CONFIG)" if readlink("$(ADVCAL_CONFIG)") eq "$(DEFAULT_CONFIG)";'
install-depends:
$(CPAN) $(DEPEND_CPAN_MODULES)
upload: build
tar cvzf $(ADVCAL_OUT_TGZ) $(ADVCAL_OUT)
scp $(ADVCAL_OUT_TGZ) $(ADV_UPLOAD_USER)@$(ADV_UPLOAD_SERVER):/tmp/
ssh -t $(ADV_UPLOAD_USER)@$(ADV_UPLOAD_SERVER) '$(ADV_UPLOAD_COMMAND); rm -rf /tmp/$(ADVCAL_OUT_TGZ)'
run: build
$(IFCONFIG) | perl -nlE 'do { say $$1 } if /inet addr:(\d{1,3}(?:\.\d{1,3}){3})/'
http_this $(ADVCAL_OUT)
.PHONY: all build clean install-depends upload