Debian Codegraph @

GNUmakefile

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 # -*- mode: makefile-gmake -*-
2
3 all:
4 .PHONY: all
5
6 # git version
•7 GIT_VERSION = unknown
8
9 # check GNU Make
10 ifeq ($(.FEATURES),)
11 $(error Sorry, please use a newer version (3.81 or later) of gmake (GNU Make).)
12 endif
13 MAKE_VERSION := $(shell LANG=C $(MAKE) --version | head -1)
14
15 # check gawk
16 GAWK := $(shell which gawk 2>/dev/null || bash -c 'builtin type -P gawk' 2>/dev/null)
17 ifneq ($(GAWK),)
18 GAWK_VERSION := $(shell LANG=C $(GAWK) --version 2>/dev/null | sed -n '1{/[Gg][Nn][Uu] [Aa][Ww][Kk]/p;}')
19 ifeq ($(GAWK_VERSION),)
20 $(error Sorry, gawk is found but does not seem to work. Please install a proper version of gawk (GNU Awk).)
21 endif
22 else
23 GAWK := $(shell which awk 2>/dev/null || bash -c 'builtin type -P awk' 2>/dev/null)
24 ifeq ($(GAWK),)
25 $(error Sorry, gawk/awk could not be found. Please check your PATH environment variable.)
26 endif
27 GAWK_VERSION := $(shell LANG=C $(GAWK) --version 2>/dev/null | sed -n '1{/[Gg][Nn][Uu] [Aa][Ww][Kk]/p;}')
28 ifeq ($(GAWK_VERSION),)
29 $(error Sorry, gawk could not be found. Please install gawk (GNU Awk).)
30 endif
31 endif
32
33 MWGPP := $(GAWK) -f make/mwg_pp.awk
34
35 # Note (#D2058): we had used "cp -p xxx out/xxx" to copy files to the build
36 # directory, but some filesystem (ecryptfs) has a bug that the subsecond
37 # timestamps are truncated causing an issue: make every time copies all the
38 # files into the subdirectory `out`. We give up using `cp -p` and instead copy
39 # the file with `cp` with the timestamps being the copy time.
40 CP := cp
41
42 #------------------------------------------------------------------------------
43 # ble.sh
44
45 FULLVER := 0.4.0-devel4
46
•47 BLE_GIT_COMMIT_ID := unknown
48 BLE_GIT_BRANCH := unknown
49
50 OUTDIR:=out
51
52 outdirs += $(OUTDIR)
53
54 outfiles+=$(OUTDIR)/ble.sh
55 -include $(OUTDIR)/ble.dep
56 # Note: ble.sh depends on lib/init-cmap.sh and lib/init-bind.sh
57 # because it contains the hash of these files for the cache.
58 $(OUTDIR)/ble.sh: ble.pp GNUmakefile lib/init-cmap.sh lib/init-bind.sh | $(OUTDIR)
59 DEPENDENCIES_PHONY=1 DEPENDENCIES_OUTPUT="$(@:%.sh=%.dep)" DEPENDENCIES_TARGET="$@" \
60 FULLVER=$(FULLVER) \
61 BLE_GIT_COMMIT_ID="$(BLE_GIT_COMMIT_ID)" \
62 BLE_GIT_BRANCH="$(BLE_GIT_BRANCH)" \
63 BUILD_GIT_VERSION="$(GIT_VERSION)" \
64 BUILD_MAKE_VERSION="$(MAKE_VERSION)" \
65 BUILD_GAWK_VERSION="$(GAWK_VERSION)" \
66 $(MWGPP) $< >/dev/null
67 .DELETE_ON_ERROR: $(OUTDIR)/ble.sh
68
69 GENTABLE := bash make/canvas.c2w.generate-table.sh
70
71 src/canvas.c2w.sh:
72 $(GENTABLE) c2w
73 src/canvas.c2w.musl.sh: make/canvas.c2w.wcwidth.cpp make/canvas.c2w.wcwidth-musl.cpp
74 +make -C make canvas.c2w.wcwidth.exe
75 make/canvas.c2w.wcwidth.exe table_musl2014 | $(GENTABLE) convert-custom-c2w _ble_util_c2w_musl > $@
76 src/canvas.emoji.sh:
77 $(GENTABLE) emoji
78 src/canvas.GraphemeClusterBreak.sh:
79 $(GENTABLE) GraphemeClusterBreak
80
81 # Note: the following line is a workaround for the missing
82 # DEPENDENCIES_PHONY option for mwg_pp in older Makefile
83 ble-form.sh:
84
85 #------------------------------------------------------------------------------
86 # lib
87
88 outdirs += $(OUTDIR)/lib
89
90 # keymap
91 outfiles += $(OUTDIR)/lib/keymap.emacs.sh
92 outfiles += $(OUTDIR)/lib/keymap.vi.sh
93 outfiles += $(OUTDIR)/lib/keymap.vi_digraph.sh
94 outfiles += $(OUTDIR)/lib/keymap.vi_digraph.txt
95
96 # init
97 outfiles += $(OUTDIR)/lib/init-term.sh
98 outfiles += $(OUTDIR)/lib/init-bind.sh
99 outfiles += $(OUTDIR)/lib/init-cmap.sh
100 outfiles += $(OUTDIR)/lib/init-msys1.sh
101
102 # core
103 outfiles += $(OUTDIR)/lib/core-complete.sh
104 outfiles += $(OUTDIR)/lib/core-syntax.sh
105 outfiles += $(OUTDIR)/lib/core-test.sh
106 outfiles += $(OUTDIR)/lib/core-cmdspec.sh
107 outfiles += $(OUTDIR)/lib/core-debug.sh
108 outfiles += $(OUTDIR)/lib/core-edit.ignoreeof-messages.txt
109 outfiles += $(OUTDIR)/lib/core-decode.emacs-rlfunc.txt
110 outfiles += $(OUTDIR)/lib/core-decode.vi_imap-rlfunc.txt
111 outfiles += $(OUTDIR)/lib/core-decode.vi_nmap-rlfunc.txt
112
113 # vim
114 outfiles += $(OUTDIR)/lib/vim-surround.sh
115 outfiles += $(OUTDIR)/lib/vim-arpeggio.sh
116 outfiles += $(OUTDIR)/lib/vim-airline.sh
117
118 # test
119 outfiles += $(OUTDIR)/lib/test-bash.sh
120 outfiles += $(OUTDIR)/lib/test-main.sh
121 outfiles += $(OUTDIR)/lib/test-util.sh
122 outfiles += $(OUTDIR)/lib/test-canvas.sh
123 outfiles += $(OUTDIR)/lib/test-decode.sh
124 outfiles += $(OUTDIR)/lib/test-edit.sh
125 outfiles += $(OUTDIR)/lib/test-syntax.sh
126 outfiles += $(OUTDIR)/lib/test-complete.sh
127 outfiles += $(OUTDIR)/lib/test-keymap.vi.sh
128 outfiles += $(OUTDIR)/lib/util.bgproc.sh
129
130 $(OUTDIR)/lib/%.sh: lib/%.sh | $(OUTDIR)/lib
131 $(CP) $< $@
132 $(OUTDIR)/lib/%.txt: lib/%.txt | $(OUTDIR)/lib
133 $(CP) $< $@
134 $(OUTDIR)/lib/core-syntax.sh: lib/core-syntax.sh lib/core-syntax-ctx.def | $(OUTDIR)/lib
135 $(MWGPP) $< > $@
136 $(OUTDIR)/lib/init-msys1.sh: lib/init-msys1.sh lib/init-msys1-helper.c | $(OUTDIR)/lib
137 $(MWGPP) $< > $@
138 $(OUTDIR)/lib/test-canvas.sh: lib/test-canvas.sh lib/test-canvas.GraphemeClusterTest.sh | $(OUTDIR)/lib
139 $(MWGPP) $< > $@
140 $(OUTDIR)/lib/init-cmap.sh: lib/init-cmap.sh | $(OUTDIR)/lib
141 $(MWGPP) $< > $@
142 $(OUTDIR)/lib/init-bind.sh: lib/init-bind.sh | $(OUTDIR)/lib
143 $(MWGPP) $< > $@
144
145 outfiles += $(OUTDIR)/lib/benchmark.ksh
•146 $(OUTDIR)/lib/benchmark.ksh: lib/benchmark.ksh src/benchmark.sh | $(OUTDIR)/lib
147 $(MWGPP) $< > $@
148
149 #outfiles += $(OUTDIR)/lib/init-msleep.sh
150 #$(OUTDIR)/lib/init-msleep.sh: lib/init-msleep.sh lib/init-msleep.c | $(OUTDIR)/lib
151 # $(MWGPP) $< > $@
152
153 # いつか削除する
154 removedfiles += \
155 keymap/emacs.rlfunc.txt \
156 keymap/emacs.sh \
157 keymap/isearch.sh \
158 keymap/vi.sh \
159 keymap/vi_digraph.sh \
160 keymap/vi_digraph.txt \
161 keymap/vi_imap.rlfunc.txt \
162 keymap/vi_nmap.rlfunc.txt \
163 keymap/vi_test.sh \
164 lib/keymap.vi_test.sh
165
166 #------------------------------------------------------------------------------
167 # licenses and documents
168
169 outdirs += $(OUTDIR)/licenses $(OUTDIR)/doc
170 outfiles-license += $(OUTDIR)/licenses/LICENSE.md
171 ifneq ($(USE_DOC),no)
172 outfiles-doc += $(OUTDIR)/doc/README.md
173 outfiles-doc += $(OUTDIR)/doc/README-ja_JP.md
174 outfiles-doc += $(OUTDIR)/doc/CONTRIBUTING.md
175 outfiles-doc += $(OUTDIR)/doc/ChangeLog.md
176 outfiles-doc += $(OUTDIR)/doc/Release.md
177 endif
178
179 # Workaround for make-3.81 (#D2065)
180 #
181 # We want to do something like the following:
182 #
183 # $(OUTDIR)/license/%.md: %.md | $(OUTDIR)/license
184 # $(CP) $< $@
185 # $(OUTDIR)/doc/%.md: %.md | $(OUTDIR)/doc
186 # $(CP) $< $@
187 #
188 # However, because of a bug in make-3.81, this rule overrides all the other
189 # more detailed patterns such as $(OUTDIR)/doc/contrib/%.md. As a result, even
190 # when we want to apply preprocessing to specific file patterns under
191 # $(OUTDIR)/doc/%, $(CP) is always is used to install the files. To work
192 # around this problem in make-3.81, we need to manually filter the target files
193 # whose source files are at the top level in the source tree.
194 #
195 outfiles-doc-toplevel := \
196 $(filter $(outfiles-doc),$(patsubst %,$(OUTDIR)/doc/%,$(wildcard *.md)))
197 $(outfiles-doc-toplevel): $(OUTDIR)/doc/%.md: %.md | $(OUTDIR)/doc
198 $(CP) $< $@
199 outfiles-license-toplevel := \
200 $(filter $(outfiles-license),$(patsubst %,$(OUTDIR)/licenses/%,$(wildcard *.md)))
201 $(outfiles-license-toplevel): $(OUTDIR)/licenses/%.md: %.md | $(OUTDIR)/licenses
202 $(CP) $< $@
203
204 $(OUTDIR)/doc/%: docs/% | $(OUTDIR)/doc
205 $(CP) $< $@
206
207 #------------------------------------------------------------------------------
208 # contrib
209
210 .PHONY: update-contrib
211 update-contrib contrib/contrib.mk:
212 git submodule update --init --recursive
213
214 include contrib/contrib.mk
215
216 #------------------------------------------------------------------------------
217 # target "all"
218
219 $(outdirs):
220 mkdir -p $@
221
222 build: contrib/contrib.mk $(outfiles) $(outfiles-doc) $(outfiles-license)
223 .PHONY: build
224
225 all: build
226
227 #------------------------------------------------------------------------------
228 # target "install"
229
230 # Users can specify make variables INSDIR, INSDIR_LICENSE, and INSDIR_DOC to
231 # control the install locations. Instead of INSDIR, users may specify DESTDIR
232 # and/or PREFIX to automatically set up these variables.
233
234 ifneq ($(INSDIR),)
235 INSDIR_LICENSE := $(INSDIR)/licenses
236 INSDIR_DOC := $(INSDIR)/doc
237 else
238 ifneq ($(DESTDIR),)
239 DATADIR := $(abspath $(DESTDIR)/$(PREFIX)/share)
240 else ifneq ($(PREFIX),)
241 DATADIR := $(abspath $(PREFIX)/share)
242 else ifneq ($(XDG_DATA_HOME),)
243 DATADIR := $(abspath $(XDG_DATA_HOME))
244 else
245 DATADIR := $(abspath $(HOME)/.local/share)
246 endif
247
248 INSDIR := $(DATADIR)/blesh
249 INSDIR_LICENSE := $(DATADIR)/blesh/licenses
250 INSDIR_DOC := $(DATADIR)/doc/blesh
251 endif
252
253 ifneq ($(strip_comment),)
254 opt_strip_comment := --strip-comment=$(strip_comment)
255 else
256 opt_strip_comment :=
257 endif
258
259 insfiles := $(outfiles:$(OUTDIR)/%=$(INSDIR)/%)
260 insfiles-license := $(outfiles-license:$(OUTDIR)/licenses/%=$(INSDIR_LICENSE)/%)
261 insfiles-doc := $(outfiles-doc:$(OUTDIR)/doc/%=$(INSDIR_DOC)/%)
262
263 install-files := \
264 $(insfiles) $(insfiles-license) $(insfiles-doc) \
265 $(INSDIR)/cache.d $(INSDIR)/run
266 install: $(install-files)
267 uninstall:
268 bash make_command.sh uninstall $(install-files)
269 .PHONY: install uninstall
270
271 $(insfiles): $(INSDIR)/%: $(OUTDIR)/%
272 bash make_command.sh install $(opt_strip_comment) "$<" "$@"
273 $(insfiles-license): $(INSDIR_LICENSE)/%: $(OUTDIR)/licenses/%
274 bash make_command.sh install "$<" "$@"
275 $(insfiles-doc): $(INSDIR_DOC)/%: $(OUTDIR)/doc/%
276 bash make_command.sh install "$<" "$@"
277 $(INSDIR)/cache.d $(INSDIR)/run:
278 mkdir -p $@ && chmod a+rwxt $@
279
280 clean:
281 -rm -rf $(outfiles) $(outfiles-doc) $(outfiles-license) $(OUTDIR)/ble.dep
282 .PHONY: clean
283
284 dist: $(outfiles) $(outfiles-doc) $(outfiles-license)
285 FULLVER=$(FULLVER) bash make_command.sh dist $^
286 .PHONY: dist
287
288 dist_excludes= \
289 --exclude=./ble/backup \
290 --exclude=*~ \
291 --exclude=./ble/.git \
292 --exclude=./ble/out \
293 --exclude=./ble/dist \
294 --exclude=./ble/ble.sh
295 dist.date:
296 cd .. && tar cavf "$$(date +ble.%Y%m%d.tar.xz)" ./ble $(dist_excludes)
297 .PHONY: dist.date
298
299 #------------------------------------------------------------------------------
300
301 define DeclareMakeCommand
302 $1: $2
303 bash make_command.sh $1
304 .PHONY: $1
305 endef
306
307 $(eval $(call DeclareMakeCommand,ignoreeof-messages,))
308 $(eval $(call DeclareMakeCommand,scan,))
309 $(eval $(call DeclareMakeCommand,check,build))
310 $(eval $(call DeclareMakeCommand,check-all,build))
311 $(eval $(call DeclareMakeCommand,list-functions,))