Permalink
Browse files

Update makefile example for PkgConfig support (#135)

  • Loading branch information...
mmha authored and DuncanMcBain committed Aug 29, 2018
1 parent e996669 commit fff421f577e1ffa219ba2a988dc00e779616ddae
Showing with 16 additions and 23 deletions.
  1. +16 −23 tools/makefile_basic/Makefile
@@ -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}"

0 comments on commit fff421f

Please sign in to comment.