sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

GNUmakefile (8868B)


      1 # -*- mode: makefile-gmake -*-
      2 
      3 all:
      4 .PHONY: all
      5 
      6 # check GNU Make
      7 ifeq ($(.FEATURES),)
      8   $(error Sorry, please use a newer version (3.81 or later) of gmake (GNU Make).)
      9 endif
     10 
     11 # check gawk
     12 GAWK := $(shell which gawk 2>/dev/null || type -p gawk 2>/dev/null)
     13 ifneq ($(GAWK),)
     14   GAWK_VERSION := $(shell LANG=C $(GAWK) --version 2>/dev/null | sed -n '1{/[Gg][Nn][Uu] [Aa][Ww][Kk]/p;}')
     15   ifeq ($(GAWK_VERSION),)
     16     $(error Sorry, gawk is found but does not seem to work. Please install a proper version of gawk (GNU Awk).)
     17   endif
     18 else
     19   GAWK := $(shell which awk 2>/dev/null || type -p awk 2>/dev/null)
     20   ifeq ($(GAWK),)
     21     $(error Sorry, gawk/awk could not be found. Please check your PATH environment variable.)
     22   endif
     23   GAWK_VERSION := $(shell LANG=C $(GAWK) --version 2>/dev/null | sed -n '1{/[Gg][Nn][Uu] [Aa][Ww][Kk]/p;}')
     24   ifeq ($(GAWK_VERSION),)
     25     $(error Sorry, gawk could not be found. Please install gawk (GNU Awk).)
     26   endif
     27 endif
     28 
     29 MWGPP:=$(GAWK) -f make/mwg_pp.awk
     30 
     31 # Note (): we had used "cp -p xxx out/xxx" to copy files to the build
     32 # directory, but some filesystem (ecryptfs) has a bug that the subsecond
     33 # timestamps are truncated causing an issue: make every time copies all the
     34 # files into the subdirectory `out`.  We give up using `cp -p` and instead copy
     35 # the file with `cp` with the timestamps being the copy time.
     36 CP := cp
     37 
     38 #------------------------------------------------------------------------------
     39 # ble.sh
     40 
     41 FULLVER := 0.4.0-devel4
     42 
     43 OUTDIR:=out
     44 
     45 outdirs += $(OUTDIR)
     46 
     47 # Note: the following line is a workaround for the missing
     48 #   DEPENDENCIES_PHONY option for mwg_pp in older Makefile
     49 ble-form.sh:
     50 
     51 outfiles+=$(OUTDIR)/ble.sh
     52 -include $(OUTDIR)/ble.dep
     53 $(OUTDIR)/ble.sh: ble.pp GNUmakefile | .git $(OUTDIR)
     54 	DEPENDENCIES_PHONY=1 DEPENDENCIES_OUTPUT="$(@:%.sh=%.dep)" DEPENDENCIES_TARGET="$@" \
     55 	  FULLVER=$(FULLVER) \
     56 	  BUILD_GIT_VERSION="$(shell LANG=C git --version)" \
     57 	  BUILD_MAKE_VERSION="$(shell LANG=C $(MAKE) --version | head -1)" \
     58 	  BUILD_GAWK_VERSION="$(GAWK_VERSION)" \
     59 	  $(MWGPP) $< >/dev/null
     60 .DELETE_ON_ERROR: $(OUTDIR)/ble.sh
     61 
     62 GENTABLE := bash make/canvas.c2w.generate-table.sh
     63 
     64 src/canvas.c2w.sh:
     65 	$(GENTABLE) c2w
     66 src/canvas.c2w.musl.sh: make/canvas.c2w.wcwidth.cpp make/canvas.c2w.wcwidth-musl.cpp
     67 	+make -C make canvas.c2w.wcwidth.exe
     68 	make/canvas.c2w.wcwidth.exe table_musl2014 | $(GENTABLE) convert-custom-c2w _ble_util_c2w_musl > $@
     69 src/canvas.emoji.sh:
     70 	$(GENTABLE) emoji
     71 src/canvas.GraphemeClusterBreak.sh:
     72 	$(GENTABLE) GraphemeClusterBreak
     73 
     74 #------------------------------------------------------------------------------
     75 # lib
     76 
     77 outdirs += $(OUTDIR)/lib
     78 
     79 # keymap
     80 outfiles += $(OUTDIR)/lib/keymap.emacs.sh
     81 outfiles += $(OUTDIR)/lib/keymap.vi.sh
     82 outfiles += $(OUTDIR)/lib/keymap.vi_digraph.sh
     83 outfiles += $(OUTDIR)/lib/keymap.vi_digraph.txt
     84 outfiles += $(OUTDIR)/lib/keymap.vi_test.sh
     85 
     86 # init
     87 outfiles += $(OUTDIR)/lib/init-term.sh
     88 outfiles += $(OUTDIR)/lib/init-bind.sh
     89 outfiles += $(OUTDIR)/lib/init-cmap.sh
     90 outfiles += $(OUTDIR)/lib/init-msys1.sh
     91 
     92 # core
     93 outfiles += $(OUTDIR)/lib/core-complete.sh
     94 outfiles += $(OUTDIR)/lib/core-syntax.sh
     95 outfiles += $(OUTDIR)/lib/core-test.sh
     96 outfiles += $(OUTDIR)/lib/core-cmdspec.sh
     97 outfiles += $(OUTDIR)/lib/core-debug.sh
     98 outfiles += $(OUTDIR)/lib/core-edit.ignoreeof-messages.txt
     99 outfiles += $(OUTDIR)/lib/core-decode.emacs-rlfunc.txt
    100 outfiles += $(OUTDIR)/lib/core-decode.vi_imap-rlfunc.txt
    101 outfiles += $(OUTDIR)/lib/core-decode.vi_nmap-rlfunc.txt
    102 
    103 # vim
    104 outfiles += $(OUTDIR)/lib/vim-surround.sh
    105 outfiles += $(OUTDIR)/lib/vim-arpeggio.sh
    106 outfiles += $(OUTDIR)/lib/vim-airline.sh
    107 
    108 # test
    109 outfiles += $(OUTDIR)/lib/test-bash.sh
    110 outfiles += $(OUTDIR)/lib/test-main.sh
    111 outfiles += $(OUTDIR)/lib/test-util.sh
    112 outfiles += $(OUTDIR)/lib/test-canvas.sh
    113 outfiles += $(OUTDIR)/lib/test-decode.sh
    114 outfiles += $(OUTDIR)/lib/test-edit.sh
    115 outfiles += $(OUTDIR)/lib/test-syntax.sh
    116 outfiles += $(OUTDIR)/lib/test-complete.sh
    117 outfiles += $(OUTDIR)/lib/util.bgproc.sh
    118 
    119 $(OUTDIR)/lib/%.sh: lib/%.sh | $(OUTDIR)/lib
    120 	$(CP) $< $@
    121 $(OUTDIR)/lib/%.txt: lib/%.txt | $(OUTDIR)/lib
    122 	$(CP) $< $@
    123 $(OUTDIR)/lib/core-syntax.sh: lib/core-syntax.sh lib/core-syntax-ctx.def | $(OUTDIR)/lib
    124 	$(MWGPP) $< > $@
    125 $(OUTDIR)/lib/init-msys1.sh: lib/init-msys1.sh lib/init-msys1-helper.c | $(OUTDIR)/lib
    126 	$(MWGPP) $< > $@
    127 $(OUTDIR)/lib/test-canvas.sh: lib/test-canvas.sh lib/test-canvas.GraphemeClusterTest.sh | $(OUTDIR)/lib
    128 	$(MWGPP) $< > $@
    129 
    130 outfiles += $(OUTDIR)/lib/benchmark.ksh
    131 $(OUTDIR)/lib/benchmark.ksh: lib/benchmark.ksh src/benchmark.sh
    132 	$(MWGPP) $< > $@
    133 
    134 #outfiles += $(OUTDIR)/lib/init-msleep.sh
    135 #$(OUTDIR)/lib/init-msleep.sh: lib/init-msleep.sh lib/init-msleep.c | $(OUTDIR)/lib
    136 #	$(MWGPP) $< > $@
    137 
    138 # いつか削除する
    139 removedfiles += \
    140   keymap/emacs.rlfunc.txt \
    141   keymap/emacs.sh \
    142   keymap/isearch.sh \
    143   keymap/vi.sh \
    144   keymap/vi_digraph.sh \
    145   keymap/vi_digraph.txt \
    146   keymap/vi_imap.rlfunc.txt \
    147   keymap/vi_nmap.rlfunc.txt \
    148   keymap/vi_test.sh
    149 
    150 #------------------------------------------------------------------------------
    151 # documents
    152 
    153 outdirs += $(OUTDIR)/doc
    154 outfiles-doc += $(OUTDIR)/doc/README.md
    155 outfiles-doc += $(OUTDIR)/doc/README-ja_JP.md
    156 outfiles-doc += $(OUTDIR)/doc/CONTRIBUTING.md
    157 outfiles-doc += $(OUTDIR)/doc/ChangeLog.md
    158 outfiles-doc += $(OUTDIR)/doc/Release.md
    159 outfiles-license += $(OUTDIR)/doc/LICENSE.md
    160 
    161 # Note #D2065: make-3.81 のバグにより以下の様に記述すると、より長く一致するパター
    162 # ンを持った規則よりも優先されてしまう。3.82 では問題は発生しない。% の代わりに
    163 # %.md にしたとしても、%.md が contrib/README.md 等に一致してしまう。仕方がない
    164 # ので $(OUTDIR)/doc/%: % に対応するファイルに関しては明示的に一つずつ記述する
    165 # 事にする。
    166 #
    167 #   $(OUTDIR)/doc/%: % | $(OUTDIR)/doc
    168 #   	$(CP) $< $@
    169 #
    170 # Workaround for make-3.81:
    171 $(OUTDIR)/doc/README.md: README.md | $(OUTDIR)/doc
    172 	$(CP) $< $@
    173 $(OUTDIR)/doc/README-ja_JP.md: README-ja_JP.md | $(OUTDIR)/doc
    174 	$(CP) $< $@
    175 $(OUTDIR)/doc/LICENSE.md: LICENSE.md | $(OUTDIR)/doc
    176 	$(CP) $< $@
    177 
    178 $(OUTDIR)/doc/%: docs/% | $(OUTDIR)/doc
    179 	$(CP) $< $@
    180 
    181 #------------------------------------------------------------------------------
    182 # contrib
    183 
    184 .PHONY: update-contrib
    185 update-contrib contrib/contrib.mk:
    186 	git submodule update --init --recursive
    187 
    188 include contrib/contrib.mk
    189 
    190 #------------------------------------------------------------------------------
    191 # target "all"
    192 
    193 $(outdirs):
    194 	mkdir -p $@
    195 
    196 build: contrib/contrib.mk $(outfiles) $(outfiles-doc) $(outfiles-license)
    197 .PHONY: build
    198 
    199 all: build
    200 
    201 #------------------------------------------------------------------------------
    202 # target "install"
    203 
    204 ifneq ($(INSDIR),)
    205   ifeq ($(INSDIR_DOC),)
    206     INSDIR_DOC := $(INSDIR)/doc
    207   endif
    208   ifeq ($(INSDIR_LICENSE),)
    209     INSDIR_LICENSE := $(INSDIR)/doc
    210   endif
    211 else
    212   ifneq ($(filter-out %/,$(DESTDIR)),)
    213     DESTDIR := $(DESTDIR)/
    214   endif
    215 
    216   ifneq ($(DESTDIR)$(PREFIX),)
    217     DATA_HOME := $(DESTDIR)$(PREFIX)/share
    218   else ifneq ($(XDG_DATA_HOME),)
    219     DATA_HOME := $(XDG_DATA_HOME)
    220   else
    221     DATA_HOME := $(HOME)/.local/share
    222   endif
    223 
    224   INSDIR = $(DATA_HOME)/blesh
    225   INSDIR_DOC = $(DATA_HOME)/doc/blesh
    226   INSDIR_LICENSE = $(DATA_HOME)/doc/blesh
    227 endif
    228 
    229 ifneq ($(strip_comment),)
    230   opt_strip_comment := --strip-comment=$(strip_comment)
    231 else
    232   opt_strip_comment :=
    233 endif
    234 
    235 install-files := \
    236   $(outfiles:$(OUTDIR)/%=$(INSDIR)/%) \
    237   $(outfiles-doc:$(OUTDIR)/doc/%=$(INSDIR_DOC)/%) \
    238   $(outfiles-license:$(OUTDIR)/doc/%=$(INSDIR_LICENSE)/%) \
    239   $(INSDIR)/cache.d $(INSDIR)/run
    240 install: $(install-files)
    241 uninstall:
    242 	bash make_command.sh uninstall $(install-files)
    243 .PHONY: install uninstall
    244 
    245 $(INSDIR)/%: $(OUTDIR)/%
    246 	bash make_command.sh install $(opt_strip_comment) "$<" "$@"
    247 $(INSDIR_DOC)/%: $(OUTDIR)/doc/%
    248 	bash make_command.sh install "$<" "$@"
    249 ifneq ($(INSDIR_DOC),$(INSDIR_LICENSE))
    250 $(INSDIR_LICENSE)/%: $(OUTDIR)/doc/%
    251 	bash make_command.sh install "$<" "$@"
    252 endif
    253 $(INSDIR)/cache.d $(INSDIR)/run:
    254 	mkdir -p $@ && chmod a+rwxt $@
    255 
    256 clean:
    257 	-rm -rf $(outfiles) $(outfiles-doc) $(outfiles-license) $(OUTDIR)/ble.dep
    258 .PHONY: clean
    259 
    260 dist: $(outfiles) $(outfiles-doc) $(outfiles-license)
    261 	FULLVER=$(FULLVER) bash make_command.sh dist $^
    262 .PHONY: dist
    263 
    264 dist_excludes= \
    265 	--exclude=./ble/backup \
    266 	--exclude=*~ \
    267 	--exclude=./ble/.git \
    268 	--exclude=./ble/out \
    269 	--exclude=./ble/dist \
    270 	--exclude=./ble/ble.sh
    271 dist.date:
    272 	cd .. && tar cavf "$$(date +ble.%Y%m%d.tar.xz)" ./ble $(dist_excludes)
    273 .PHONY: dist.date
    274 
    275 #------------------------------------------------------------------------------
    276 
    277 define DeclareMakeCommand
    278 $1: $2
    279 	bash make_command.sh $1
    280 .PHONY: $1
    281 endef
    282 
    283 $(eval $(call DeclareMakeCommand,ignoreeof-messages,))
    284 $(eval $(call DeclareMakeCommand,scan,))
    285 $(eval $(call DeclareMakeCommand,check,build))
    286 $(eval $(call DeclareMakeCommand,check-all,build))
    287 $(eval $(call DeclareMakeCommand,list-functions,))