Debian Codegraph @

GNUmakefile

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 # -*- mode: makefile-gmake -*-
2
3 all:
4 .PHONY: all
5
6 # git version
7 GIT_VERSION = $(shell LANG=C git --version)
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 :=
48 BLE_GIT_BRANCH :=
49 ifneq ($(wildcard .git),)
50 BLE_GIT_COMMIT_ID := $(shell git show -s --format=%h)
51 BLE_GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
52 else ifneq ($(wildcard make/.git-archive-export.mk),)
53 ifeq ($(shell grep '\$$Format:.*\$$' make/.git-archive-export.mk),)
54 include make/.git-archive-export.mk
55 endif
56 endif
57 ifeq ($(BLE_GIT_COMMIT_ID),)
58 $(error Failed to determine the commit id of the current tree. The .git directory is required to build ble.sh.)
59 endif
60
61 OUTDIR:=out
62
63 outdirs += $(OUTDIR)
64
65 outfiles+=$(OUTDIR)/ble.sh
66 -include $(OUTDIR)/ble.dep
67 # Note: ble.sh depends on lib/init-cmap.sh and lib/init-bind.sh
68 # because it contains the hash of these files for the cache.
69 $(OUTDIR)/ble.sh: ble.pp GNUmakefile lib/init-cmap.sh lib/init-bind.sh | $(OUTDIR)
70 DEPENDENCIES_PHONY=1 DEPENDENCIES_OUTPUT="$(@:%.sh=%.dep)" DEPENDENCIES_TARGET="$@" \
71 FULLVER=$(FULLVER) \
72 BLE_GIT_COMMIT_ID="$(BLE_GIT_COMMIT_ID)" \
73 BLE_GIT_BRANCH="$(BLE_GIT_BRANCH)" \
74 BUILD_GIT_VERSION="$(GIT_VERSION)" \
75 BUILD_MAKE_VERSION="$(MAKE_VERSION)" \
76 BUILD_GAWK_VERSION="$(GAWK_VERSION)" \
77 $(MWGPP) $< >/dev/null
78 .DELETE_ON_ERROR: $(OUTDIR)/ble.sh
79
80 GENTABLE := bash make/canvas.c2w.generate-table.sh
81
82 src/canvas.c2w.sh:
83 $(GENTABLE) c2w
84 src/canvas.c2w.musl.sh: make/canvas.c2w.wcwidth.cpp make/canvas.c2w.wcwidth-musl.cpp
85 +make -C make canvas.c2w.wcwidth.exe
86 make/canvas.c2w.wcwidth.exe table_musl2014 | $(GENTABLE) convert-custom-c2w _ble_util_c2w_musl > $@
87 src/canvas.emoji.sh:
88 $(GENTABLE) emoji
89 src/canvas.GraphemeClusterBreak.sh:
90 $(GENTABLE) GraphemeClusterBreak
91
92 # Note: the following line is a workaround for the missing
93 # DEPENDENCIES_PHONY option for mwg_pp in older Makefile
94 ble-form.sh:
95
96 #------------------------------------------------------------------------------
97 # lib
98
99 outdirs += $(OUTDIR)/lib
100
101 # keymap
102 outfiles += $(OUTDIR)/lib/keymap.emacs.sh
103 outfiles += $(OUTDIR)/lib/keymap.vi.sh
104 outfiles += $(OUTDIR)/lib/keymap.vi_digraph.sh
105 outfiles += $(OUTDIR)/lib/keymap.vi_digraph.txt
106
107 # init
108 outfiles += $(OUTDIR)/lib/init-term.sh
109 outfiles += $(OUTDIR)/lib/init-bind.sh
110 outfiles += $(OUTDIR)/lib/init-cmap.sh
111 outfiles += $(OUTDIR)/lib/init-msys1.sh
112
113 # core
114 outfiles += $(OUTDIR)/lib/core-complete.sh
115 outfiles += $(OUTDIR)/lib/core-syntax.sh
116 outfiles += $(OUTDIR)/lib/core-test.sh
117 outfiles += $(OUTDIR)/lib/core-cmdspec.sh
118 outfiles += $(OUTDIR)/lib/core-debug.sh
119 outfiles += $(OUTDIR)/lib/core-edit.ignoreeof-messages.txt
120 outfiles += $(OUTDIR)/lib/core-decode.emacs-rlfunc.txt
121 outfiles += $(OUTDIR)/lib/core-decode.vi_imap-rlfunc.txt
122 outfiles += $(OUTDIR)/lib/core-decode.vi_nmap-rlfunc.txt
123
124 # vim
125 outfiles += $(OUTDIR)/lib/vim-surround.sh
126 outfiles += $(OUTDIR)/lib/vim-arpeggio.sh
127 outfiles += $(OUTDIR)/lib/vim-airline.sh
128
129 # test
130 outfiles += $(OUTDIR)/lib/test-bash.sh
131 outfiles += $(OUTDIR)/lib/test-main.sh
132 outfiles += $(OUTDIR)/lib/test-util.sh
133 outfiles += $(OUTDIR)/lib/test-canvas.sh
134 outfiles += $(OUTDIR)/lib/test-decode.sh
135 outfiles += $(OUTDIR)/lib/test-edit.sh
136 outfiles += $(OUTDIR)/lib/test-syntax.sh
137 outfiles += $(OUTDIR)/lib/test-complete.sh
138 outfiles += $(OUTDIR)/lib/test-keymap.vi.sh
139 outfiles += $(OUTDIR)/lib/util.bgproc.sh
140
141 $(OUTDIR)/lib/%.sh: lib/%.sh | $(OUTDIR)/lib
142 $(CP) $< $@
143 $(OUTDIR)/lib/%.txt: lib/%.txt | $(OUTDIR)/lib
144 $(CP) $< $@
145 $(OUTDIR)/lib/core-syntax.sh: lib/core-syntax.sh lib/core-syntax-ctx.def | $(OUTDIR)/lib
146 $(MWGPP) $< > $@
147 $(OUTDIR)/lib/init-msys1.sh: lib/init-msys1.sh lib/init-msys1-helper.c | $(OUTDIR)/lib
148 $(MWGPP) $< > $@
149 $(OUTDIR)/lib/test-canvas.sh: lib/test-canvas.sh lib/test-canvas.GraphemeClusterTest.sh | $(OUTDIR)/lib
150 $(MWGPP) $< > $@
151 $(OUTDIR)/lib/init-cmap.sh: lib/init-cmap.sh | $(OUTDIR)/lib
152 $(MWGPP) $< > $@
153 $(OUTDIR)/lib/init-bind.sh: lib/init-bind.sh | $(OUTDIR)/lib
154 $(MWGPP) $< > $@
155
156 outfiles += $(OUTDIR)/lib/benchmark.ksh
157 $(OUTDIR)/lib/benchmark.ksh: lib/benchmark.ksh src/benchmark.sh
158 $(MWGPP) $< > $@
159
160 #outfiles += $(OUTDIR)/lib/init-msleep.sh
161 #$(OUTDIR)/lib/init-msleep.sh: lib/init-msleep.sh lib/init-msleep.c | $(OUTDIR)/lib
162 # $(MWGPP) $< > $@
163
164 # いつか削除する
165 removedfiles += \
166 keymap/emacs.rlfunc.txt \
167 keymap/emacs.sh \
168 keymap/isearch.sh \
169 keymap/vi.sh \
170 keymap/vi_digraph.sh \
171 keymap/vi_digraph.txt \
172 keymap/vi_imap.rlfunc.txt \
173 keymap/vi_nmap.rlfunc.txt \
174 keymap/vi_test.sh \
175 lib/keymap.vi_test.sh
176
177 #------------------------------------------------------------------------------
178 # licenses and documents
179
180 outdirs += $(OUTDIR)/licenses $(OUTDIR)/doc
181 outfiles-license += $(OUTDIR)/licenses/LICENSE.md
182 ifneq ($(USE_DOC),no)
183 outfiles-doc += $(OUTDIR)/doc/README.md
184 outfiles-doc += $(OUTDIR)/doc/README-ja_JP.md
185 outfiles-doc += $(OUTDIR)/doc/CONTRIBUTING.md
186 outfiles-doc += $(OUTDIR)/doc/ChangeLog.md
187 outfiles-doc += $(OUTDIR)/doc/Release.md
188 endif
189
190 # Workaround for make-3.81 (#D2065)
191 #
192 # We want to do something like the following:
193 #
194 # $(OUTDIR)/license/%.md: %.md | $(OUTDIR)/license
195 # $(CP) $< $@
196 # $(OUTDIR)/doc/%.md: %.md | $(OUTDIR)/doc
197 # $(CP) $< $@
198 #
199 # However, because of a bug in make-3.81, this rule overrides all the other
200 # more detailed patterns such as $(OUTDIR)/doc/contrib/%.md. As a result, even
201 # when we want to apply preprocessing to specific file patterns under
202 # $(OUTDIR)/doc/%, $(CP) is always is used to install the files. To work
203 # around this problem in make-3.81, we need to manually filter the target files
204 # whose source files are at the top level in the source tree.
205 #
206 outfiles-doc-toplevel := \
207 $(filter $(outfiles-doc),$(patsubst %,$(OUTDIR)/doc/%,$(wildcard *.md)))
208 $(outfiles-doc-toplevel): $(OUTDIR)/doc/%.md: %.md | $(OUTDIR)/doc
209 $(CP) $< $@
210 outfiles-license-toplevel := \
211 $(filter $(outfiles-license),$(patsubst %,$(OUTDIR)/licenses/%,$(wildcard *.md)))
212 $(outfiles-license-toplevel): $(OUTDIR)/licenses/%.md: %.md | $(OUTDIR)/licenses
213 $(CP) $< $@
214
215 $(OUTDIR)/doc/%: docs/% | $(OUTDIR)/doc
216 $(CP) $< $@
217
218 #------------------------------------------------------------------------------
219 # contrib
220
221 .PHONY: update-contrib
222 update-contrib contrib/contrib.mk:
223 git submodule update --init --recursive
224
225 include contrib/contrib.mk
226
227 #------------------------------------------------------------------------------
228 # target "all"
229
230 $(outdirs):
231 mkdir -p $@
232
233 build: contrib/contrib.mk $(outfiles) $(outfiles-doc) $(outfiles-license)
234 .PHONY: build
235
236 all: build
237
238 #------------------------------------------------------------------------------
239 # target "install"
240
241 # Users can specify make variables INSDIR, INSDIR_LICENSE, and INSDIR_DOC to
242 # control the install locations. Instead of INSDIR, users may specify DESTDIR
243 # and/or PREFIX to automatically set up these variables.
244
245 ifneq ($(INSDIR),)
246 INSDIR_LICENSE := $(INSDIR)/licenses
247 INSDIR_DOC := $(INSDIR)/doc
248 else
249 ifneq ($(DESTDIR),)
250 DATADIR := $(abspath $(DESTDIR)/$(PREFIX)/share)
251 else ifneq ($(PREFIX),)
252 DATADIR := $(abspath $(PREFIX)/share)
253 else ifneq ($(XDG_DATA_HOME),)
254 DATADIR := $(abspath $(XDG_DATA_HOME))
255 else
256 DATADIR := $(abspath $(HOME)/.local/share)
257 endif
258
259 INSDIR := $(DATADIR)/blesh
260 INSDIR_LICENSE := $(DATADIR)/blesh/licenses
261 INSDIR_DOC := $(DATADIR)/doc/blesh
262 endif
263
264 ifneq ($(strip_comment),)
265 opt_strip_comment := --strip-comment=$(strip_comment)
266 else
267 opt_strip_comment :=
268 endif
269
270 insfiles := $(outfiles:$(OUTDIR)/%=$(INSDIR)/%)
271 insfiles-license := $(outfiles-license:$(OUTDIR)/licenses/%=$(INSDIR_LICENSE)/%)
272 insfiles-doc := $(outfiles-doc:$(OUTDIR)/doc/%=$(INSDIR_DOC)/%)
273
274 install-files := \
275 $(insfiles) $(insfiles-license) $(insfiles-doc) \
276 $(INSDIR)/cache.d $(INSDIR)/run
277 install: $(install-files)
278 uninstall:
279 bash make_command.sh uninstall $(install-files)
280 .PHONY: install uninstall
281
282 $(insfiles): $(INSDIR)/%: $(OUTDIR)/%
283 bash make_command.sh install $(opt_strip_comment) "$<" "$@"
284 $(insfiles-license): $(INSDIR_LICENSE)/%: $(OUTDIR)/licenses/%
285 bash make_command.sh install "$<" "$@"
286 $(insfiles-doc): $(INSDIR_DOC)/%: $(OUTDIR)/doc/%
287 bash make_command.sh install "$<" "$@"
288 $(INSDIR)/cache.d $(INSDIR)/run:
289 mkdir -p $@ && chmod a+rwxt $@
290
291 clean:
292 -rm -rf $(outfiles) $(outfiles-doc) $(outfiles-license) $(OUTDIR)/ble.dep
293 .PHONY: clean
294
295 dist: $(outfiles) $(outfiles-doc) $(outfiles-license)
296 FULLVER=$(FULLVER) bash make_command.sh dist $^
297 .PHONY: dist
298
299 dist_excludes= \
300 --exclude=./ble/backup \
301 --exclude=*~ \
302 --exclude=./ble/.git \
303 --exclude=./ble/out \
304 --exclude=./ble/dist \
305 --exclude=./ble/ble.sh
306 dist.date:
307 cd .. && tar cavf "$$(date +ble.%Y%m%d.tar.xz)" ./ble $(dist_excludes)
308 .PHONY: dist.date
309
310 #------------------------------------------------------------------------------
311
312 define DeclareMakeCommand
313 $1: $2
314 bash make_command.sh $1
315 .PHONY: $1
316 endef
317
318 $(eval $(call DeclareMakeCommand,ignoreeof-messages,))
319 $(eval $(call DeclareMakeCommand,scan,))
320 $(eval $(call DeclareMakeCommand,check,build))
321 $(eval $(call DeclareMakeCommand,check-all,build))
322 $(eval $(call DeclareMakeCommand,list-functions,))