This repository has been archived by the owner on Oct 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
189 lines (142 loc) · 4.45 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# DPP
# Copyright (C) 2015, 2016 Christophe Delord
# http://www.cdsoft.fr/dpp
#
# This file is part of DPP.
#
# DPP is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DPP is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DPP. If not, see <http://www.gnu.org/licenses/>.
#####################################################################
# Platform detection
#####################################################################
OS = $(shell uname)
GHCOPT = -Wall -Werror -O2
ifeq "$(OS)" "Linux"
DPP = dpp
GPP = gpp
all: gpp dpp README.md
all: dpp.tgz
all: doc/gpp.html doc/dpp.html
all: gpp.exe dpp.exe
CCWIN = i686-w64-mingw32-gcc
WINE = wine
else
ifeq "$(OS)" "MINGW32_NT-6.1"
DPP = dpp.exe
GPP = gpp.exe
all: gpp.exe dpp.exe
all: doc/gpp.html doc/dpp.html
CCWIN = gcc
WINE =
else
ifeq "$(OS)" "CYGWIN_NT-6.1-WOW"
DPP = dpp.exe
GPP = gpp.exe
all: gpp.exe dpp.exe
all: doc/gpp.html doc/dpp.html
CCWIN = mingw32-gcc
WINE =
else
$(error "Unknown platform: $(OS)")
endif
endif
endif
BUILD = .build
CACHE = .cache
install: $(DPP) $(GPP)
install -v -C $^ $(shell (ls -d /usr/local/bin || echo /usr/bin) 2>/dev/null)
clean:
rm -rf $(BUILD) doc
rm -f gpp gpp.exe dpp dpp.exe
rm -f dpp.tgz
.DELETE_ON_ERROR:
#####################################################################
# README
#####################################################################
README.md: $(GPP) $(DPP)
README.md: src/dpp.md
@mkdir -p doc/img
./$(GPP) -T -x $< | ./$(DPP) | pandoc -f markdown -t markdown_github > $@
#####################################################################
# archives
#####################################################################
dpp.tgz: Makefile $(wildcard src/*) README.md LICENSE .gitignore
tar -czf $@ $^
#####################################################################
# GPP
#####################################################################
GPP_URL = http://files.nothingisreal.com/software/gpp/gpp.tar.bz2
gpp: BUILDGPP=$(BUILD)/$@
gpp: $(CACHE)/$(notdir $(GPP_URL))
@mkdir -p $(BUILDGPP)
tar xjf $< -C $(BUILDGPP)
cd $(BUILDGPP)/gpp-* && ./configure && make
cp $(BUILDGPP)/gpp-*/src/gpp $@
@strip $@
gpp.exe: BUILDGPP=$(BUILD)/$@
gpp.exe: $(CACHE)/$(notdir $(GPP_URL))
@mkdir -p $(BUILDGPP)
tar xjf $< -C $(BUILDGPP)
export CC=$(CCWIN); cd $(BUILDGPP)/gpp-* && ./configure --host $(shell uname) && make
cp $(BUILDGPP)/gpp-*/src/gpp.exe $@
@strip $@
$(CACHE)/$(notdir $(GPP_URL)):
@mkdir -p $(dir $@)
wget $(GPP_URL) -O $@
doc/gpp.html: $(GPP)
@mkdir -p $(dir $@)
cp $(BUILD)/$</gpp-*/doc/gpp.html $@
#####################################################################
# Dependencies
#####################################################################
PLANTUML = plantuml
PLANTUML_URL = http://sourceforge.net/projects/plantuml/files/$(PLANTUML).jar/download
DITAA_VERSION = 0.9
DITAA = ditaa0_9
DITAA_URL = http://freefr.dl.sourceforge.net/project/ditaa/ditaa/$(DITAA_VERSION)/$(DITAA).zip
$(BUILD)/%.o: $(BUILD)/%.c
gcc -c -o $@ $^
$(BUILD)/%-win.o: $(BUILD)/%.c
$(CCWIN) -c -o $@ $^
$(BUILD)/%.c: $(CACHE)/%.jar
@mkdir -p $(dir $@)
xxd -i $< $@
sed -i 's/_cache_//g' $@
$(CACHE)/$(PLANTUML).jar:
@mkdir -p $(dir $@)
wget $(PLANTUML_URL) -O $@
$(CACHE)/$(DITAA).zip:
@mkdir -p $(dir $@)
wget $(DITAA_URL) -O $@
$(CACHE)/$(DITAA).jar: $(CACHE)/$(DITAA).zip
unzip $< $(notdir $@) -d $(dir $@)
@touch $@
$(CACHE)/dpp.css:
@mkdir -p $(dir $@)
wget http://cdsoft.fr/cdsoft.css -O $@
#####################################################################
# DPP
#####################################################################
dpp: src/dpp.c $(BUILD)/$(PLANTUML).o $(BUILD)/$(DITAA).o
gcc -Werror -Wall $^ -o $@
@strip $@
dpp.exe: src/dpp.c $(BUILD)/$(PLANTUML)-win.o $(BUILD)/$(DITAA)-win.o
$(CCWIN) -Werror -Wall $^ -o $@
@strip $@
doc/dpp.html: $(GPP) $(DPP) doc/dpp.css
doc/dpp.html: src/dpp.md
@mkdir -p $(dir $@) doc/img
./$(GPP) -T -x $< | ./$(DPP) | pandoc -S --toc --self-contained -c doc/dpp.css -f markdown -t html5 > $@
doc/dpp.css: $(CACHE)/dpp.css
@mkdir -p $(dir $@)
cp $< $@