Skip to content

Commit eb88d43

Browse files
committed
build: add separate configurations for benchmarks and examples
1 parent d35c90c commit eb88d43

File tree

3 files changed

+275
-17
lines changed

3 files changed

+275
-17
lines changed

lib/node_modules/@stdlib/blas/base/sasum/benchmark/c/Makefile

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,17 @@ else
6969
fPIC ?= -fPIC
7070
endif
7171

72+
# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
73+
INCLUDE ?=
74+
7275
# List of source files:
73-
c_src := ../../src/sasum.c
76+
SOURCE_FILES ?=
77+
78+
# List of libraries (e.g., `-lopenblas -lpthread`):
79+
LIBRARIES ?=
80+
81+
# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
82+
LIBPATH ?=
7483

7584
# List of C targets:
7685
c_targets := benchmark.length.out
@@ -79,11 +88,15 @@ c_targets := benchmark.length.out
7988
# RULES #
8089

8190
#/
82-
# Compiles C source files.
91+
# Compiles source files.
8392
#
8493
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
8594
# @param {string} [CFLAGS] - C compiler options
86-
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`)
95+
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
96+
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
97+
# @param {string} [SOURCE_FILES] - list of source files
98+
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
99+
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
87100
#
88101
# @example
89102
# make
@@ -99,12 +112,16 @@ all: $(c_targets)
99112
# Compiles C source files.
100113
#
101114
# @private
102-
# @param {string} CC - C compiler
103-
# @param {string} CFLAGS - C compiler flags
104-
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
115+
# @param {string} CC - C compiler (e.g., `gcc`)
116+
# @param {string} CFLAGS - C compiler options
117+
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
118+
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
119+
# @param {string} SOURCE_FILES - list of source files
120+
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
121+
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
105122
#/
106123
$(c_targets): %.out: %.c
107-
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm
124+
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)
108125

109126
#/
110127
# Runs compiled benchmarks.

lib/node_modules/@stdlib/blas/base/sasum/examples/c/Makefile

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,17 @@ else
6969
fPIC ?= -fPIC
7070
endif
7171

72+
# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
73+
INCLUDE ?=
74+
7275
# List of source files:
73-
c_src := ../../src/sasum.c
76+
SOURCE_FILES ?=
77+
78+
# List of libraries (e.g., `-lopenblas -lpthread`):
79+
LIBRARIES ?=
80+
81+
# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
82+
LIBPATH ?=
7483

7584
# List of C targets:
7685
c_targets := example.out
@@ -79,11 +88,15 @@ c_targets := example.out
7988
# RULES #
8089

8190
#/
82-
# Compiles C source files.
91+
# Compiles source files.
8392
#
8493
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
8594
# @param {string} [CFLAGS] - C compiler options
86-
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`)
95+
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
96+
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
97+
# @param {string} [SOURCE_FILES] - list of source files
98+
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
99+
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
87100
#
88101
# @example
89102
# make
@@ -99,15 +112,19 @@ all: $(c_targets)
99112
# Compiles C source files.
100113
#
101114
# @private
102-
# @param {string} CC - C compiler
103-
# @param {string} CFLAGS - C compiler flags
104-
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
115+
# @param {string} CC - C compiler (e.g., `gcc`)
116+
# @param {string} CFLAGS - C compiler options
117+
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
118+
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
119+
# @param {string} SOURCE_FILES - list of source files
120+
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
121+
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
105122
#/
106123
$(c_targets): %.out: %.c
107-
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm
124+
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)
108125

109126
#/
110-
# Runs compiled benchmarks.
127+
# Runs compiled examples.
111128
#
112129
# @example
113130
# make run

0 commit comments

Comments
 (0)