|
diff --git a/Makefile b/Makefile
|
|
|
1 |
MAKEFLAGS += -j4 |
|
|
2 |
MEX_ASSURE="cc docker" |
|
|
3 |
|
|
|
4 |
include makext.mk |
|
|
5 |
|
| 1 |
LLAMA_DIR = llama.cpp |
6 |
LLAMA_DIR = llama.cpp |
| 2 |
LLAMA_BUILD_DIR = $(LLAMA_DIR)/build |
|
|
| 3 |
|
7 |
|
| 4 |
CFLAGS = -Wall -Wextra -O3 -I$(LLAMA_DIR)/include -I$(LLAMA_DIR)/ggml/include |
8 |
CFLAGS = -Wall -Wextra -O3 -I$(LLAMA_DIR)/include -I$(LLAMA_DIR)/ggml/include |
| 5 |
LDFLAGS = -L$(LLAMA_BUILD_DIR)/src -L$(LLAMA_BUILD_DIR)/ggml/src \ |
9 |
LDFLAGS = -L$(LLAMA_DIR)/build/src -L$(LLAMA_DIR)/build/ggml/src \ |
| 6 |
-lpthread -lm -ldl -lstdc++ -g \ |
10 |
-lpthread -lm -ldl -lstdc++ -g \ |
| 7 |
-lllama -lggml -lggml-cpu -lggml-base |
11 |
-lllama -lggml -lggml-cpu -lggml-base |
| 8 |
|
12 |
|
| 9 |
|
13 |
help: .help |
| 10 |
# -Wl,-rpath,$(shell pwd)/$(LLAMA_BUILD_DIR)/bin \ |
|
|
| 11 |
|
14 |
|
| 12 |
prompt: prompt.c |
15 |
prompt: prompt.c models.h # Build prompt binary for testing |
| 13 |
$(CC) $(CFLAGS) prompt.c -o prompt $(LDFLAGS) |
16 |
$(CC) $(CFLAGS) prompt.c -o prompt $(LDFLAGS) |
| 14 |
|
17 |
|
| 15 |
llama: |
18 |
llamacpp: .assure # Build llama.cpp libraries |
| 16 |
mkdir llama.cpp/build && \ |
19 |
mkdir $(LLAMA_DIR)/build && \ |
| 17 |
cd llama.cpp/build && \ |
20 |
cd $(LLAMA_DIR)/build && \ |
| 18 |
cmake ../ -DBUILD_SHARED_LIBS=OFF && \ |
21 |
cmake ../ -DBUILD_SHARED_LIBS=OFF && \ |
| 19 |
make -j8 |
22 |
make -j8 |
| 20 |
|
23 |
|
| 21 |
clean: |
24 |
docker: .assure # Runs prompt in Docker container |
| 22 |
-rm -f prompt |
|
|
| 23 |
cd llama.cpp/build && make clean |
|
|
| 24 |
-rm -Rf llama.cpp/build |
|
|
| 25 |
|
|
|
| 26 |
docker: |
|
|
| 27 |
docker build -t promptd . |
25 |
docker build -t promptd . |
| 28 |
docker run -it promptd bash |
26 |
docker run -it promptd bash |
|
|
27 |
|
|
|
28 |
clean: # Cleans up all the build artefacts |
|
|
29 |
-rm -f prompt |
|
|
30 |
cd $(LLAMA_DIR)/build && make clean |
|
|
31 |
-rm -Rf $(LLAMA_DIR)/build |
|
diff --git a/makext.mk b/makext.mk
|
|
|
1 |
# Makext is a collection of useful extensions for Makefiles, aimed at |
|
|
2 |
# simplifying and enhancing the functionality of Make-based projects. These |
|
|
3 |
# extensions provide additional features and convenience functions to |
|
|
4 |
# improve the build process, manage dependencies, and streamline common |
|
|
5 |
# tasks. |
|
|
6 |
# |
|
|
7 |
# Visit the GitHub repository at https://github.com/mitjafelicijan/makext |
|
|
8 |
# to learn more and contribute to the project. |
|
|
9 |
# |
|
|
10 |
# `makext` was written by Mitja Felicijan and is released under the BSD |
|
|
11 |
# two-clause license, see the LICENSE file for more information. |
|
|
12 |
|
|
|
13 |
# Load environmental files from `MEX_ENVIRONMENT`. By default GNU make |
|
|
14 |
# loads what is already in `env`. This extends it to other files. |
|
|
15 |
ifdef MEX_ENVIRONMENT |
|
|
16 |
TEMP_ENV_FILES=$(shell echo $(MEX_ENVIRONMENT) | tr ',' ' ') |
|
|
17 |
$(foreach file,$(TEMP_ENV_FILES),$(eval include $(file))) |
|
|
18 |
endif |
|
|
19 |
|
|
|
20 |
# Help extension that lists all the targets with descriptions |
|
|
21 |
# and adds description and license information if data provided. |
|
|
22 |
.PHONY: .help |
|
|
23 |
.help: |
|
|
24 |
ifdef MEX_DESCRIPTION |
|
|
25 |
@printf "%s\n\n" $(MEX_DESCRIPTION) | fmt |
|
|
26 |
endif |
|
|
27 |
@echo "Targets:" |
|
|
28 |
@grep -vE '^[[:space:]]' $(MAKEFILE_LIST) | grep -E '^.*:.* #' | sed -E 's/(.*):(.*):.*#(.*)/ \2###\3/' | column -t -s '###' |
|
|
29 |
ifdef MEX_LICENSE |
|
|
30 |
@printf "\n%s" $(MEX_LICENSE) | fmt |
|
|
31 |
endif |
|
|
32 |
|
|
|
33 |
# Checks `MEX_ASSURE` variable if all the programs declared actually |
|
|
34 |
# exist on a machine. If not this exists make with error. |
|
|
35 |
.PHONY: .assure |
|
|
36 |
.assure: |
|
|
37 |
ifndef MEX_ASSURE |
|
|
38 |
@printf "Variable MEX_ASSURE is not defined. Can not check for programs.\n" |
|
|
39 |
else |
|
|
40 |
@for prog in $(shell echo $(MEX_ASSURE)); do \ |
|
|
41 |
if ! which $$prog > /dev/null; then \ |
|
|
42 |
echo "Error: '$$prog' not found on this machine."; \ |
|
|
43 |
exit 1; \ |
|
|
44 |
fi; \ |
|
|
45 |
done |
|
|
46 |
endif |