From 6498a5d32de02297759c0db7df7e2ab2d5f5a031 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 10 Apr 2022 15:47:43 +0900 Subject: [PATCH] Makefile: add fallback Makefile for BSD make --- GNUmakefile | 98 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 110 ++++++++++------------------------------------------ 2 files changed, 118 insertions(+), 90 deletions(-) create mode 100644 GNUmakefile diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 00000000..be0864bd --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,98 @@ +# -*- mode: makefile-gmake -*- + +all: +.PHONY: all install dist + +# check GNU Make +ifeq ($(.FEATURES),) + $(error Sorry, please use a newer version of gmake (GNU Make).) +endif + +# check gawk +GAWK := $(shell which gawk 2>/dev/null || type -p gawk 2>/dev/null) +ifeq ($(GAWK),) + GAWK := $(shell which awk 2>/dev/null || type -p awk 2>/dev/null) + ifeq ($(GAWK),) + $(error Sorry, gawk/awk could not be found. Please check your PATH environment variable.) + endif + ifeq ($(shell $(GAWK) --version | grep -Fi 'GNU Awk'),) + $(error Sorry, gawk could not be found. Please install gawk (GNU Awk).) + endif +endif + +MWGPP:=$(GAWK) -f ext/mwg_pp.awk + +FULLVER:=0.2.6 + +OUTDIR:=out + +outdirs += $(OUTDIR) +outdirs += $(OUTDIR)/lib + +outfiles+=$(OUTDIR)/ble.sh +$(OUTDIR)/ble.sh: ble.pp ble-core.sh ble-decode.sh ble-edit.sh ble-color.sh ble-syntax-lazy.sh ble-form.sh | $(OUTDIR) + $(MWGPP) $< >/dev/null + +outfiles+=$(OUTDIR)/term.sh +$(OUTDIR)/term.sh: term.sh | $(OUTDIR) + cp -p $< $@ +outfiles+=$(OUTDIR)/bind.sh +$(OUTDIR)/bind.sh: bind.sh | $(OUTDIR) + cp -p $< $@ +outfiles+=$(OUTDIR)/lib/core-complete.sh +$(OUTDIR)/lib/core-complete.sh: lib/core-complete.sh | $(OUTDIR)/lib + cp -p $< $@ +outfiles+=$(OUTDIR)/lib/core-syntax.sh +$(OUTDIR)/lib/core-syntax.sh: lib/core-syntax.sh | $(OUTDIR)/lib + $(MWGPP) $< > $@ +outfiles+=$(OUTDIR)/ignoreeof-messages.txt +$(OUTDIR)/ignoreeof-messages.txt: ignoreeof-messages.txt | $(OUTDIR) + cp -p $< $@ + +outdirs += $(OUTDIR)/cmap +outfiles += $(OUTDIR)/cmap/default.sh +$(OUTDIR)/cmap/%.sh: cmap/%.sh | $(OUTDIR)/cmap + cp -p $< $@ + +outdirs += $(OUTDIR)/keymap +outfiles += $(OUTDIR)/keymap/emacs.sh +outfiles += $(OUTDIR)/keymap/vi.sh $(OUTDIR)/keymap/vi_digraph.sh $(OUTDIR)/keymap/vi_digraph.txt $(OUTDIR)/keymap/vi_test.sh +$(OUTDIR)/keymap/%.sh: keymap/%.sh | $(OUTDIR)/keymap + cp -p $< $@ +$(OUTDIR)/keymap/%.txt: keymap/%.txt | $(OUTDIR)/keymap + cp -p $< $@ + +outfiles += $(OUTDIR)/lib/vim-surround.sh +$(OUTDIR)/lib/%.sh: lib/%.sh | $(OUTDIR)/lib + cp -p $< $@ + +$(outdirs): + mkdir -p $@ +all: $(outfiles) + +DATA_HOME := $(XDG_DATA_HOME) +ifeq ($(DATA_HOME),) + DATA_HOME := $(HOME)/.local/share +endif +INSDIR = $(DATA_HOME)/blesh +install: $(outfiles:$(OUTDIR)/%=$(INSDIR)/%) $(INSDIR)/cache.d $(INSDIR)/tmp +$(INSDIR)/%: $(OUTDIR)/% + bash make_command.sh install "$<" "$@" +$(INSDIR)/cache.d $(INSDIR)/tmp: + mkdir -p $@ && chmod a+rwxt $@ + +dist: $(outfiles) + FULLVER=$(FULLVER) bash make_command.sh dist $^ + +dist_excludes= \ + --exclude=./ble/backup \ + --exclude=*~ \ + --exclude=./ble/.git \ + --exclude=./ble/out \ + --exclude=./ble/dist \ + --exclude=./ble/ble.sh +dist.date: + cd .. && tar cavf "$$(date +ble.%Y%m%d.tar.xz)" ./ble $(dist_excludes) + +list-functions: + awk '/^[[:space:]]*function[[:space:]]+/{sub(/^[[:space:]]*function[[:space:]]+/,"");sub(/[[:space:]]+\{.*$$/,"");print $$0}' ble.sh |sort diff --git a/Makefile b/Makefile index be0864bd..a3afc804 100644 --- a/Makefile +++ b/Makefile @@ -1,98 +1,28 @@ -# -*- mode: makefile-gmake -*- +# -*- mode: makefile-bsdmake -*- all: -.PHONY: all install dist +.PHONY: all install -# check GNU Make -ifeq ($(.FEATURES),) - $(error Sorry, please use a newer version of gmake (GNU Make).) -endif +.warning This is not GNU make. Plaese use GNU make (gmake). +.warning Trying to redirect to gmake... -# check gawk -GAWK := $(shell which gawk 2>/dev/null || type -p gawk 2>/dev/null) -ifeq ($(GAWK),) - GAWK := $(shell which awk 2>/dev/null || type -p awk 2>/dev/null) - ifeq ($(GAWK),) - $(error Sorry, gawk/awk could not be found. Please check your PATH environment variable.) - endif - ifeq ($(shell $(GAWK) --version | grep -Fi 'GNU Awk'),) - $(error Sorry, gawk could not be found. Please install gawk (GNU Awk).) - endif -endif +.ifdef INSDIR +assign_insdir := INSDIR="$(INSDIR)" +.endif -MWGPP:=$(GAWK) -f ext/mwg_pp.awk +.ifdef INSDIR_DOC +assign_insdir_doc := INSDIR_DOC="$(INSDIR_DOC)" +.endif -FULLVER:=0.2.6 +.ifdef PREFIX +assign_prefix := PREFIX="$(PREFIX)" +.endif -OUTDIR:=out +.ifdef DESTDIR +assign_destdir := DESTDIR="$(DESTDIR)" +.endif -outdirs += $(OUTDIR) -outdirs += $(OUTDIR)/lib - -outfiles+=$(OUTDIR)/ble.sh -$(OUTDIR)/ble.sh: ble.pp ble-core.sh ble-decode.sh ble-edit.sh ble-color.sh ble-syntax-lazy.sh ble-form.sh | $(OUTDIR) - $(MWGPP) $< >/dev/null - -outfiles+=$(OUTDIR)/term.sh -$(OUTDIR)/term.sh: term.sh | $(OUTDIR) - cp -p $< $@ -outfiles+=$(OUTDIR)/bind.sh -$(OUTDIR)/bind.sh: bind.sh | $(OUTDIR) - cp -p $< $@ -outfiles+=$(OUTDIR)/lib/core-complete.sh -$(OUTDIR)/lib/core-complete.sh: lib/core-complete.sh | $(OUTDIR)/lib - cp -p $< $@ -outfiles+=$(OUTDIR)/lib/core-syntax.sh -$(OUTDIR)/lib/core-syntax.sh: lib/core-syntax.sh | $(OUTDIR)/lib - $(MWGPP) $< > $@ -outfiles+=$(OUTDIR)/ignoreeof-messages.txt -$(OUTDIR)/ignoreeof-messages.txt: ignoreeof-messages.txt | $(OUTDIR) - cp -p $< $@ - -outdirs += $(OUTDIR)/cmap -outfiles += $(OUTDIR)/cmap/default.sh -$(OUTDIR)/cmap/%.sh: cmap/%.sh | $(OUTDIR)/cmap - cp -p $< $@ - -outdirs += $(OUTDIR)/keymap -outfiles += $(OUTDIR)/keymap/emacs.sh -outfiles += $(OUTDIR)/keymap/vi.sh $(OUTDIR)/keymap/vi_digraph.sh $(OUTDIR)/keymap/vi_digraph.txt $(OUTDIR)/keymap/vi_test.sh -$(OUTDIR)/keymap/%.sh: keymap/%.sh | $(OUTDIR)/keymap - cp -p $< $@ -$(OUTDIR)/keymap/%.txt: keymap/%.txt | $(OUTDIR)/keymap - cp -p $< $@ - -outfiles += $(OUTDIR)/lib/vim-surround.sh -$(OUTDIR)/lib/%.sh: lib/%.sh | $(OUTDIR)/lib - cp -p $< $@ - -$(outdirs): - mkdir -p $@ -all: $(outfiles) - -DATA_HOME := $(XDG_DATA_HOME) -ifeq ($(DATA_HOME),) - DATA_HOME := $(HOME)/.local/share -endif -INSDIR = $(DATA_HOME)/blesh -install: $(outfiles:$(OUTDIR)/%=$(INSDIR)/%) $(INSDIR)/cache.d $(INSDIR)/tmp -$(INSDIR)/%: $(OUTDIR)/% - bash make_command.sh install "$<" "$@" -$(INSDIR)/cache.d $(INSDIR)/tmp: - mkdir -p $@ && chmod a+rwxt $@ - -dist: $(outfiles) - FULLVER=$(FULLVER) bash make_command.sh dist $^ - -dist_excludes= \ - --exclude=./ble/backup \ - --exclude=*~ \ - --exclude=./ble/.git \ - --exclude=./ble/out \ - --exclude=./ble/dist \ - --exclude=./ble/ble.sh -dist.date: - cd .. && tar cavf "$$(date +ble.%Y%m%d.tar.xz)" ./ble $(dist_excludes) - -list-functions: - awk '/^[[:space:]]*function[[:space:]]+/{sub(/^[[:space:]]*function[[:space:]]+/,"");sub(/[[:space:]]+\{.*$$/,"");print $$0}' ble.sh |sort +all: + gmake -f GNUmakefile all +install: + gmake -f GNUmakefile install $(assign_insdir) $(assign_insdir_doc) $(assign_prefix) $(assign_destdir)