This repository has been archived by the owner on Aug 11, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update makefile example for PkgConfig support (#135)
- Loading branch information
1 parent
e996669
commit fff421f
Showing
1 changed file
with
16 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
# Example Makefile to build a SYCL application using ComputeCpp. | ||
CXXFLAGS += -std=c++11 `pkg-config --cflags computecpp` | ||
LDFLAGS += `pkg-config --libs computecpp` | ||
SYCLFLAGS += `pkg-config computecpp --variable device_cflags` | ||
SYCLCXX ?= `pkg-config computecpp --variable device_compiler` | ||
|
||
# Your ComputeCpp installation root. | ||
COMPUTECPP_PREFIX ?= /usr/local | ||
EXECUTABLE = app | ||
|
||
COMPUTECPP ?= $(COMPUTECPP_PREFIX)/bin/compute++ | ||
COMPUTECPP_INFO ?= $(COMPUTECPP_PREFIX)/bin/computecpp_info | ||
COMPUTECPP_INCLUDES ?= $(COMPUTECPP_PREFIX)/include | ||
COMPUTECPP_LIBS ?= $(COMPUTECPP_PREFIX)/lib | ||
all : $(EXECUTABLE) | ||
|
||
# In addition your normal flags, compilation requires C++11 standard, | ||
# the SYCL headers, and the ComputeCpp library. | ||
CXXFLAGS += --std=c++11 -I$(COMPUTECPP_INCLUDES) | ||
LDFLAGS += -L$(COMPUTECPP_LIBS) -lComputeCpp | ||
COMPUTECPP_FLAGS += \ | ||
$(CXXFLAGS) $(shell $(COMPUTECPP_INFO) --dump-device-compiler-flags) | ||
|
||
# The example application to build. | ||
target := app | ||
all: $(target) | ||
|
||
# Single source multiple pass compilation. | ||
%: %.cpp | ||
$(COMPUTECPP) $(COMPUTECPP_FLAGS) -c $< -o $@.sycl | ||
$(CXX) $(CXXFLAGS) -include $@.sycl $< -o $@ $(LDFLAGS) | ||
|
||
%.o : %.cpp | ||
$(SYCLCXX) $(SYCLFLAGS) $< -o $@.sycl | ||
$(CXX) -c $(CXXFLAGS) -include $@.sycl $< -o $@ | ||
|
||
% : %.o | ||
$(CXX) $< $(LDFLAGS) -o $@ | ||
|
||
.PHONY: clean help | ||
|
||
clean: | ||
rm -fv $(target) $(target).sycl $(target).o | ||
rm -f *.o *.sycl $(EXECUTABLE) | ||
|
||
help: | ||
@echo "Builds an example SYCL application." | ||
@echo "Usage: make COMPUTECPP_PREFIX=[path-to-computecpp] {all,clean,help}" | ||
@echo "Either copy computecpp.pc to /usr/lib/pkgconfig or append <computecpp_dir>/lib/pkgconfig to PKG_CONFIG_PATH." | ||
@echo "Usage: make {all,clean,help}" |