"Fossies" - the Fresh Open Source Software Archive

Member "argbash-2.10.0/resources/Makefile" (22 Sep 2020, 8323 Bytes) of package /linux/privat/argbash-2.10.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "Makefile": 2.9.0_vs_2.10.0.

    1 NUL =
    2 
    3 # SC2015: Note that A && B || C is not if-then-else. C may run when A is true.
    4 SHELLCHECK_EXCLUDE_CHECKS_ARGUMENT = -e 2015
    5 
    6 SHELLCHECK = $(shell shellcheck -V > /dev/null && echo "shellcheck -x $(SHELLCHECK_EXCLUDE_CHECKS_ARGUMENT)")
    7 
    8 DEFINE_SCRIPT_DIR_FORM ?= DEFINE_SCRIPT_DIR$(shell readlink -e /dev/null > /dev/null && echo "_GNU")
    9 
   10 M4_SRC = \
   11 	../src/output-strip-none.m4 \
   12 	../src/output-strip-user-content.m4 \
   13 	../src/output-strip-all.m4 \
   14 	../src/argbash-lib.m4 \
   15 	../src/version \
   16 	$(NUL)
   17 
   18 M4_SRC += \
   19 	../src/output-bash-script.m4 \
   20 	../src/output-completion.m4 \
   21 	../src/output-docopt.m4 \
   22 	../src/output-manpage.m4 \
   23 	../src/output-manpage-defs.m4 \
   24 	../src/output-posix-script.m4 \
   25 	$(NUL)
   26 
   27 # generate using
   28 # grep '^m4_include' ../src/*.m4 | sed -e 's/.*m4_include(\[\(.*\)\])\s*/\t..\/src\/\1 \\/' | sort | uniq
   29 # which outputs all files that are included using m4_include in .m4 files
   30 M4_SRC += \
   31 	../src/argument_value_types.m4 \
   32 	../src/collectors.m4 \
   33 	../src/constants.m4 \
   34 	../src/default_settings.m4 \
   35 	../src/docopt.m4 \
   36 	../src/env_vars.m4 \
   37 	../src/function_generators.m4 \
   38 	../src/list.m4 \
   39 	../src/progs.m4 \
   40 	../src/stuff.m4 \
   41 	../src/utilities.m4 \
   42 	../src/value_validators.m4 \
   43 	$(NUL)
   44 
   45 PREFIX ?= $(HOME)/.local
   46 PREFIXED_LIBDIR ?= $(PREFIX)/lib
   47 SYSCONFDIR ?= /etc
   48 BASH_COMPLETION_DIRECTORY ?= $(SYSCONFDIR)/bash_completion.d
   49 ROOT ?= /
   50 
   51 A_INIT = ../bin/argbash-init
   52 GENPARSE = ../bin/argbash
   53 COMPLETION = argbash
   54 INSTALL_COMPLETION ?= no
   55 ARGBASH_EXEC ?= $(GENPARSE)
   56 ARGBASH_INIT_EXEC ?= $(A_INIT)
   57 EXAMPLES = \
   58 	examples/minimal.sh \
   59 	examples/simple.sh \
   60 	examples/simple-wrapper.sh \
   61 	$(NUL)
   62 
   63 ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
   64 MANPAGE = argbash.1.gz
   65 
   66 $(GENPARSE): ../src/argbash.m4 $(M4_SRC)
   67 	ARGBASH_INTENDED_DESTINATION="$@" bash $(GENPARSE) $< -o argbash.temp && mv argbash.temp $@
   68 
   69 # TODO: Figure out how to use the GNU version of DEFINE_SCRIPT_DIR based on autodetection.
   70 ../src/argbash.m4.script-dir: ../src/argbash.m4
   71 	sed "s/\\bDEFINE_SCRIPT_DIR\\b/$(DEFINE_SCRIPT_DIR_FORM)/" $< > $@
   72 
   73 $(A_INIT): ../src/argbash-init.m4 $(GENPARSE)
   74 	$(GENPARSE) $< -o $@
   75 
   76 $(COMPLETION): ../src/argbash.m4 $(GENPARSE)
   77 	$(GENPARSE) $< --type completion --strip all -o $@
   78 
   79 major_version ?= $(shell cat ../src/version | sed -e 's/\..*//')
   80 
   81 ../bin/argbash-%to$(major_version): ../src/argbash-%to$(major_version).m4 $(GENPARSE)
   82 	$(ARGBASH_EXEC) $< -o $@
   83 
   84 lesser_versions = $(shell seq 1 $$(($(major_version) - 1)))
   85 ARGBASH_TO = $(foreach ver,$(lesser_versions),../bin/argbash-$(ver)to$(major_version))
   86 
   87 CHANGELOG = ../ChangeLog
   88 
   89 %-standalone.sh: %-standalone.m4 $(GENPARSE)
   90 	$(ARGBASH_EXEC) $< -o $@ --strip user-content
   91 
   92 # argbash-init uses the -parsing suffix to denote standalone parsing sections of scripts
   93 %-parsing.sh: %-parsing.m4 $(GENPARSE)
   94 	$(ARGBASH_EXEC) $< -o $@ --strip user-content
   95 
   96 %-standalone2.sh: %-standalone.sh $(GENPARSE)
   97 	$(ARGBASH_EXEC) $< -o $@ --strip user-content
   98 
   99 %.sh: %.m4 $(GENPARSE)
  100 	$(ARGBASH_EXEC) $< -o $@
  101 
  102 %2.sh: %.sh $(GENPARSE)
  103 	$(ARGBASH_EXEC) $< -o $@
  104 
  105 %3.sh: %2.sh $(GENPARSE)
  106 	$(ARGBASH_EXEC) $< -o $@
  107 
  108 examples/minimal.sh: examples/minimal.m4
  109 	$(ARGBASH_EXEC) $< -c -o $@
  110 
  111 # Must be included AFTER we have rules for .sh stuff
  112 TESTDIR = ../tests/regressiontests
  113 
  114 include ../tests/regressiontests/Makefile
  115 
  116 
  117 # We include the source dir because there is m4_include in argbash-lib.m4
  118 bootstrap:
  119 	cat ../src/argbash-lib.m4 ../src/output-strip-none.m4 ../src/argbash.m4 | autom4te -I ../src -l m4sugar -o $(GENPARSE)
  120 	chmod a+x $(GENPARSE)
  121 	touch ../src/argbash.m4
  122 
  123 examples: $(EXAMPLES)
  124 
  125 check: $(TESTDIR)/Makefile $(GENPARSE) $(A_INIT) $(ARGBASH_TO)
  126 	$(MAKE) unittests
  127 	$(MAKE) regressiontests
  128 	$(MAKE) tests-clean
  129 	test -z "$(SHELLCHECK)" || $(SHELLCHECK) $(ARGBASH_BIN)
  130 	test -z "$(SHELLCHECK)" || $(SHELLCHECK) $(ARGBASH_INIT)
  131 	test -z "$(SHELLCHECK)" || $(SHELLCHECK) $(ARGBASH_TO)
  132 	@echo "*** All is OK ***"
  133 
  134 # TODO: Think out how to make a multiline foreach
  135 unittests:
  136 	$(foreach testfile,$(wildcard ../tests/unittests/check-*.m4),autom4te -l m4sugar -I ../src/ -I ../tests/unittests $(testfile) &&) true
  137 
  138 develop: $(ARGBASH_TO)
  139 	@echo Installing to prefix "'/$(PREFIX)' of root $(ROOT)"
  140 	mkdir -p "$(ROOT)/$(PREFIX)/bin"
  141 	touch "$(ROOT)/$(PREFIX)/bin/argbash" && rm "$(ROOT)/$(PREFIX)/bin/argbash"
  142 	echo '#!/bin/bash' > "$(ROOT)/$(PREFIX)/bin/argbash"
  143 	echo '$(abspath $(ROOT_DIR)/$(GENPARSE)) "$$@"' >> "$(ROOT)/$(PREFIX)/bin/argbash"
  144 	chmod a+x "$(ROOT)/$(PREFIX)/bin/argbash"
  145 	test -z "$(ARGBASH_TO)" || ln -s $(abspath $(ARGBASH_TO)) "$(ROOT)/$(PREFIX)/bin"
  146 	ln -s $(abspath $(A_INIT)) "$(ROOT)/$(PREFIX)/bin"
  147 
  148 # Parse the version file and expose version numbers as variables
  149 # that are available in targets that have this target as prerequisite
  150 define-version:
  151 	$(eval VERSION_PATCH := $(shell cut -f 3 -d . ../src/version))
  152 	$(eval VERSION_MINOR := $(shell cut -f 2 -d . ../src/version))
  153 	$(eval VERSION_MAJOR := $(shell cut -f 1 -d . ../src/version))
  154 	$(eval VERSION_SUFFIX := -$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH))
  155 
  156 argbash.rst: ../src/argbash.m4 $(ARGBASH_EXEC)
  157 	$(ARGBASH_EXEC) --type manpage --strip all -o $@ $<
  158 
  159 man: $(MANPAGE)
  160 
  161 $(MANPAGE): argbash.rst argbash-defs.rst
  162 	rst2man $< | gzip > $@
  163 
  164 install: $(GENPARSE) $(A_INIT) $(ARGBASH_TO) $(COMPLETION) $(MANPAGE)
  165 	@echo Installing to prefix "'/$(PREFIX)' of root $(ROOT)"
  166 	mkdir -p "$(ROOT)/$(PREFIX)/bin"
  167 	touch "$(ROOT)/$(PREFIX)/bin/argbash$(VERSION_SUFFIX)"
  168 	mkdir -p "$(ROOT)/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)"
  169 	touch "$(ROOT)/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)/argbash-lib.m4"
  170 	cp -p $(M4_SRC) "$(ROOT)/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)/"
  171 	grep -q 'm4dir=' $(GENPARSE) && sed -e 's|m4dir=.*|m4dir=/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)|' $(GENPARSE) > "$(ROOT)/$(PREFIX)/bin/argbash$(VERSION_SUFFIX)"
  172 	test -n "$(VERSION_SUFFIX)" || test -z "$(ARGBASH_TO)" || { cp -p $(ARGBASH_TO) "$(ROOT)/$(PREFIX)/bin" && chmod a+x "$(ROOT)/$(PREFIX)"/bin/argbash-*; }
  173 	cp -p $(A_INIT) "$(ROOT)/$(PREFIX)/bin/argbash-init$(VERSION_SUFFIX)" && chmod a+x "$(ROOT)/$(PREFIX)"/bin/argbash-init$(VERSION_SUFFIX)
  174 	chmod a+x "$(ROOT)/$(PREFIX)/bin/argbash$(VERSION_SUFFIX)"
  175 	test "$(INSTALL_COMPLETION)" = "no" || (mkdir -p "$(ROOT)/$(BASH_COMPLETION_DIRECTORY)" && mv "$(COMPLETION)" "$(ROOT)/$(BASH_COMPLETION_DIRECTORY)/")
  176 	mkdir -p "$(ROOT)/$(PREFIX)/share/man/man1/"
  177 	cp -p $(MANPAGE) "$(ROOT)/$(PREFIX)/share/man/man1/"
  178 
  179 altpreclean: define-version
  180 	$(RM) "$(ROOT)/$(PREFIX)/bin/argbash-$(VERSION_MAJOR).$(VERSION_MINOR)"
  181 	$(RM) "$(ROOT)/$(PREFIX)/bin/argbash-$(VERSION_MAJOR)"
  182 	$(RM) "$(ROOT)/$(PREFIX)/bin/argbash"
  183 
  184 altinstall: altpreclean install
  185 	ln -s "$(ROOT)/$(PREFIX)/bin/argbash$(VERSION_SUFFIX)" "$(ROOT)/$(PREFIX)/bin/argbash-$(VERSION_MAJOR).$(VERSION_MINOR)"
  186 	ln -s "$(ROOT)/$(PREFIX)/bin/argbash-$(VERSION_MAJOR).$(VERSION_MINOR)" "$(ROOT)/$(PREFIX)/bin/argbash-$(VERSION_MAJOR)"
  187 	ln -s "$(ROOT)/$(PREFIX)/bin/argbash-$(VERSION_MAJOR)" "$(ROOT)/$(PREFIX)/bin/argbash"
  188 
  189 uninstall:
  190 	$(RM) "$(ROOT)/$(PREFIX)/bin/argbash"
  191 	$(RM) "$(ROOT)/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)/"*.m4
  192 	$(RM) "$(ROOT)/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)/version"
  193 	$(RM) "$(ROOT)/$(PREFIX)"/bin/argbash-*
  194 	rmdir "$(ROOT)/$(PREFIXED_LIBDIR)/argbash$(VERSION_SUFFIX)"
  195 	$(RM) "$(ROOT)/$(BASH_COMPLETION_DIRECTORY)/$(COMPLETION)"
  196 	$(RM) "$(ROOT)/$(PREFIX)/share/man/man1/$(MANPAGE)"
  197 
  198 altuninstall: define-version uninstall
  199 
  200 version:
  201 	@test -n '$(VERSION)' || { echo "You have to specify a version string, for example 'make version VERSION=1.0.0'"; exit 1; }
  202 	echo '$(VERSION)' > ../src/version
  203 	sed -i "1s/.*/$(VERSION) ($$(date -I))/" $(CHANGELOG)
  204 	touch $(M4_SRC)
  205 
  206 ../docker/Dockerfile: ../docker/Dockerfile.in
  207 	cat "$<" | sed -e "s/@VERSION@/$(shell cat ../src/version)/g; s/@NOW@/$(shell date -Iseconds)/" > "$@"
  208 
  209 release: version $(GENPARSE) $(ARGBASH_TO) examples check
  210 	sed -i "1s/([-0-9]+)/($$(date -I))/" $(CHANGELOG)
  211 	cd ../doc && $(MAKE) clean && $(MAKE) html && $(MAKE) clean-tmp
  212 
  213 tag:
  214 	git tag $(shell cat ../src/version) -s -m 'Version release' master
  215 	git push --follow-tags
  216 
  217 # Update using
  218 # grep '^[-a-z]*:' Makefile | cut -f 1 -d ':' | sort | tr '\n' ' '
  219 .PHONY: altinstall altpreclean bootstrap check check-shellcheck define-version develop examples install man release tag uninstall unittests version