xref: /libCEED/rust/libceed-sys/c-src/common.mk (revision c4016ce5e01824a90bfdd2159ea8004eb7b29eef)
1# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3# All Rights reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.
9#
10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11# a collaborative effort of two U.S. Department of Energy organizations (Office
12# of Science and the National Nuclear Security Administration) responsible for
13# the planning and preparation of a capable exascale ecosystem, including
14# software, applications, hardware, advanced system engineering and early
15# testbed platforms, in support of the nation's exascale computing imperative.
16
17# Output using the 216-color rules mode
18rule_file = $(notdir $(1))
19rule_path = $(patsubst %/,%,$(dir $(1)))
20last_path = $(notdir $(patsubst %/,%,$(dir $(1))))
21ansicolor = $(shell echo $(call last_path,$(1)) | cksum | cut -b1-2 | xargs -IS expr 2 \* S + 17)
22emacs_out = @printf "  %10s %s/%s\n" $(1) $(call rule_path,$(2)) $(call rule_file,$(2))
23color_out = @if [ -t 1 ]; then \
24				printf "  %10s \033[38;5;%d;1m%s\033[m/%s\n" \
25					$(1) $(call ansicolor,$(2)) \
26					$(call rule_path,$(2)) $(call rule_file,$(2)); else \
27				printf "  %10s %s\n" $(1) $(2); fi
28# if TERM=dumb, use it, otherwise switch to the term one
29output = $(if $(TERM:dumb=),$(call color_out,$1,$2),$(call emacs_out,$1,$2))
30
31# if V is set to non-nil, turn the verbose mode
32quiet = $(if $(V),$($(1)),$(call output,$1,$@);$($(1)))
33
34# make-4.3 allows string literals like "#include" in variables, but older versions need "\#include". Specifically, the following code:
35#
36# X := $(shell echo "#foo")
37#
38# works with make-4.3, but fails with previous versions:
39#
40# Makefile:1: *** unterminated call to function 'shell': missing ')'.  Stop.
41#
42# Older versions work if you spell it "\#foo", but 4.3 will include the backslash. We define $(HASH), which works consistently across versions.
43HASH := \#
44