16
16
# limitations under the License.
17
17
# /
18
18
19
-
20
19
# VARIABLES #
21
20
22
21
ifndef VERBOSE
70
69
fPIC ?= -fPIC
71
70
endif
72
71
72
+ # List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
73
+ INCLUDE ?=
74
+
75
+ # List of source files:
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 ?=
83
+
73
84
# List of C targets:
74
85
c_targets := benchmark.out
75
86
76
87
77
88
# RULES #
78
89
79
90
# /
80
- # Compiles C source files.
91
+ # Compiles source files.
81
92
#
82
- # @param {string} [C_COMPILER] - C compiler
83
- # @param {string} [CFLAGS] - C compiler flags
84
- # @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code
93
+ # @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
94
+ # @param {string} [CFLAGS] - C compiler options
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`)
85
100
#
86
101
# @example
87
102
# make
@@ -97,12 +112,16 @@ all: $(c_targets)
97
112
# Compiles C source files.
98
113
#
99
114
# @private
100
- # @param {string} CC - C compiler
101
- # @param {string} CFLAGS - C compiler flags
102
- # @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`)
103
122
# /
104
123
$(c_targets ) : % .out: % .c
105
- $(QUIET ) $(CC ) $(CFLAGS ) $(fPIC ) -o $@ $< -lm
124
+ $(QUIET ) $(CC ) $(CFLAGS ) $(fPIC ) $( INCLUDE ) -o $@ $( SOURCE_FILES ) $< $( LIBPATH ) -lm $( LIBRARIES )
106
125
107
126
# /
108
127
# Runs compiled benchmarks.
0 commit comments