...

Text file src/github.com/datawire/ambassador/v2/build-aux/common.mk

Documentation: github.com/datawire/ambassador/v2/build-aux

     1# Copyright 2018 Datawire. All rights reserved.
     2#
     3# Makefile snippet for bits common bits we "always" want.
     4#
     5## Eager inputs ##
     6#  (none)
     7## Lazy inputs ##
     8#  (none)
     9## Outputs ##
    10#  - Variable: GOOS
    11#  - Variable: GOARCH
    12#  - .PHONY Target: all
    13#  - .PHONY Target: build
    14#  - .PHONY Target: check
    15#  - .PHONY Target: lint
    16#  - .PHONY Target: format
    17#  - .PHONY Target: clean
    18#  - .PHONY Target: clobber
    19## common.mk targets ##
    20#  (N/A)
    21ifeq ($(words $(filter $(abspath $(lastword $(MAKEFILE_LIST))),$(abspath $(MAKEFILE_LIST)))),1)
    22_common.mk := $(lastword $(MAKEFILE_LIST))
    23include $(dir $(_common.mk))prelude.mk
    24
    25#
    26# Variables
    27
    28# Possible values of GOOS/GOARCH:
    29# https://golang.org/doc/install/source#environment
    30export GOOS   = $(call lazyonce,_GOOS,$(shell go env GOOS))
    31export GOARCH = $(call lazyonce,_GOARCH,$(shell go env GOARCH))
    32
    33#
    34# User-facing targets
    35
    36# To the extent reasonable, use target names that agree with the GNU
    37# standards.
    38#
    39# https://www.gnu.org/prep/standards/standards.html#Makefile-Conventions
    40
    41all: build
    42.PHONY: all
    43
    44build: ## (Common) Build the software
    45.PHONY: build
    46
    47check: ## (Common) Check whether the software works; run the tests
    48.PHONY: check
    49
    50lint: ## (Common) Perform static analysis of the software
    51.PHONY: lint
    52
    53format: ## (Common) Apply automatic formatting+cleanup to source code
    54.PHONY: format
    55
    56clean: ## (Common) Delete all files that are normally created by building the software
    57.PHONY: clean
    58# XXX: Rename this to maintainer-clean, per GNU?
    59clobber: ## (Common) Delete all files that this Makefile can re-generate
    60clobber: clean
    61.PHONY: clobber
    62
    63#
    64# Targets: Default behavior
    65
    66clean: _common_clean
    67_common_clean:
    68	rm -f test-suite.tap
    69.PHONY: _common_clean
    70
    71check: lint build
    72	$(MAKE) -f $(firstword $(MAKEFILE_LIST)) test-suite.tap.summary
    73test-suite.tap: $(tools/tap-driver)
    74	@$(tools/tap-driver) cat $(sort $(filter %.tap,$^)) > $@
    75
    76%.tap.summary: %.tap $(tools/tap-driver)
    77	@$(tools/tap-driver) summarize $<
    78
    79%.tap: %.tap.gen $(tools/tap-driver) FORCE
    80	@{ $(abspath $<) || true; } 2>&1 | tee $@ | $(tools/tap-driver) stream -n $<
    81%.log: %.test FORCE
    82	@$(abspath $<) >$@ 2>&1; echo :exit-status: $$? >>$@
    83%.tap: %.log %.test $(tools/tap-driver)
    84	@{ \
    85		printf '%s\n' 'TAP version 13' '1..1' && \
    86		sed 's/^/#/' < $< && \
    87		sed -n '$${ s/^:exit-status: 0$$/ok 1/; s/^:exit-status: 77$$/ok 1 # SKIP/; s/^:exit-status: .*/not ok 1/; p; }' < $<; \
    88	} | tee $@ | $(tools/tap-driver) stream -n $*.test
    89
    90endif

View as plain text