11#  Define the default target now so that it is always the first target
22BUILD_TARGETS  = \ 
33	main quantize quantize-stats perplexity embedding vdot q8dot train-text-from-scratch convert-llama2c-to-ggml \ 
4- 	simple batched batched-bench save-load-state server gguf llama-bench llava baby-llama beam-search  \ 
4+ 	simple batched batched-bench save-load-state server gguf llama-bench libllava.a  llava-cli  baby-llama beam-search  \ 
55	speculative infill benchmark-matmult parallel finetune export-lora tests/test-c.o
66
77#  Binaries only useful for tests
@@ -542,9 +542,9 @@ llama.o: llama.cpp ggml.h ggml-alloc.h ggml-backend.h ggml-cuda.h ggml-metal.h l
542542	$(CXX )  $(CXXFLAGS )  -c $<  -o $@ 
543543
544544COMMON_H_DEPS  = common/common.h common/sampling.h common/log.h
545- COMMON_DEPS    = common.o sampling.o grammar-parser.o
545+ COMMON_DEPS    = common.o sampling.o grammar-parser.o build-info.o 
546546
547- common.o : common/common.cpp build-info.h  $(COMMON_H_DEPS ) 
547+ common.o : common/common.cpp $(COMMON_H_DEPS ) 
548548	$(CXX )  $(CXXFLAGS )  -c $<  -o $@ 
549549
550550sampling.o : common/sampling.cpp $(COMMON_H_DEPS ) 
@@ -563,46 +563,46 @@ libllama.so: llama.o ggml.o $(OBJS)
563563	$(CXX )  $(CXXFLAGS )  -shared -fPIC -o $@  $^  $(LDFLAGS ) 
564564
565565clean :
566- 	rm -vrf * .o tests/* .o * .so * .dll benchmark-matmult build-info.h  * .dot $(COV_TARGETS )  $(BUILD_TARGETS )  $(TEST_TARGETS ) 
566+ 	rm -vrf * .o tests/* .o * .so * .dll benchmark-matmult common/ build-info.cpp  * .dot $(COV_TARGETS )  $(BUILD_TARGETS )  $(TEST_TARGETS ) 
567567
568568# 
569569#  Examples
570570# 
571571
572- main : examples/main/main.cpp                                  build-info.h  ggml.o llama.o $(COMMON_DEPS )  console.o grammar-parser.o $(OBJS ) 
572+ main : examples/main/main.cpp                                  ggml.o llama.o $(COMMON_DEPS )  console.o grammar-parser.o $(OBJS ) 
573573	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
574574	@echo
575575	@echo ' ====  Run ./main -h for help.  ====' 
576576	@echo
577577
578- infill : examples/infill/infill.cpp                            build-info.h  ggml.o llama.o $(COMMON_DEPS )  console.o grammar-parser.o $(OBJS ) 
578+ infill : examples/infill/infill.cpp                            ggml.o llama.o $(COMMON_DEPS )  console.o grammar-parser.o $(OBJS ) 
579579	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
580580
581- simple : examples/simple/simple.cpp                            build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
581+ simple : examples/simple/simple.cpp                            ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
582582	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
583583
584- batched : examples/batched/batched.cpp                         build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
584+ batched : examples/batched/batched.cpp                         ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
585585	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
586586
587- batched-bench : examples/batched-bench/batched-bench.cpp       build-info.h  ggml.o llama.o common.o $(OBJS ) 
587+ batched-bench : examples/batched-bench/batched-bench.cpp       build-info.o  ggml.o llama.o common.o $(OBJS ) 
588588	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
589589
590- quantize : examples/quantize/quantize.cpp                      build-info.h  ggml.o llama.o $(OBJS ) 
590+ quantize : examples/quantize/quantize.cpp                      build-info.o  ggml.o llama.o $(OBJS ) 
591591	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
592592
593- quantize-stats : examples/quantize-stats/quantize-stats.cpp    build-info.h  ggml.o llama.o $(OBJS ) 
593+ quantize-stats : examples/quantize-stats/quantize-stats.cpp    build-info.o  ggml.o llama.o $(OBJS ) 
594594	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
595595
596- perplexity : examples/perplexity/perplexity.cpp                build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
596+ perplexity : examples/perplexity/perplexity.cpp                ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
597597	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
598598
599- embedding : examples/embedding/embedding.cpp                   build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
599+ embedding : examples/embedding/embedding.cpp                   ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
600600	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
601601
602- save-load-state : examples/save-load-state/save-load-state.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
602+ save-load-state : examples/save-load-state/save-load-state.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
603603	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
604604
605- server : examples/server/server.cpp examples/server/httplib.h examples/server/json.hpp examples/server/index.html.hpp examples/server/index.js.hpp examples/server/completion.js.hpp examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h build-info.h  ggml.o llama.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
605+ server : examples/server/server.cpp examples/server/httplib.h examples/server/json.hpp examples/server/index.html.hpp examples/server/index.js.hpp examples/server/completion.js.hpp examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h ggml.o llama.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
606606	$(CXX )  $(CXXFLAGS )  -Iexamples/server $(filter-out  % .h,$(filter-out  % .hpp,$^ ) )  -o $@  $(LDFLAGS )  $(LWINSOCK2 )  -Wno-cast-qual
607607
608608gguf : examples/gguf/gguf.cpp ggml.o llama.o $(OBJS ) 
@@ -614,28 +614,31 @@ train-text-from-scratch: examples/train-text-from-scratch/train-text-from-scratc
614614convert-llama2c-to-ggml : examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp ggml.o llama.o $(OBJS ) 
615615	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
616616
617- llama-bench : examples/llama-bench/llama-bench.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
617+ llama-bench : examples/llama-bench/llama-bench.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
618618	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
619619
620- llava : examples/llava/llava.cpp examples/llava/llava-utils.h examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
620+ libllava.a : examples/llava/llava.cpp examples/llava/llava.h examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h common/base64.hpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
621+ 	$(CXX )  $(CXXFLAGS )  -static -fPIC -c $<  -o $@  -Wno-cast-qual
622+ 
623+ llava-cli : examples/llava/llava-cli.cpp examples/llava/clip.h examples/llava/clip.cpp examples/llava/llava.h examples/llava/llava.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
621624	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS )  -Wno-cast-qual
622625
623626baby-llama : examples/baby-llama/baby-llama.cpp ggml.o llama.o $(COMMON_DEPS )  train.o $(OBJS ) 
624627	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
625628
626- beam-search : examples/beam-search/beam-search.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
629+ beam-search : examples/beam-search/beam-search.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
627630	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
628631
629- finetune : examples/finetune/finetune.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  train.o $(OBJS ) 
632+ finetune : examples/finetune/finetune.cpp ggml.o llama.o $(COMMON_DEPS )  train.o $(OBJS ) 
630633	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
631634
632- export-lora : examples/export-lora/export-lora.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
635+ export-lora : examples/export-lora/export-lora.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
633636	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
634637
635- speculative : examples/speculative/speculative.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
638+ speculative : examples/speculative/speculative.cpp ggml.o llama.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
636639	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
637640
638- parallel : examples/parallel/parallel.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
641+ parallel : examples/parallel/parallel.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
639642	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
640643
641644ifdef  LLAMA_METAL 
@@ -648,21 +651,24 @@ swift: examples/batched.swift
648651	(cd examples/batched.swift;  make build)
649652endif 
650653
651- build-info.h  : $(wildcard  .git/index)  scripts/build-info.sh
654+ common/ build-info.cpp  : $(wildcard  .git/index)  scripts/build-info.sh
652655	@sh scripts/build-info.sh $(CC )  >  $@ .tmp
653656	@if !  cmp -s $@ .tmp $@ ;  then  \ 
654657		mv $@ .tmp $@ ;  \ 
655658	else  \ 
656659		rm $@ .tmp;  \ 
657660	fi 
658661
662+ build-info.o : common/build-info.cpp
663+ 	$(CXX )  $(CXXFLAGS )  -c $(filter-out  % .h,$^ )  -o $@ 
664+ 
659665# 
660666#  Tests
661667# 
662668
663669tests : $(TEST_TARGETS ) 
664670
665- benchmark-matmult : examples/benchmark/benchmark-matmult.cpp build-info.h  ggml.o $(OBJS ) 
671+ benchmark-matmult : examples/benchmark/benchmark-matmult.cpp build-info.o  ggml.o $(OBJS ) 
666672	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
667673
668674run-benchmark-matmult : benchmark-matmult
@@ -676,40 +682,40 @@ vdot: pocs/vdot/vdot.cpp ggml.o $(OBJS)
676682q8dot : pocs/vdot/q8dot.cpp ggml.o $(OBJS ) 
677683	$(CXX )  $(CXXFLAGS )  $^  -o $@  $(LDFLAGS ) 
678684
679- tests/test-llama-grammar : tests/test-llama-grammar.cpp build-info.h  ggml.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
685+ tests/test-llama-grammar : tests/test-llama-grammar.cpp ggml.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
680686	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
681687
682- tests/test-grammar-parser : tests/test-grammar-parser.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
688+ tests/test-grammar-parser : tests/test-grammar-parser.cpp ggml.o llama.o $(COMMON_DEPS )  grammar-parser.o $(OBJS ) 
683689	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
684690
685- tests/test-double-float : tests/test-double-float.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
691+ tests/test-double-float : tests/test-double-float.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
686692	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
687693
688- tests/test-grad0 : tests/test-grad0.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
694+ tests/test-grad0 : tests/test-grad0.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
689695	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
690696
691- tests/test-opt : tests/test-opt.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
697+ tests/test-opt : tests/test-opt.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
692698	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
693699
694- tests/test-quantize-fns : tests/test-quantize-fns.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
700+ tests/test-quantize-fns : tests/test-quantize-fns.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
695701	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
696702
697- tests/test-quantize-perf : tests/test-quantize-perf.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
703+ tests/test-quantize-perf : tests/test-quantize-perf.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
698704	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
699705
700- tests/test-sampling : tests/test-sampling.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
706+ tests/test-sampling : tests/test-sampling.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
701707	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
702708
703- tests/test-tokenizer-0-falcon : tests/test-tokenizer-0-falcon.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
709+ tests/test-tokenizer-0-falcon : tests/test-tokenizer-0-falcon.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
704710	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
705711
706- tests/test-tokenizer-0-llama : tests/test-tokenizer-0-llama.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
712+ tests/test-tokenizer-0-llama : tests/test-tokenizer-0-llama.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
707713	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
708714
709- tests/test-tokenizer-1-bpe : tests/test-tokenizer-1-bpe.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
715+ tests/test-tokenizer-1-bpe : tests/test-tokenizer-1-bpe.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
710716	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
711717
712- tests/test-tokenizer-1-llama : tests/test-tokenizer-1-llama.cpp build-info.h  ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
718+ tests/test-tokenizer-1-llama : tests/test-tokenizer-1-llama.cpp ggml.o llama.o $(COMMON_DEPS )  $(OBJS ) 
713719	$(CXX )  $(CXXFLAGS )  $(filter-out  % .h,$^ )  -o $@  $(LDFLAGS ) 
714720
715721tests/test-c.o : tests/test-c.c llama.h
0 commit comments