Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # top level makefile for Ollama
  2. include make/common-defs.make
  3. # Determine which if any GPU runners we should build
  4. include make/cuda-v11-defs.make
  5. include make/cuda-v12-defs.make
  6. include make/rocm-defs.make
  7. ifeq ($(CUSTOM_CPU_FLAGS),)
  8. ifeq ($(ARCH),amd64)
  9. RUNNER_TARGETS=cpu
  10. endif
  11. # Without CUSTOM_CPU_FLAGS we default to build both v11 and v12 if present
  12. ifeq ($(OLLAMA_SKIP_CUDA_GENERATE),)
  13. ifneq ($(CUDA_11_COMPILER),)
  14. RUNNER_TARGETS += cuda_v11
  15. endif
  16. ifneq ($(CUDA_12_COMPILER),)
  17. RUNNER_TARGETS += cuda_v12
  18. endif
  19. endif
  20. else # CUSTOM_CPU_FLAGS is set, we'll build only the latest cuda version detected
  21. ifneq ($(CUDA_12_COMPILER),)
  22. RUNNER_TARGETS += cuda_v12
  23. else ifneq ($(CUDA_11_COMPILER),)
  24. RUNNER_TARGETS += cuda_v11
  25. endif
  26. endif
  27. ifeq ($(OLLAMA_SKIP_ROCM_GENERATE),)
  28. ifneq ($(HIP_COMPILER),)
  29. RUNNER_TARGETS += rocm
  30. endif
  31. endif
  32. all: runners exe
  33. dist: $(addprefix dist_, $(RUNNER_TARGETS)) dist_exe
  34. dist_%:
  35. @$(MAKE) --no-print-directory -f make/Makefile.$* dist
  36. runners: $(RUNNER_TARGETS)
  37. $(RUNNER_TARGETS):
  38. @$(MAKE) --no-print-directory -f make/Makefile.$@
  39. exe dist_exe:
  40. @$(MAKE) --no-print-directory -f make/Makefile.ollama $@
  41. help-sync apply-patches create-patches sync sync-clean:
  42. @$(MAKE) --no-print-directory -f make/Makefile.sync $@
  43. test integration lint:
  44. @$(MAKE) --no-print-directory -f make/Makefile.test $@
  45. clean:
  46. rm -rf $(BUILD_DIR) $(DIST_LIB_DIR) $(OLLAMA_EXE) $(DIST_OLLAMA_EXE)
  47. go clean -cache
  48. help:
  49. @echo "The following make targets will help you build Ollama"
  50. @echo ""
  51. @echo " make all # (default target) Build Ollama llm subprocess runners, and the primary ollama executable"
  52. @echo " make runners # Build Ollama llm subprocess runners; after you may use 'go build .' to build the primary ollama exectuable"
  53. @echo " make <runner> # Build specific runners. Enabled: '$(RUNNER_TARGETS)'"
  54. @echo " make dist # Build the runners and primary ollama executable for distribution"
  55. @echo " make help-sync # Help information on vendor update targets"
  56. @echo " make help-runners # Help information on runner targets"
  57. @echo ""
  58. @echo "The following make targets will help you test Ollama"
  59. @echo ""
  60. @echo " make test # Run unit tests"
  61. @echo " make integration # Run integration tests. You must 'make all' first"
  62. @echo " make lint # Run lint and style tests"
  63. @echo ""
  64. @echo "For more information see 'docs/development.md'"
  65. @echo ""
  66. help-runners:
  67. @echo "The following runners will be built based on discovered GPU libraries: '$(RUNNER_TARGETS)'"
  68. @echo ""
  69. @echo "GPU Runner CPU Flags: '$(GPU_RUNNER_CPU_FLAGS)' (Override with CUSTOM_CPU_FLAGS)"
  70. @echo ""
  71. @echo "# CUDA_PATH sets the location where CUDA toolkits are present"
  72. @echo "CUDA_PATH=$(CUDA_PATH)"
  73. @echo " CUDA_11_PATH=$(CUDA_11_PATH)"
  74. @echo " CUDA_11_COMPILER=$(CUDA_11_COMPILER)"
  75. @echo " CUDA_12_PATH=$(CUDA_12_PATH)"
  76. @echo " CUDA_12_COMPILER=$(CUDA_12_COMPILER)"
  77. @echo ""
  78. @echo "# HIP_PATH sets the location where the ROCm toolkit is present"
  79. @echo "HIP_PATH=$(HIP_PATH)"
  80. @echo " HIP_COMPILER=$(HIP_COMPILER)"
  81. .PHONY: all exe dist help help-sync help-runners test integration lint runners clean $(RUNNER_TARGETS)
  82. # Handy debugging for make variables
  83. print-%:
  84. @echo '$*=$($*)'