4 space indenting for cmake, attempt to clean up my mess in Makefile
This commit is contained in:
parent
3e7ec6e1e2
commit
ddb3e88376
4 changed files with 115 additions and 72 deletions
83
Makefile
83
Makefile
|
@ -187,40 +187,40 @@ clean:
|
||||||
rm -vf *.o main quantize quantize-stats perplexity embedding benchmark-matmult build-info.h
|
rm -vf *.o main quantize quantize-stats perplexity embedding benchmark-matmult build-info.h
|
||||||
|
|
||||||
build-info.h: $(GIT_INDEX)
|
build-info.h: $(GIT_INDEX)
|
||||||
@BUILD_NUMBER="0";\
|
scripts/build-info.sh > $@
|
||||||
BUILD_COMMIT="unknown";\
|
|
||||||
echo "git rev-list HEAD --count"; REV_LIST=`git rev-list HEAD --count`;\
|
|
||||||
if [ $$? -eq 0 ]; then BUILD_NUMBER=$$REV_LIST; fi;\
|
|
||||||
echo "git rev-parse HEAD"; REV_PARSE=`git rev-parse HEAD`;\
|
|
||||||
if [ $$? -eq 0 ]; then BUILD_COMMIT=$$REV_PARSE; fi;\
|
|
||||||
echo "#ifndef BUILD_INFO_H" > $@;\
|
|
||||||
echo "#define BUILD_INFO_H" >> $@;\
|
|
||||||
echo "" >> $@;\
|
|
||||||
echo "#define BUILD_NUMBER $$BUILD_NUMBER" >> $@;\
|
|
||||||
echo "#define BUILD_COMMIT \"$$BUILD_COMMIT\"" >> $@;\
|
|
||||||
echo "" >> $@;\
|
|
||||||
echo "#endif // BUILD_INFO_H" >> $@;
|
|
||||||
|
|
||||||
main: examples/main/main.cpp build-info.h ggml.o llama.o common.o $(OBJS)
|
#
|
||||||
$(CXX) $(CXXFLAGS) $(filter-out build-info.h,$^) -o $@ $(LDFLAGS)
|
# Examples
|
||||||
@echo
|
#
|
||||||
@echo '==== Run ./main -h for help. ===='
|
|
||||||
@echo
|
|
||||||
|
|
||||||
quantize: examples/quantize/quantize.cpp build-info.h ggml.o llama.o $(OBJS)
|
TARGETS_CPP += main
|
||||||
$(CXX) $(CXXFLAGS) $(filter-out build-info.h,$^) -o $@ $(LDFLAGS)
|
DEPS_main := examples/main/main.cpp ggml.o llama.o common.o
|
||||||
|
EXEC_main :=\
|
||||||
|
@echo;\
|
||||||
|
echo "==== Run ./main -h for help. ====";\
|
||||||
|
echo
|
||||||
|
|
||||||
quantize-stats: examples/quantize-stats/quantize-stats.cpp build-info.h ggml.o llama.o $(OBJS)
|
TARGETS_CPP += quantize
|
||||||
$(CXX) $(CXXFLAGS) $(filter-out build-info.h,$^) -o $@ $(LDFLAGS)
|
DEPS_quantize := examples/quantize/quantize.cpp ggml.o llama.o
|
||||||
|
|
||||||
perplexity: examples/perplexity/perplexity.cpp build-info.h ggml.o llama.o common.o $(OBJS)
|
TARGETS_CPP += quantize-stats
|
||||||
$(CXX) $(CXXFLAGS) $(filter-out build-info.h,$^) -o $@ $(LDFLAGS)
|
DEPS_quantize-stats := examples/quantize-stats/quantize-stats.cpp ggml.o llama.o
|
||||||
|
|
||||||
embedding: examples/embedding/embedding.cpp build-info.h ggml.o llama.o common.o $(OBJS)
|
TARGETS_CPP += perplexity
|
||||||
$(CXX) $(CXXFLAGS) $(filter-out build-info.h,$^) -o $@ $(LDFLAGS)
|
DEPS_perplexity := examples/perplexity/perplexity.cpp ggml.o llama.o common.o
|
||||||
|
|
||||||
vdot: pocs/vdot/vdot.cpp ggml.o $(OBJS)
|
TARGETS_CPP += embedding
|
||||||
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
|
DEPS_embedding := examples/embedding/embedding.cpp ggml.o llama.o common.o
|
||||||
|
|
||||||
|
TARGETS_CPP += save-load-state
|
||||||
|
DEPS_save-load-state := examples/save-load-state/save-load-state.cpp ggml.o llama.o common.o
|
||||||
|
|
||||||
|
TARGETS_CPP += vdot
|
||||||
|
DEPS_vdot := pocs/vdot/vdot.cpp ggml.o
|
||||||
|
|
||||||
|
#
|
||||||
|
# libllama
|
||||||
|
#
|
||||||
|
|
||||||
libllama.so: llama.o ggml.o $(OBJS)
|
libllama.so: llama.o ggml.o $(OBJS)
|
||||||
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
|
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
|
||||||
|
@ -229,10 +229,31 @@ libllama.so: llama.o ggml.o $(OBJS)
|
||||||
# Tests
|
# Tests
|
||||||
#
|
#
|
||||||
|
|
||||||
benchmark-matmult: examples/benchmark/benchmark-matmult.cpp build-info.h ggml.o $(OBJS)
|
TARGETS_CPP += benchmark
|
||||||
$(CXX) $(CXXFLAGS) $(filter-out build-info.h,$^) -o $@ $(LDFLAGS)
|
DEPS_benchmark := examples/benchmark/benchmark-matmult.cpp build-info.h ggml.o $(OBJS)
|
||||||
./$@
|
OUTP_benchmark := benchmark-matmult
|
||||||
|
EXEC_benchmark := ./benchmark-matmult
|
||||||
|
|
||||||
.PHONY: tests
|
.PHONY: tests
|
||||||
tests:
|
tests:
|
||||||
bash ./tests/run-tests.sh
|
bash ./tests/run-tests.sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Templates
|
||||||
|
#
|
||||||
|
|
||||||
|
# C++ template
|
||||||
|
# To use this template:
|
||||||
|
# 1. Add your target to the TARGETS variable: TARGETS_CPP += target
|
||||||
|
# 2. Set target-specific dependencies: DEPS_target := source1 dependency1 dependency2 ...
|
||||||
|
# 3. Optionally, set target-specific output: OUTP_target := output_name
|
||||||
|
# 4. Optionally, set target-specific command: EXEC_target := command
|
||||||
|
define template_cpp
|
||||||
|
OUTP_$(1) ?= $(1)
|
||||||
|
$(1): $$(DEPS_$(1)) $$(OBJS) build-info.h
|
||||||
|
$$(CXX) $$(CXXFLAGS) $$(filter-out build-info.h,$$^) -o $$(OUTP_$(1)) $$(LDFLAGS)
|
||||||
|
$$(if $$(value EXEC_$(1)),$$(EXEC_$(1)))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# This iterates through TARGETS_CPP and call the template for each target
|
||||||
|
$(foreach target,$(TARGETS_CPP),$(eval $(call template_cpp,$(target))))
|
||||||
|
|
22
scripts/build-info.sh
Executable file
22
scripts/build-info.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
BUILD_NUMBER="0"
|
||||||
|
BUILD_COMMIT="unknown"
|
||||||
|
|
||||||
|
REV_LIST=$(git rev-list HEAD --count)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
BUILD_NUMBER=$REV_LIST
|
||||||
|
fi
|
||||||
|
|
||||||
|
REV_PARSE=$(git rev-parse HEAD)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
BUILD_COMMIT=$REV_PARSE
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "#ifndef BUILD_INFO_H"
|
||||||
|
echo "#define BUILD_INFO_H"
|
||||||
|
echo ""
|
||||||
|
echo "#define BUILD_NUMBER $BUILD_NUMBER"
|
||||||
|
echo "#define BUILD_COMMIT \"$BUILD_COMMIT\""
|
||||||
|
echo ""
|
||||||
|
echo "#endif // BUILD_INFO_H"
|
Loading…
Add table
Add a link
Reference in a new issue