|
19 | 19 | mkdir -p build && $(CXX) -std=c++17 $(INCLUDES) -x c++-header gpu.hpp -o build/gpu.hpp.pch
|
20 | 20 |
|
21 | 21 | # TODO(avh): change extension based on platform
|
22 |
| -lib: |
23 |
| - mkdir -p build && $(CXX) -std=c++17 $(INCLUDES) -L$(LIBDIR) -ldawn -ldl -shared -fPIC gpu.cpp -o build/libgpucpp.dylib |
| 22 | +# Get the current OS name |
| 23 | +OS = $(shell uname | tr -d '\n') |
| 24 | +LIB_PATH ?= /usr/lib |
| 25 | +HEADER_PATH ?= /usr/include |
| 26 | +# Set the specific variables for each platform |
| 27 | +ifeq ($(OS), Linux) |
| 28 | + OS_TYPE ?= Linux |
| 29 | + |
| 30 | + GPU_CPP_LIB_NAME ?= libgpucpp.so |
| 31 | + DAWN_LIB_NAME ?= libdawn.so |
| 32 | +else ifeq ($(OS), Darwin) |
| 33 | + OS_TYPE ?= macOS |
| 34 | + |
| 35 | + GPU_CPP_LIB_NAME ?= libgpucpp.dylib |
| 36 | + DAWN_LIB_NAME ?= libdawn.dylib |
| 37 | +else |
| 38 | + OS_TYPE ?= unknown |
| 39 | +endif |
| 40 | + |
| 41 | +lib: check-clang dawnlib |
| 42 | +ifneq ($(OS_TYPE), unknown) |
| 43 | + mkdir -p build && $(CXX) -std=c++17 $(INCLUDES) -L$(LIBDIR) -ldawn -ldl -shared -fPIC gpu.cpp -o build/$(GPU_CPP_LIB_NAME) |
| 44 | + python3 build.py |
| 45 | + cp third_party/lib/$(DAWN_LIB_NAME) build/ |
| 46 | +else |
| 47 | + @echo "Unsupported operating system" |
| 48 | +endif |
| 49 | + |
| 50 | +install: |
| 51 | +ifneq ($(OS_TYPE), unknown) |
| 52 | + cp build/$(GPU_CPP_LIB_NAME) $(LIB_PATH) |
| 53 | + cp build/$(DAWN_LIB_NAME) $(LIB_PATH) |
| 54 | + cp build/gpu.hpp $(HEADER_PATH) |
| 55 | +else |
| 56 | + @echo "Unsupported operating system" |
| 57 | +endif |
| 58 | + |
| 59 | +uninstall: |
| 60 | +ifneq ($(OS_TYPE), unknown) |
| 61 | + rm $(LIB_PATH)/$(GPU_CPP_LIB_NAME) |
| 62 | + rm $(LIB_PATH)/$(DAWN_LIB_NAME) |
| 63 | + rm $(HEADER_PATH)/gpu.hpp |
| 64 | +else |
| 65 | + @echo "Unsupported operating system" |
| 66 | +endif |
24 | 67 |
|
25 | 68 | examples/hello_world/build/hello_world: check-clang dawnlib examples/hello_world/run.cpp check-linux-vulkan
|
26 | 69 | $(LIBSPEC) && cd examples/hello_world && make build/hello_world && ./build/hello_world
|
|
0 commit comments