vis: let '^ mark point to top of jump list
[vis.git] / Makefile
blobd32e863181c68057ac65a3e083bca1d38dd3f726
1 -include config.mk
3 REGEX_SRC ?= text-regex.c
5 SRC = array.c buffer.c libutf.c main.c map.c \
6 sam.c text.c text-motions.c text-objects.c text-util.c \
7 ui-terminal.c view.c vis.c vis-lua.c vis-modes.c vis-motions.c \
8 vis-operators.c vis-registers.c vis-marks.c vis-prompt.c vis-text-objects.c $(REGEX_SRC)
10 ELF = vis vis-menu vis-digraph
11 EXECUTABLES = $(ELF) vis-clipboard vis-complete vis-open
13 MANUALS = $(EXECUTABLES:=.1)
15 DOCUMENTATION = LICENSE README.md
17 VERSION = $(shell git describe --always --dirty 2>/dev/null || echo "v0.3-git")
19 CONFIG_HELP ?= 1
20 CONFIG_CURSES ?= 1
21 CONFIG_LUA ?= 1
22 CONFIG_LPEG ?= 0
23 CONFIG_TRE ?= 0
24 CONFIG_ACL ?= 0
25 CONFIG_SELINUX ?= 0
27 CFLAGS_STD ?= -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DNDEBUG
28 CFLAGS_STD += -DVERSION=\"${VERSION}\"
29 LDFLAGS_STD ?= -lc
31 CFLAGS_LIBC ?= -DHAVE_MEMRCHR=0
33 CFLAGS_VIS = $(CFLAGS_AUTO) $(CFLAGS_TERMKEY) $(CFLAGS_CURSES) $(CFLAGS_ACL) \
34 $(CFLAGS_SELINUX) $(CFLAGS_TRE) $(CFLAGS_LUA) $(CFLAGS_LPEG) $(CFLAGS_STD) \
35 $(CFLAGS_LIBC)
37 CFLAGS_VIS += -DVIS_PATH=\"${SHAREPREFIX}/vis\"
38 CFLAGS_VIS += -DCONFIG_HELP=${CONFIG_HELP}
39 CFLAGS_VIS += -DCONFIG_CURSES=${CONFIG_CURSES}
40 CFLAGS_VIS += -DCONFIG_LUA=${CONFIG_LUA}
41 CFLAGS_VIS += -DCONFIG_LPEG=${CONFIG_LPEG}
42 CFLAGS_VIS += -DCONFIG_TRE=${CONFIG_TRE}
43 CFLAGS_VIS += -DCONFIG_SELINUX=${CONFIG_SELINUX}
44 CFLAGS_VIS += -DCONFIG_ACL=${CONFIG_ACL}
46 LDFLAGS_VIS = $(LDFLAGS_AUTO) $(LDFLAGS_TERMKEY) $(LDFLAGS_CURSES) $(LDFLAGS_ACL) \
47 $(LDFLAGS_SELINUX) $(LDFLAGS_TRE) $(LDFLAGS_LUA) $(LDFLAGS_LPEG) $(LDFLAGS_STD)
49 STRIP?=strip
51 all: $(ELF)
53 config.h:
54 cp config.def.h config.h
56 config.mk:
57 @touch $@
59 vis: config.h config.mk *.c *.h
60 ${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} ${SRC} ${LDFLAGS} ${LDFLAGS_VIS} -o $@
62 vis-menu: vis-menu.c
63 ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} -o $@
65 vis-digraph: vis-digraph.c
66 ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} -o $@
68 vis-single-payload.inc: $(EXECUTABLES) lua/*
69 for e in $(ELF); do \
70 ${STRIP} "$$e"; \
71 done
72 echo '#ifndef VIS_SINGLE_PAYLOAD_H' > $@
73 echo '#define VIS_SINGLE_PAYLOAD_H' >> $@
74 echo 'static unsigned char vis_single_payload[] = {' >> $@
75 tar --mtime='2014-07-15 01:23Z' --owner=0 --group=0 --numeric-owner --mode='a+rX-w' -c \
76 $(EXECUTABLES) $$(find lua -name '*.lua' | LC_ALL=C sort) | xz -T 1 | \
77 od -t x1 -A none -v | sed 's/\([0-9a-f]\+\)/0x\1,/g;$$s/,$$/ };/' >> $@
78 echo '#endif' >> $@
80 vis-single: vis-single.c vis-single-payload.inc
81 ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} -luntar -llzma -o $@
82 ${STRIP} $@
84 docker: clean
85 docker rm -f vis || true
86 docker build -t vis .
87 docker run --rm -d --name vis vis tail -f /dev/null
88 docker cp . vis:/tmp/vis
89 docker exec vis sed -i '/^VERSION/c VERSION = $(VERSION)' Makefile
90 docker exec vis ./configure CC='cc --static'
91 docker exec vis make clean vis-single
92 docker cp vis:/tmp/vis/vis-single vis
93 docker kill vis
95 debug: clean
96 @$(MAKE) CFLAGS_EXTRA='${CFLAGS_EXTRA} ${CFLAGS_DEBUG}'
98 profile: clean
99 @$(MAKE) CFLAGS_AUTO='' LDFLAGS_AUTO='' CFLAGS_EXTRA='-pg -O2'
101 coverage: clean
102 @$(MAKE) CFLAGS_EXTRA='--coverage'
104 test-update:
105 git submodule init
106 git submodule update --remote --rebase
108 test:
109 [ -e test/Makefile ] || $(MAKE) test-update
110 @$(MAKE) -C test
112 clean:
113 @echo cleaning
114 @rm -f $(ELF) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno
116 dist: clean
117 @echo creating dist tarball
118 @git archive --prefix=vis-${VERSION}/ -o vis-${VERSION}.tar.gz HEAD
120 man:
121 @for m in ${MANUALS}; do \
122 echo "Generating $$m"; \
123 sed -e "s/VERSION/${VERSION}/" "man/$$m" | mandoc -W warning -T utf8 -T xhtml -O man=%N.%S.html -O style=mandoc.css 1> "man/$$m.html" || true; \
124 done
126 luadoc:
127 @cd lua/doc && ldoc . && sed -e "s/RELEASE/${VERSION}/" -i index.html
129 luadoc-all:
130 @cd lua/doc && ldoc -a . && sed -e "s/RELEASE/${VERSION}/" -i index.html
132 luacheck:
133 @luacheck --config .luacheckrc lua test/lua | less -RFX
135 install: $(ELF)
136 @echo stripping executable
137 @for e in $(ELF); do \
138 ${STRIP} "$$e"; \
139 done
140 @echo installing executable files to ${DESTDIR}${PREFIX}/bin
141 @mkdir -p ${DESTDIR}${PREFIX}/bin
142 @for e in ${EXECUTABLES}; do \
143 cp -f "$$e" ${DESTDIR}${PREFIX}/bin && \
144 chmod 755 ${DESTDIR}${PREFIX}/bin/"$$e"; \
145 done
146 @test ${CONFIG_LUA} -eq 0 || { \
147 echo installing support files to ${DESTDIR}${SHAREPREFIX}/vis; \
148 mkdir -p ${DESTDIR}${SHAREPREFIX}/vis; \
149 cp -r lua/* ${DESTDIR}${SHAREPREFIX}/vis; \
150 rm -rf "${DESTDIR}${SHAREPREFIX}/vis/doc"; \
152 @echo installing documentation to ${DESTDIR}${DOCPREFIX}/vis
153 @mkdir -p ${DESTDIR}${DOCPREFIX}/vis
154 @for d in ${DOCUMENTATION}; do \
155 cp "$$d" ${DESTDIR}${DOCPREFIX}/vis && \
156 chmod 644 "${DESTDIR}${DOCPREFIX}/vis/$$d"; \
157 done
158 @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
159 @mkdir -p ${DESTDIR}${MANPREFIX}/man1
160 @for m in ${MANUALS}; do \
161 sed -e "s/VERSION/${VERSION}/" < "man/$$m" > "${DESTDIR}${MANPREFIX}/man1/$$m" && \
162 chmod 644 "${DESTDIR}${MANPREFIX}/man1/$$m"; \
163 done
165 uninstall:
166 @echo removing executable file from ${DESTDIR}${PREFIX}/bin
167 @for e in ${EXECUTABLES}; do \
168 rm -f ${DESTDIR}${PREFIX}/bin/"$$e"; \
169 done
170 @echo removing documentation from ${DESTDIR}${DOCPREFIX}/vis
171 @for d in ${DOCUMENTATION}; do \
172 rm -f ${DESTDIR}${DOCPREFIX}/vis/"$$d"; \
173 done
174 @echo removing manual pages from ${DESTDIR}${MANPREFIX}/man1
175 @for m in ${MANUALS}; do \
176 rm -f ${DESTDIR}${MANPREFIX}/man1/"$$m"; \
177 done
178 @echo removing support files from ${DESTDIR}${SHAREPREFIX}/vis
179 @rm -rf ${DESTDIR}${SHAREPREFIX}/vis
181 .PHONY: all clean dist install uninstall debug profile coverage test test-update luadoc luadoc-all luacheck man docker