xref: /libCEED/common.mk (revision 6b5c14f77ab795bef5c65d6d90146e5779148744)
1777ff853SJeremy L Thompson# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2777ff853SJeremy L Thompson# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3777ff853SJeremy L Thompson# All Rights reserved. See files LICENSE and NOTICE for details.
4777ff853SJeremy L Thompson#
5777ff853SJeremy L Thompson# This file is part of CEED, a collection of benchmarks, miniapps, software
6777ff853SJeremy L Thompson# libraries and APIs for efficient high-order finite element and spectral
7777ff853SJeremy L Thompson# element discretizations for exascale applications. For more information and
8777ff853SJeremy L Thompson# source code availability see http://github.com/ceed.
9777ff853SJeremy L Thompson#
10777ff853SJeremy L Thompson# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11777ff853SJeremy L Thompson# a collaborative effort of two U.S. Department of Energy organizations (Office
12777ff853SJeremy L Thompson# of Science and the National Nuclear Security Administration) responsible for
13777ff853SJeremy L Thompson# the planning and preparation of a capable exascale ecosystem, including
14777ff853SJeremy L Thompson# software, applications, hardware, advanced system engineering and early
15777ff853SJeremy L Thompson# testbed platforms, in support of the nation's exascale computing imperative.
16777ff853SJeremy L Thompson
17777ff853SJeremy L Thompson# Output using the 216-color rules mode
18777ff853SJeremy L Thompsonrule_file = $(notdir $(1))
19777ff853SJeremy L Thompsonrule_path = $(patsubst %/,%,$(dir $(1)))
20777ff853SJeremy L Thompsonlast_path = $(notdir $(patsubst %/,%,$(dir $(1))))
21777ff853SJeremy L Thompsonansicolor = $(shell echo $(call last_path,$(1)) | cksum | cut -b1-2 | xargs -IS expr 2 \* S + 17)
22777ff853SJeremy L Thompsonemacs_out = @printf "  %10s %s/%s\n" $(1) $(call rule_path,$(2)) $(call rule_file,$(2))
23777ff853SJeremy L Thompsoncolor_out = @if [ -t 1 ]; then \
24777ff853SJeremy L Thompson				printf "  %10s \033[38;5;%d;1m%s\033[m/%s\n" \
25777ff853SJeremy L Thompson					$(1) $(call ansicolor,$(2)) \
26777ff853SJeremy L Thompson					$(call rule_path,$(2)) $(call rule_file,$(2)); else \
27777ff853SJeremy L Thompson				printf "  %10s %s\n" $(1) $(2); fi
28777ff853SJeremy L Thompson# if TERM=dumb, use it, otherwise switch to the term one
29777ff853SJeremy L Thompsonoutput = $(if $(TERM:dumb=),$(call color_out,$1,$2),$(call emacs_out,$1,$2))
30777ff853SJeremy L Thompson
31777ff853SJeremy L Thompson# if V is set to non-nil, turn the verbose mode
32777ff853SJeremy L Thompsonquiet = $(if $(V),$($(1)),$(call output,$1,$@);$($(1)))
33*6b5c14f7SJed Brown
34*6b5c14f7SJed Brown# make-4.3 allows string literals like "#include" in variables, but older versions need "\#include". Specifically, the following code:
35*6b5c14f7SJed Brown#
36*6b5c14f7SJed Brown# X := $(shell echo "#foo")
37*6b5c14f7SJed Brown#
38*6b5c14f7SJed Brown# works with make-4.3, but fails with previous versions:
39*6b5c14f7SJed Brown#
40*6b5c14f7SJed Brown# Makefile:1: *** unterminated call to function 'shell': missing ')'.  Stop.
41*6b5c14f7SJed Brown#
42*6b5c14f7SJed Brown# Older versions work if you spell it "\#foo", but 4.3 will include the backslash. We define $(HASH), which works consistently across versions.
43*6b5c14f7SJed BrownHASH := \#
44