-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
127 lines (104 loc) · 2.7 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
CFLAGS += -std=c11
CFLAGS += -Wall
CFLAGS += -Iinclude
CFLAGS += -isystem/usr/local/include
CFLAGS += $(shell pkg-config --cflags libffi)
CFLAGS += $(shell pcre-config --cflags)
CFLAGS += $(shell pkg-config --cflags libcurl)
CFLAGS += $(shell pkg-config --cflags openssl)
CFLAGS += -Wno-switch
CFLAGS += -Wno-unused-value
CFLAGS += -Wno-unused-function
CFLAGS += -D_GNU_SOURCE
LDFLAGS += -L/usr/local/lib
LDFLAGS += -lpthread
LDFLAGS += -lm
LDFLAGS += -lreadline
LDFLAGS += -lutf8proc
LDFLAGS += -lsqlite3
LDFLAGS += -ldl
LDFLAGS += $(shell pkg-config --libs openssl)
LDFLAGS += -lffi
LDFLAGS += $(shell pcre-config --libs)
LDFLAGS += $(shell pkg-config --libs gumbo)
LDFLAGS += $(shell pkg-config --libs libcurl)
LDFLAGS += $(shell pkg-config --libs libcurl)
ifdef JEMALLOC
LDFLAGS += -L$(shell jemalloc-config --libdir)
LDFLAGS += -Wl,-rpath,$(shell jemalloc-config --libdir)
LDFLAGS += -ljemalloc $(shell jemalloc-config --libs)
endif
ifdef DEBUG_NAMES
CFLAGS += -DTY_DEBUG_NAMES
endif
TEST_FILTER ?= "."
PROG := ty
PREFIX ?= /usr/local
bindir := /bin
ifndef LOG
CFLAGS += -DTY_NO_LOG
endif
ifdef UNSAFE
CFLAGS += -DTY_UNSAFE
endif
ifdef RELEASE
CFLAGS += -O3
CFLAGS += -pipe
CFLAGS += -DTY_RELEASE
CFLAGS += -mcpu=native
CFLAGS += -mtune=native
else ifdef DEBUG
CFLAGS += -O0
CFLAGS += -fsanitize=undefined
CFLAGS += -fsanitize=address
CFLAGS += -ggdb3
else ifdef TDEBUG
CFLAGS += -O0
CFLAGS += -fsanitize=thread
CFLAGS += -ggdb3
else ifndef LOG
CFLAGS += -O1
CFLAGS += -ggdb3
CFLAGS += -DTY_RELEASE
endif
ifdef TY_PROFILER
CFLAGS += -DTY_ENABLE_PROFILING
endif
ifdef GENPROF
CFLAGS += -fprofile-generate
endif
ifdef USEPROF
CFLAGS += -fprofile-use
endif
ifdef LTO
CFLAGS += -flto
CFLAGS += -fomit-frame-pointer
CFLAGS += -fwhole-program
endif
ifdef WITHOUT_OS
CFLAGS += -DTY_WITHOUT_OS
endif
SOURCES := $(wildcard src/*.c)
OBJECTS := $(patsubst src/%.c,obj/%.o,$(SOURCES))
ASSEMBLY := $(patsubst %.c,%.s,$(SOURCES))
all: $(PROG)
ty: ty.c $(OBJECTS)
@echo cc $^
$(CC) $(CFLAGS) -o $@ $< obj/* $(LDFLAGS)
asm: $(ASSEMBLY)
%.s: src/%.c
@echo cc $<
$(CC) $(CFLAGS) -S -o asm/$@ -DFILENAME=$(patsubst %.c,%,$<) $<
obj/%.o: src/%.c
@echo cc $<
$(CC) $(CFLAGS) -c -o $@ -DFILENAME=$(patsubst src/%.c,%,$<) $<
clean:
rm -rf $(PROG) *.gcda $(wildcard obj/*.o) $(wildcard asm/*.s) $(wildcard obj/*.gcda)
test:
./ty test.ty
install: $(PROG)
sudo install -m755 -s $(PROG) $(DESTDIR)$(PREFIX)$(bindir)
install -d $(HOME)/.ty
install -m644 lib/* $(HOME)/.ty
based: $(SOURCES)
cat $^ | gcc-13 $(CFLAGS) -c -x c -o $@ -