-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (116 loc) · 3.78 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
PROGNAME = borsch
PREFIX ?= /usr
# specify your systems terminfo directory
# leave empty to install into your home folder
TERMINFO := ${DESTDIR}${PREFIX}/share/terminfo
LIB_PREFIX = ${PREFIX}/lib/${PROGNAME}
SCHEME_LIB_PREFIX = ${LIB_PREFIX}/scheme
INCS = -I.
LIBS = -lc -lutil -lncursesw -ltinfo
CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
CFLAGS += -std=c99 ${INCS} -DNDEBUG ${CPPFLAGS}
LDFLAGS += -L ./text -L ./ui
CC ?= cc
SCHEME_LIST = scheme chez chez-scheme
$(foreach scm,$(SCHEME_LIST),$(if $(SCHEME),,$(eval SCHEME := $(shell which $(scm)))))
$(if $(SCHEME),,$(error No scheme program found))
PKG_CONFIG = pkg-config
X11_LIB = /usr/X11R6/lib
X11_LIBS = -L$(X11_LIB) -lrt -lX11 -lutil -lXft \
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2`
SRCS = xstr.c \
process.c \
main.c \
vt.c \
array.c \
window.c \
view.c \
buffer.c \
keymap.c \
event.c \
timer.c \
syntax.c \
style.c
SCH_VERSION := $(shell echo "(scheme-version)" | $(SCHEME) -q | sed -e 's|"||g' | cut -d ' ' -f4)
SCH_MACHINE := $(shell echo "(machine-type)" | $(SCHEME) -q)
SCH_PREFIX ?= /usr
SCH_PATH = $(SCH_PREFIX)/lib/csv$(SCH_VERSION)/$(SCH_MACHINE)
LIBS += -lpthread -luuid -ldl -lm
BIN += ${PROGNAME}-eval
SRCS += scheme.c
LIBS += -ltext -lui -ltree-sitter $(X11_LIBS)
SRCS += syntax/c/parser.c \
syntax/devicetree/parser.c \
syntax/diff/parser.c \
syntax/scheme/parser.c \
syntax/make/parser.c \
syntax/org/scanner.c \
syntax/org/parser.c \
syntax/markdown/parser.c \
syntax/markdown/scanner.c \
syntax/python/parser.c \
syntax/python/scanner.c
CFLAGS += -I$(SCH_PATH) \
-DPROGNAME='"${PROGNAME}"' \
-DLIB_PATH='"'"${DESTDIR}${SCHEME_LIB_PREFIX}"'"'
OBJS += ${SRCS:.c=.o}
BIN += ${PROGNAME}
VERSION = $(shell git describe --always --dirty 2>/dev/null || echo "0.15-git")
CFLAGS += -DVERSION=\"${VERSION}\"
ifeq ($(DEBUG),1)
CFLAGS += -UNDEBUG -O0 -g -ggdb -Wall -Wextra -Wno-unused-parameter
endif
.PHONY: libtext libui clean_scheme_libs install_scheme_libs ${PROGNAME}.boot
all: ${PROGNAME} ${PROGNAME}.boot
clean_scheme_libs:
@for s in $$(find scheme/ -type f -name '*.so' | sed -e 's|scheme/||'); do \
rm scheme/$$s; \
done
install_scheme_libs:
@echo "Installing scheme libraries into ${DESTDIR}${SCHEME_LIB_PREFIX} ..."
@mkdir -p ${DESTDIR}${SCHEME_LIB_PREFIX}
@for s in $$(find scheme/ -type f -name '*.so' | sed -e 's|scheme/||'); do \
echo "installing $$s"; \
install -D -m 0644 "scheme/$$s" "${DESTDIR}${SCHEME_LIB_PREFIX}/$$s"; \
done
${PROGNAME}.boot:
cat mkboot.ss | $(SCHEME) -q
${PROGNAME}: ${OBJS} libui libtext
${CC} ${CFLAGS} ${LDFLAGS} $(SCH_PATH)/kernel.o ${OBJS} ${LIBS} -o $@
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
libtext:
$(MAKE) -C text/
libui:
$(MAKE) -C ui/
debug: clean
@$(MAKE) CFLAGS='${DEBUG_CFLAGS}'
clean: clean_scheme_libs
@echo cleaning
@$(MAKE) -C text/ clean
@$(MAKE) -C ui/ clean
@rm -f ${PROGNAME}.boot
@rm -f ${PROGNAME}
@rm -f ${OBJS}
dist: clean
@echo creating dist tarball
@git archive --prefix=${PROGNAME}-${VERSION}/ -o ${PROGNAME}-${VERSION}.tar.gz HEAD
install: all install_scheme_libs
@mkdir -p ${DESTDIR}${PREFIX}/bin
@for b in ${BIN}; do \
echo "installing ${DESTDIR}${PREFIX}/bin/$$b"; \
cp -f "$$b" "${DESTDIR}${PREFIX}/bin" && \
chmod 755 "${DESTDIR}${PREFIX}/bin/$$b"; \
done
@cp -f ${PROGNAME}.boot ${SCH_PATH}
@echo installing terminfo description
@TERMINFO=${TERMINFO} tic -s ${PROGNAME}.info
uninstall:
@for b in ${BIN}; do \
echo "removing ${DESTDIR}${PREFIX}/bin/$$b"; \
rm -f "${DESTDIR}${PREFIX}/bin/$$b"; \
done
@rm -f ${SCH_PATH}/${PROGNAME}.boot
@rm -fr ${DESTDIR}${LIB_PREFIX}
.PHONY: all clean dist install uninstall debug