|
| 1 | +#/ |
| 2 | +# @license Apache-2.0 |
| 3 | +# |
| 4 | +# Copyright (c) 2018 The Stdlib Authors. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +#/ |
| 18 | + |
| 19 | +# VARIABLES # |
| 20 | + |
| 21 | +# Define the path to a script for compiling a C example: |
| 22 | +compile_c_example_bin := $(TOOLS_DIR)/scripts/compile_c_example |
| 23 | + |
| 24 | + |
| 25 | +# RULES # |
| 26 | + |
| 27 | +#/ |
| 28 | +# Runs C examples consecutively. |
| 29 | +# |
| 30 | +# ## Notes |
| 31 | +# |
| 32 | +# - The recipe delegates to local Makefiles which are responsible for actually compiling and running the respective examples. |
| 33 | +# - This rule is useful when wanting to glob for C examples files (e.g., run all C examples for a particular package). |
| 34 | +# |
| 35 | +# |
| 36 | +# @param {string} [EXAMPLES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) |
| 37 | +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) |
| 38 | +# @param {string} [BLAS] - BLAS library name (e.g., `openblas`) |
| 39 | +# @param {string} [BLAS_DIR] - BLAS directory |
| 40 | +# |
| 41 | +# @example |
| 42 | +# make examples-c |
| 43 | +# |
| 44 | +# @example |
| 45 | +# make examples-c EXAMPLES_FILTER=.*/math/base/special/abs/.* |
| 46 | +#/ |
| 47 | +examples-c: |
| 48 | + $(QUIET) $(FIND_C_EXAMPLES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \ |
| 49 | + echo ""; \ |
| 50 | + echo "Running example: $$file"; \ |
| 51 | + cd `dirname $$file` && $(MAKE) clean && \ |
| 52 | + OS="$(OS)" \ |
| 53 | + NODE="$(NODE)" \ |
| 54 | + NODE_PATH="$(NODE_PATH)" \ |
| 55 | + C_COMPILER="$(CC)" \ |
| 56 | + BLAS="$(BLAS)" \ |
| 57 | + BLAS_DIR="$(BLAS_DIR)" \ |
| 58 | + CEPHES="$(DEPS_CEPHES_BUILD_OUT)" \ |
| 59 | + CEPHES_SRC="$(DEPS_CEPHES_SRC)" \ |
| 60 | + "${compile_c_example_bin}" $$file && \ |
| 61 | + $(MAKE) run || exit 1; \ |
| 62 | + done |
| 63 | + |
| 64 | +.PHONY: examples-c |
| 65 | + |
| 66 | +#/ |
| 67 | +# Runs a specified list of C examples consecutively. |
| 68 | +# |
| 69 | +# ## Notes |
| 70 | +# |
| 71 | +# - The recipe delegates to local Makefiles which are responsible for actually compiling and running the respective examples. |
| 72 | +# - This rule is useful when wanting to run a list of C examples files generated by some other command (e.g., a list of changed C examples files obtained via `git diff`). |
| 73 | +# |
| 74 | +# |
| 75 | +# @param {string} FILES - list of C example file paths |
| 76 | +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) |
| 77 | +# @param {string} [BLAS] - BLAS library name (e.g., `openblas`) |
| 78 | +# @param {string} [BLAS_DIR] - BLAS directory |
| 79 | +# |
| 80 | +# @example |
| 81 | +# make examples-c-files FILES='/foo/example.c /bar/example.c' |
| 82 | +#/ |
| 83 | +examples-c-files: |
| 84 | + $(QUIET) for file in $(FILES); do \ |
| 85 | + echo ""; \ |
| 86 | + echo "Running example: $$file"; \ |
| 87 | + cd `dirname $$file` && $(MAKE) clean && \ |
| 88 | + OS="$(OS)" \ |
| 89 | + NODE="$(NODE)" \ |
| 90 | + NODE_PATH="$(NODE_PATH)" \ |
| 91 | + C_COMPILER="$(CC)" \ |
| 92 | + BLAS="$(BLAS)" \ |
| 93 | + BLAS_DIR="$(BLAS_DIR)" \ |
| 94 | + CEPHES="$(DEPS_CEPHES_BUILD_OUT)" \ |
| 95 | + CEPHES_SRC="$(DEPS_CEPHES_SRC)" \ |
| 96 | + "${compile_c_example_bin}" $$file && \ |
| 97 | + $(MAKE) run || exit 1; \ |
| 98 | + done |
| 99 | + |
| 100 | +.PHONY: example-c-files |
0 commit comments