diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Dockerfile | 9 | ||||
| -rw-r--r-- | Makefile | 31 | ||||
| -rw-r--r-- | makext.mk | 46 |
4 files changed, 74 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56ec2fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.log +prompt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8f438fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM debian:latest + +RUN apt-get update +RUN apt-get install -y libstdc++6 + +COPY prompt /app/prompt +COPY models/ /app/models/ + +# ENTRYPOINT ["bash"] @@ -1,28 +1,31 @@ +MAKEFLAGS += -j4 +MEX_ASSURE="cc docker" + +include makext.mk + LLAMA_DIR = llama.cpp -LLAMA_BUILD_DIR = $(LLAMA_DIR)/build CFLAGS = -Wall -Wextra -O3 -I$(LLAMA_DIR)/include -I$(LLAMA_DIR)/ggml/include -LDFLAGS = -L$(LLAMA_BUILD_DIR)/src -L$(LLAMA_BUILD_DIR)/ggml/src \ +LDFLAGS = -L$(LLAMA_DIR)/build/src -L$(LLAMA_DIR)/build/ggml/src \ -lpthread -lm -ldl -lstdc++ -g \ -lllama -lggml -lggml-cpu -lggml-base +help: .help -# -Wl,-rpath,$(shell pwd)/$(LLAMA_BUILD_DIR)/bin \ - -prompt: prompt.c +prompt: prompt.c models.h # Build prompt binary for testing $(CC) $(CFLAGS) prompt.c -o prompt $(LDFLAGS) -llama: - mkdir llama.cpp/build && \ - cd llama.cpp/build && \ +llamacpp: .assure # Build llama.cpp libraries + mkdir $(LLAMA_DIR)/build && \ + cd $(LLAMA_DIR)/build && \ cmake ../ -DBUILD_SHARED_LIBS=OFF && \ make -j8 -clean: - -rm -f prompt - cd llama.cpp/build && make clean - -rm -Rf llama.cpp/build - -docker: +docker: .assure # Runs prompt in Docker container docker build -t promptd . docker run -it promptd bash + +clean: # Cleans up all the build artefacts + -rm -f prompt + cd $(LLAMA_DIR)/build && make clean + -rm -Rf $(LLAMA_DIR)/build diff --git a/makext.mk b/makext.mk new file mode 100644 index 0000000..bbfa148 --- /dev/null +++ b/makext.mk @@ -0,0 +1,46 @@ +# Makext is a collection of useful extensions for Makefiles, aimed at +# simplifying and enhancing the functionality of Make-based projects. These +# extensions provide additional features and convenience functions to +# improve the build process, manage dependencies, and streamline common +# tasks. +# +# Visit the GitHub repository at https://github.com/mitjafelicijan/makext +# to learn more and contribute to the project. +# +# `makext` was written by Mitja Felicijan and is released under the BSD +# two-clause license, see the LICENSE file for more information. + +# Load environmental files from `MEX_ENVIRONMENT`. By default GNU make +# loads what is already in `env`. This extends it to other files. +ifdef MEX_ENVIRONMENT +TEMP_ENV_FILES=$(shell echo $(MEX_ENVIRONMENT) | tr ',' ' ') +$(foreach file,$(TEMP_ENV_FILES),$(eval include $(file))) +endif + +# Help extension that lists all the targets with descriptions +# and adds description and license information if data provided. +.PHONY: .help +.help: +ifdef MEX_DESCRIPTION + @printf "%s\n\n" $(MEX_DESCRIPTION) | fmt +endif + @echo "Targets:" + @grep -vE '^[[:space:]]' $(MAKEFILE_LIST) | grep -E '^.*:.* #' | sed -E 's/(.*):(.*):.*#(.*)/ \2###\3/' | column -t -s '###' +ifdef MEX_LICENSE + @printf "\n%s" $(MEX_LICENSE) | fmt +endif + +# Checks `MEX_ASSURE` variable if all the programs declared actually +# exist on a machine. If not this exists make with error. +.PHONY: .assure +.assure: +ifndef MEX_ASSURE + @printf "Variable MEX_ASSURE is not defined. Can not check for programs.\n" +else + @for prog in $(shell echo $(MEX_ASSURE)); do \ + if ! which $$prog > /dev/null; then \ + echo "Error: '$$prog' not found on this machine."; \ + exit 1; \ + fi; \ + done +endif |
