16
16
# limitations under the License.
17
17
# /
18
18
19
+
19
20
# VARIABLES #
20
21
21
22
ifndef VERBOSE
22
23
QUIET := @
23
- else
24
- QUIET :=
25
24
endif
26
25
27
- # Determine the OS ([1][1], [2][2]).
26
+ # Determine the OS:
28
27
#
29
28
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
30
29
# [2]: http://stackoverflow.com/a/27776822/2225624
@@ -37,10 +36,6 @@ ifneq (, $(findstring MSYS,$(OS)))
37
36
else
38
37
ifneq (, $(findstring CYGWIN,$(OS ) ) )
39
38
OS := WINNT
40
- else
41
- ifneq (, $(findstring Windows_NT,$(OS ) ) )
42
- OS := WINNT
43
- endif
44
39
endif
45
40
endif
46
41
endif
@@ -59,7 +54,7 @@ CFLAGS ?= \
59
54
-Wall \
60
55
-pedantic
61
56
62
- # Determine whether to generate position independent code ([1 ][1], [2][2]).
57
+ # Determine whether to generate [ position independent code][1]:
63
58
#
64
59
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
65
60
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
69
64
fPIC ?= -fPIC
70
65
endif
71
66
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
-
84
67
# List of C targets:
85
68
c_targets := benchmark.out
86
69
87
70
88
- # RULES #
71
+ # TARGETS #
89
72
90
- # /
91
- # Compiles source files.
73
+ # Default target.
92
74
#
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`)
100
- #
101
- # @example
102
- # make
103
- #
104
- # @example
105
- # make all
106
- # /
75
+ # This target is the default target.
76
+
107
77
all : $(c_targets )
108
78
109
79
.PHONY : all
110
80
111
- # /
112
- # Compiles C source files .
81
+
82
+ # Compile C source.
113
83
#
114
- # @private
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`)
122
- # /
84
+ # This target compiles C source files.
85
+
123
86
$(c_targets ) : % .out: % .c
124
- $(QUIET ) $(CC ) $(CFLAGS ) $(fPIC ) $( INCLUDE ) -o $@ $( SOURCE_FILES ) $< $( LIBPATH ) -lm $( LIBRARIES )
87
+ $(QUIET ) $(CC ) $(CFLAGS ) $(fPIC ) -o $@ $< -lm
125
88
126
- # /
127
- # Runs compiled benchmarks .
89
+
90
+ # Run a benchmark .
128
91
#
129
- # @example
130
- # make run
131
- # /
92
+ # This target runs a benchmark.
93
+
132
94
run : $(c_targets )
133
95
$(QUIET ) ./$<
134
96
135
97
.PHONY : run
136
98
137
- # /
138
- # Removes generated files .
99
+
100
+ # Perform clean-up .
139
101
#
140
- # @example
141
- # make clean
142
- # /
102
+ # This target removes generated files.
103
+
143
104
clean :
144
105
$(QUIET ) -rm -f * .o * .out
145
106
146
- .PHONY : clean
107
+ .PHONY : clean
0 commit comments