@@ -2,20 +2,62 @@ INCLUDE_PATH := $(abspath ./)
2
2
LIBRARY_PATH := $(abspath ./)
3
3
4
4
AR? =ar
5
-
5
+ CMAKE_ARGS? =
6
6
BUILD_TYPE? =
7
7
# keep standard at C11 and C++11
8
8
CXXFLAGS = -I. -I$(INCLUDE_PATH ) /../../../../sources/stablediffusion-ggml.cpp/thirdparty -I$(INCLUDE_PATH ) /../../../../sources/stablediffusion-ggml.cpp/ggml/include -I$(INCLUDE_PATH ) /../../../../sources/stablediffusion-ggml.cpp -O3 -DNDEBUG -std=c++17 -fPIC
9
9
10
+ # Disable Shared libs as we are linking on static gRPC and we can't mix shared and static
11
+ CMAKE_ARGS+=-DBUILD_SHARED_LIBS =OFF
12
+
13
+ # If build type is cublas, then we set -DGGML_CUDA=ON to CMAKE_ARGS automatically
14
+ ifeq ($(BUILD_TYPE ) ,cublas)
15
+ CMAKE_ARGS+=-DGGML_CUDA=ON
16
+ # If build type is openblas then we set -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
17
+ # to CMAKE_ARGS automatically
18
+ else ifeq ($(BUILD_TYPE),openblas)
19
+ CMAKE_ARGS+=-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
20
+ # If build type is clblas (openCL) we set -DGGML_CLBLAST=ON -DCLBlast_DIR=/some/path
21
+ else ifeq ($(BUILD_TYPE),clblas)
22
+ CMAKE_ARGS+=-DGGML_CLBLAST=ON -DCLBlast_DIR=/some/path
23
+ # If it's hipblas we do have also to set CC=/opt/rocm/llvm/bin/clang CXX=/opt/rocm/llvm/bin/clang++
24
+ else ifeq ($(BUILD_TYPE),hipblas)
25
+ CMAKE_ARGS+=-DGGML_HIP=ON
26
+ # If it's OSX, DO NOT embed the metal library - -DGGML_METAL_EMBED_LIBRARY=ON requires further investigation
27
+ # But if it's OSX without metal, disable it here
28
+ else ifeq ($(OS),Darwin)
29
+ ifneq ($(BUILD_TYPE),metal)
30
+ CMAKE_ARGS+=-DGGML_METAL=OFF
31
+ else
32
+ CMAKE_ARGS+=-DGGML_METAL=ON
33
+ CMAKE_ARGS+=-DGGML_METAL_EMBED_LIBRARY=ON
34
+ TARGET+=--target ggml-metal
35
+ endif
36
+ endif
37
+
38
+ ifeq ($(BUILD_TYPE ) ,sycl_f16)
39
+ CMAKE_ARGS+=-DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON
40
+ endif
41
+
42
+ ifeq ($(BUILD_TYPE ) ,sycl_f32)
43
+ CMAKE_ARGS+=-DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
44
+ endif
45
+
10
46
# warnings
11
47
CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function
12
48
49
+ build/libstable-diffusion.a :
50
+ mkdir -p build && \
51
+ cd build && \
52
+ cmake $(CMAKE_ARGS ) ../../../../../sources/stablediffusion-ggml.cpp && \
53
+ cmake --build . --config Release
54
+
13
55
gosd.o :
14
56
$(CXX ) $(CXXFLAGS ) gosd.cpp -o gosd.o -c
15
57
16
58
libsd.a : gosd.o
17
- cp $(INCLUDE_PATH ) /../../../../sources/stablediffusion-ggml.cpp/ build/libstable-diffusion.a ./libsd.a
59
+ cp $(INCLUDE_PATH ) /build/libstable-diffusion.a ./libsd.a
18
60
$(AR ) rcs libsd.a gosd.o
19
61
20
62
clean :
21
- rm -f gosd.o libsd.a
63
+ rm -f gosd.o libsd.a build
0 commit comments