-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (96 loc) · 3.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# Makefile
#
# Targets:
# all
# The default target, if no target is specified. Compiles source files
# as necessary and links them into the final executable.
# bear
# Generates a compile_commands.json file for use with LSPs.
# clean
# Removes all object files and executables.
# install
# Installs chewie and scripts into the directory specified by the prefix
# variable. Defaults to /usr/local.
# uninstall
# Removes chewie from bin, all the scripts from sbin and ~/.cache/chewie
# Variables:
# CC
# The C compiler to use. Defaults to gcc.
# CFLAGS
# Flags to pass to the C compiler. Defaults to -I/usr/include. If libcurl
# or libjson-c are installed in a non-standard location, you may need to
# add -I/path/to/include to this variable. On Mac OS, for example, I use
# MacPorts, so I use make CFLAGS="-I/opt/local/include".
# debug=1
# Build chewie with debug info
# LDFLAGS
# Flags to pass to the linker. Defaults to -L/usr/lib. If libcurl or
# libjson-c are installed in a non-standard location, you may need to add
# -L/path/to/lib to this variable. On Mac OS, for example, I use MacPorts,
# so I use make LDFLAGS="-L/opt/local/lib".
# prefix
# The directory to install chewie into. Defaults to /usr/local. chewie is
# installed into $(prefix)/bin and chewie-chat and qcg are installed into
# $(prefix)/sbin.
#
ifeq ($(CC),)
CC = gcc
endif
CFLAGS += -I/usr/include
LDFLAGS += -L/usr/lib
ifdef debug
CFLAGS += -g3 -D DEBUG
else
CFLAGS += -O3 -flto
LDFLAGS += -flto
endif
ifeq ($(prefix),)
prefix = /usr/local
endif
LIBS = -lcurl -ljson-c -llua
OBJS = main.o action.o api.o configure.o context.o file.o function.o input.o ollama.o openai.o option.o
.PHONY: all bear clean install uninstall
all: chewie
bear:
make clean
bear -- make
clean:
- rm -f chewie
- rm -f *.o
action.o : chewie.h action.h api.h configure.h context.h file.h setting.h
api.o : chewie.h api.h ollama.h openai.h
configure.o : chewie.h action.h api.h configure.h context.h file.h option.h
context.o : chewie.h context.h file.h
file.o : chewie.h file.h
function.o : chewie.h function.h
input.o : chewie.h file.h input.h
main.o : chewie.h action.h configure.h context.h file.h input.h ollama.h openai.h
ollama.o : chewie.h api.h context.h file.h ollama.h setting.h
openai.o : chewie.h api.h context.h file.h openai.h setting.h
option.o : chewie.h api.h configure.h option.h setting.h
chewie : $(OBJS)
$(CC) $(LDFLAGS) $(LIBS) $^ -o $@
ifndef debug
strip $@
endif
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
install: chewie chewie-chat eliza qb qc qg qn
mkdir -p ~/.cache/chewie
install -m 755 chewie $(prefix)/bin
install -m 755 chewie-chat $(prefix)/sbin
install -m 755 eliza $(prefix)/sbin
install -m 755 qb $(prefix)/sbin
install -m 755 qc $(prefix)/sbin
install -m 755 qg $(prefix)/sbin
install -m 755 qn $(prefix)/sbin
uninstall:
- rm -rf ~/.cache/chewie
- rm -f $(prefix)/bin/chewie
- rm -f $(prefix)/sbin/chewie-chat
- rm -f $(prefix)/sbin/eliza
- rm -f $(prefix)/sbin/qb
- rm -f $(prefix)/sbin/qc
- rm -f $(prefix)/sbin/qg
- rm -f $(prefix)/sbin/qn