@@ -163,70 +163,71 @@ else
163
163
$(Q)cp "$(VMLINUX_H)" $@
164
164
endif
165
165
166
- % .bpf.o : % .bpf.c $(INCLUDE_DIR ) /vmlinux.h scx_common.bpf.h user_exit_info.h \
166
+ $( SCXOBJ_DIR ) / % .bpf.o : % .bpf.c $(INCLUDE_DIR ) /vmlinux.h scx_common.bpf.h user_exit_info.h \
167
167
| $(BPFOBJ ) $(SCXOBJ_DIR )
168
- $(call msg,CLNG-BPF,,$@ )
169
- $(Q )$(CLANG ) $(BPF_CFLAGS ) -target bpf -c $< -o $(SCXOBJ_DIR ) /$@
170
-
171
- % .skel.h : % .bpf.o $(BPFTOOL )
172
- $(call msg,GEN-SKEL,,$@ )
173
- $(Q )$(BPFTOOL ) gen object $(SCXOBJ_DIR ) /$(<:.o=.linked1.o ) $(SCXOBJ_DIR ) /$<
174
- $(Q )$(BPFTOOL ) gen object $(SCXOBJ_DIR ) /$(<:.o=.linked2.o ) $(SCXOBJ_DIR ) /$(<:.o=.linked1.o )
175
- $(Q )$(BPFTOOL ) gen object $(SCXOBJ_DIR ) /$(<:.o=.linked3.o ) $(SCXOBJ_DIR ) /$(<:.o=.linked2.o )
176
- $(Q ) diff $(SCXOBJ_DIR ) /$(<:.o=.linked2.o ) $(SCXOBJ_DIR ) /$(<:.o=.linked3.o )
177
- $(Q )$(BPFTOOL ) gen skeleton $(SCXOBJ_DIR ) /$(<:.o=.linked3.o ) name $(<:.bpf.o= ) > $(INCLUDE_DIR ) /$@
178
- $(Q )$(BPFTOOL ) gen subskeleton $(SCXOBJ_DIR ) /$(<:.o=.linked3.o ) name $(<:.bpf.o= ) > $(INCLUDE_DIR ) /$(@:.skel.h=.subskel.h )
179
-
180
- define ccsched
181
- $(CC ) $(CFLAGS ) -c $(1 ) -o $(SCXOBJ_DIR ) /$(2 ) .o
182
- $(CC ) -o $(BINDIR ) /$(2 ) $(SCXOBJ_DIR ) /$(2 ) .o $(HOST_BPFOBJ ) $(LDFLAGS )
183
- endef
168
+ $(call msg,CLNG-BPF,,$(notdir $@ ) )
169
+ $(Q )$(CLANG ) $(BPF_CFLAGS ) -target bpf -c $< -o $@
170
+
171
+ $(INCLUDE_DIR ) /% .skel.h : $(SCXOBJ_DIR ) /% .bpf.o $(INCLUDE_DIR ) /vmlinux.h $(BPFTOOL )
172
+ $(eval sched=$(notdir $@ ) )
173
+ $(call msg,GEN-SKEL,,$(sched ) )
174
+ $(Q )$(BPFTOOL ) gen object $(<:.o=.linked1.o ) $<
175
+ $(Q )$(BPFTOOL ) gen object $(<:.o=.linked2.o ) $(<:.o=.linked1.o )
176
+ $(Q )$(BPFTOOL ) gen object $(<:.o=.linked3.o ) $(<:.o=.linked2.o )
177
+ $(Q ) diff $(<:.o=.linked2.o ) $(<:.o=.linked3.o )
178
+ $(Q )$(BPFTOOL ) gen skeleton $(<:.o=.linked3.o ) name $(subst .skel.h,,$(sched ) ) > $@
179
+ $(Q )$(BPFTOOL ) gen subskeleton $(<:.o=.linked3.o ) name $(subst .skel.h,,$(sched ) ) > $(@:.skel.h=.subskel.h )
184
180
185
181
SCX_COMMON_DEPS := user_exit_info.h scx_user_common.h | $(BINDIR )
186
- scx_simple : scx_simple.c scx_simple.skel.h $(SCX_COMMON_DEPS )
187
- $(call ccsched,$< ,$@ )
188
-
189
- scx_qmap : scx_qmap.c scx_qmap.skel.h $(SCX_COMMON_DEPS )
190
- $(call ccsched,$< ,$@ )
191
182
192
- scx_central : scx_central.c scx_central.skel.h $(SCX_COMMON_DEPS )
193
- $(call ccsched,$< ,$@ )
183
+ # ###############
184
+ # C schedulers #
185
+ # ###############
186
+ c-sched-targets = scx_qmap scx_simple scx_central scx_pair scx_flatcg scx_userland
194
187
195
- scx_pair : scx_pair.c scx_pair.skel.h $(SCX_COMMON_DEPS )
196
- $(call ccsched,$< ,$@ )
188
+ $(addprefix $(BINDIR ) /,$(c-sched-targets ) ) : \
189
+ $(BINDIR ) /%: \
190
+ $(filter-out % .bpf.c,% .c) \
191
+ $(INCLUDE_DIR ) /%.skel.h \
192
+ $(SCX_COMMON_DEPS )
193
+ $(eval sched=$(notdir $@ ) )
194
+ $(CC ) $(CFLAGS ) -c $(sched ) .c -o $(SCXOBJ_DIR ) /$(sched ) .o
195
+ $(CC ) -o $@ $(SCXOBJ_DIR ) /$(sched ) .o $(HOST_BPFOBJ ) $(LDFLAGS )
196
+ $(c-sched-targets ) : % : $(BINDIR ) /%
197
197
198
- scx_flatcg : scx_flatcg.c scx_flatcg.skel.h $(SCX_COMMON_DEPS )
199
- $(call ccsched,$< ,$@ )
200
198
201
- scx_userland : scx_userland.c scx_userland.skel.h scx_userland.h $(SCX_COMMON_DEPS )
202
- $(call ccsched,$< ,$@ )
199
+ # ##################
200
+ # Rust schedulers #
201
+ # ##################
202
+ rust-sched-targets := scx_rusty
203
203
204
204
# Separate build target that is available for build systems to use to fetch
205
205
# dependencies in a separate step from building. This allows the scheduler
206
206
# to be compiled without network access.
207
207
#
208
- # If the scx_rusty Make target is invoked without CARGO_OFFLINE=1 (e.g. if
209
- # building locally), then cargo build will download all of the necessary
210
- # dependencies, and scx_rusty_deps can be skipped.
211
- scx_rusty_deps :
212
- cargo fetch --manifest-path=scx_rusty/Cargo.toml
213
-
214
- scx_rusty : export RUSTFLAGS = -C link-args=-lzstd -C link-args=-lz -C link-args=-lelf -L $(BPFOBJ_DIR )
215
- scx_rusty : export SCX_RUSTY_CLANG = $(CLANG )
216
- scx_rusty : export SCX_RUSTY_BPF_CFLAGS = $(BPF_CFLAGS )
217
- scx_rusty : $(INCLUDE_DIR ) /vmlinux.h $(SCX_COMMON_DEPS )
218
- cargo build --manifest-path=$@ /Cargo.toml $(CARGOFLAGS )
219
- $(Q ) cp $(OUTPUT_DIR ) /release/$@ $(BINDIR ) /$@
208
+ # If the regular rust scheduler Make target (e.g. scx_rusty) is invoked without
209
+ # CARGO_OFFLINE=1 (e.g. if building locally), then cargo build will download
210
+ # all of the necessary dependencies, and the deps target can be skipped.
211
+ $(addsuffix _deps,$(rust-sched-targets ) ) :
212
+ $(Q ) cargo fetch --manifest-path=scx_rusty/Cargo.toml
213
+
214
+ $(rust-sched-targets ) : % : $(INCLUDE_DIR ) /vmlinux.h $(SCX_COMMON_DEPS )
215
+ $(eval export RUSTFLAGS = -C link-args=-lzstd -C link-args=-lz -C link-args=-lelf -L $(BPFOBJ_DIR ) )
216
+ $(eval export SCX_RUST_CLANG = $(CLANG ) )
217
+ $(eval export SCX_RUST_BPF_CFLAGS= $(BPF_CFLAGS ) )
218
+ $(eval sched=$(notdir $@ ) )
219
+ $(Q ) cargo build --manifest-path=$(sched ) /Cargo.toml $(CARGOFLAGS )
220
+ $(Q ) cp $(OUTPUT_DIR ) /release/$(sched ) $(BINDIR ) /$@
220
221
221
222
install : all
222
223
$(Q ) mkdir -p $(DESTDIR ) /usr/bin/
223
224
$(Q ) cp $(BINDIR ) /* $(DESTDIR ) /usr/bin/
224
225
225
226
clean :
226
- cargo clean --manifest-path=scx_rusty /Cargo.toml
227
+ $( foreach sched, $( rust-sched-targets ) , cargo clean --manifest-path=$( sched ) /Cargo.toml;)
227
228
rm -rf $(OUTPUT_DIR ) $(HOST_OUTPUT_DIR )
228
229
rm -f * .o * .bpf.o * .skel.h * .subskel.h
229
- rm -f scx_simple scx_qmap scx_central scx_pair scx_flatcg scx_userland
230
+ rm -f $( c-sched-targets )
230
231
231
232
fullclean : clean
232
233
$(Q )$(MAKE ) -sC ../../ clean
@@ -290,7 +291,7 @@ help:
290
291
@echo ' rust files for rust schedulers, and also trigger a'
291
292
@echo ' clean of the kernel at the root of the whole repository.'
292
293
293
- .PHONY : all scx_rusty clean fullclean help
294
+ .PHONY : all $( c-sched-targets ) $( rust-sched-targets ) clean fullclean help
294
295
295
296
# delete failed targets
296
297
.DELETE_ON_ERROR :
0 commit comments