-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathBUILD.mk
More file actions
114 lines (96 loc) · 4.59 KB
/
Copy pathBUILD.mk
File metadata and controls
114 lines (96 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘
#
# Copyright 2026 Mozilla.ai
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# BUILD.mk for diffusionfile tools
#
# diffusionfile provides llamafile-integrated stable-diffusion tools:
# - diffusionfile: CLI image generation with llamafile features
#
PKGS += DIFFUSIONFILE
# ==============================================================================
# Package Sources (NOT using deps.mk SRCS/HDRS mechanism)
# ==============================================================================
# Note: We don't define DIFFUSIONFILE_SRCS or DIFFUSIONFILE_HDRS because:
# 1. Our sources include stable-diffusion.cpp headers with relative paths
# 2. mkdeps can't resolve these relative paths against full-path HDRS entries
# This matches the pattern used by stable-diffusion.cpp/BUILD.mk
# ==============================================================================
# Source files
# ==============================================================================
DIFFUSIONFILE_CLI_SRCS := \
diffusionfile/diffusionfile.cpp
# ==============================================================================
# Object files
# ==============================================================================
DIFFUSIONFILE_OBJS := $(DIFFUSIONFILE_CLI_SRCS:%.cpp=o/$(MODE)/%.o)
# ==============================================================================
# Include paths
# ==============================================================================
# Note: Using DIFFUSIONFILE_INCLUDES (not _INCS) to avoid being collected by
# deps.mk which expects _INCS to be a list of .inc files, not compiler flags.
DIFFUSIONFILE_INCLUDES := \
-iquote . \
-iquote diffusionfile \
-iquote stable-diffusion.cpp \
-iquote stable-diffusion.cpp/src \
-iquote stable-diffusion.cpp/include \
-iquote stable-diffusion.cpp/thirdparty \
-iquote stable-diffusion.cpp/examples \
-iquote llama.cpp/ggml/include \
-iquote llama.cpp/include
# ==============================================================================
# Compiler flags
# ==============================================================================
DIFFUSIONFILE_CPPFLAGS := \
$(DIFFUSIONFILE_INCLUDES) \
-DLLAMAFILE_VERSION_STRING=\"$(LLAMAFILE_VERSION_STRING)\"
# ==============================================================================
# Dependencies - llamafile objects for GPU support
# ==============================================================================
# Same pattern as llama.cpp/BUILD.mk TOOL_LLAMAFILE_OBJS
DIFFUSIONFILE_LLAMAFILE_OBJS := \
o/$(MODE)/llamafile/llamafile.o \
o/$(MODE)/llamafile/gpu.a \
o/$(MODE)/llamafile/zip.o \
o/$(MODE)/llamafile/check_cpu.o
# ==============================================================================
# Compilation rules
# ==============================================================================
o/$(MODE)/diffusionfile/%.o: diffusionfile/%.cpp diffusionfile/BUILD.mk
@mkdir -p $(@D)
$(COMPILE.cc) $(DIFFUSIONFILE_CPPFLAGS) -frtti -o $@ $<
# ==============================================================================
# Executable - diffusionfile (llamafile-integrated CLI)
# ==============================================================================
# Links main.cpp compiled with -DDIFFUSIONFILE to exclude its main()
o/$(MODE)/diffusionfile/diffusionfile: \
$(DIFFUSIONFILE_OBJS) \
o/$(MODE)/stable-diffusion.cpp/examples/cli/main.diffusionfile.cpp.o \
o/$(MODE)/stable-diffusion.cpp/stable-diffusion.cpp.a \
o/$(MODE)/stable-diffusion.cpp/thirdparty/zip.c.o \
o/$(MODE)/stable-diffusion.cpp.patches/sd_math_shim.o \
$(DIFFUSIONFILE_LLAMAFILE_OBJS) \
$(GGML_OBJS) \
$(TINYBLAS_CPU_OBJS)
@mkdir -p $(@D)
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lm -o $@
# ==============================================================================
# Main target
# ==============================================================================
.PHONY: o/$(MODE)/diffusionfile
o/$(MODE)/diffusionfile: \
o/$(MODE)/diffusionfile/diffusionfile