diff options
Diffstat (limited to 'lib/make/make.config.rules.in')
-rw-r--r-- | lib/make/make.config.rules.in | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/make/make.config.rules.in b/lib/make/make.config.rules.in index cec72a91..caef245d 100644 --- a/lib/make/make.config.rules.in +++ b/lib/make/make.config.rules.in @@ -83,6 +83,12 @@ define CXX_DEPENDENCIES $(DEPENDENCY_FIXER) endef +define CL_DEPENDENCIES +# An OpenCL source file has no external dependencies + $(CL_DEPEND) $< $(CL_DEPEND_OUT) + $(DEPENDENCY_FIXER) +endef + define CU_DEPENDENCIES $(CU_DEPEND) $< $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE $(CU_DEPEND_OUT) $(DEPENDENCY_FIXER) @@ -149,6 +155,26 @@ define POSTPROCESS_CXX $(CXX_POSTPROCESSING) endef +# Define how to do an OpenCL compilation +define PREPROCESS_CL +# Wrap the OpenCL source code into a string, using the thorn name and +# file name to create a variable name, and create a C file +{ \ + echo 'char const *const OpenCL_source_$(THORN)_$* ='; \ + sed -e 's/\\/\\\\/g;s/"/\\"/g;s/\(.*\)/"\1\\n"/g'; \ + echo ';'; \ +} < $^ > $(notdir $<).c +endef + +define COMPILE_CL +# Basically a C compile, but with a different source file name +current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(CC) $(CPPFLAGS) $(CFLAGS) $(CCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(notdir $<).c $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE +endef + +define POSTPROCESS_CL +$(CL_POSTPROCESSING) +endef + # Define how to do a CUDA compilation define PREPROCESS_CU { if test $(C_LINE_DIRECTIVES) = 'yes'; then echo '#line 1 "'$<'"'; fi; cat $<; } | $(PERL) -s $(C_FILE_PROCESSOR) -line_directives=$(C_LINE_DIRECTIVES) -source_file_name=$< $(CONFIG) > $(notdir $<) @@ -283,6 +309,20 @@ endef %.cxx.d: $(SRCDIR)/%.cxx $(CXX_DEPENDENCIES) +# Build rules for OpenCL + +%.cl.o: $(SRCDIR)/%.cl + $(NOTIFY_PREPROCESSING) + $(PREPROCESS_CL) + $(NOTIFY_COMPILING) + $(COMPILE_CL) + $(NOTIFY_POSTPROCESSING) + $(POSTPROCESS_CL) + $(NOTIFY_DIVIDER) + +%.cl.d: $(SRCDIR)/%.cl + $(CL_DEPENDENCIES) + # Build rules for CUDA %.cu.o: $(SRCDIR)/%.cu |