doc: fix a couple of API doc warnings
[vis.git] / Makefile
blob7a08d869bf4ac348156e5907ee4998afe23a4833
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.6-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
50 TAR?=tar
51 DOCKER?=docker
53 all: $(ELF)
55 config.h:
56 cp config.def.h config.h
58 config.mk:
59 @touch $@
61 vis: config.h config.mk *.c *.h
62 ${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} ${SRC} ${LDFLAGS} ${LDFLAGS_VIS} -o $@
64 vis-menu: vis-menu.c
65 ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} -o $@
67 vis-digraph: vis-digraph.c
68 ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} -o $@
70 vis-single-payload.inc: $(EXECUTABLES) lua/*
71 for e in $(ELF); do \
72 ${STRIP} "$$e"; \
73 done
74 echo '#ifndef VIS_SINGLE_PAYLOAD_H' > $@
75 echo '#define VIS_SINGLE_PAYLOAD_H' >> $@
76 echo 'static unsigned char vis_single_payload[] = {' >> $@
77 $(TAR) --mtime='2014-07-15 01:23Z' --owner=0 --group=0 --numeric-owner --mode='a+rX-w' -c \
78 $(EXECUTABLES) $$(find lua -name '*.lua' | LC_ALL=C sort) | xz -T 1 | \
79 od -t x1 -v | sed -e 's/^[0-9a-fA-F]\{1,\}//g' -e 's/\([0-9a-f]\{2\}\)/0x\1,/g' >> $@
80 echo '};' >> $@
81 echo '#endif' >> $@
83 vis-single: vis-single.c vis-single-payload.inc
84 ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} -luntar -llzma -o $@
85 ${STRIP} $@
87 docker-kill:
88 -$(DOCKER) kill vis && $(DOCKER) wait vis
90 docker: docker-kill clean
91 $(DOCKER) build -t vis .
92 $(DOCKER) run --rm -d --name vis vis tail -f /dev/null
93 $(DOCKER) exec vis apk update
94 $(DOCKER) exec vis apk upgrade
95 $(DOCKER) cp . vis:/build/vis
96 $(DOCKER) exec -w /build/vis vis ./configure CC='cc --static' \
97 --enable-acl \
98 --enable-lua \
99 --enable-lpeg-static
100 $(DOCKER) exec -w /build/vis vis make VERSION="$(VERSION)" clean vis-single
101 $(DOCKER) cp vis:/build/vis/vis-single vis
102 $(DOCKER) kill vis
104 docker-clean: docker-kill clean
105 -$(DOCKER) image rm vis
107 debug: clean
108 @$(MAKE) CFLAGS_EXTRA='${CFLAGS_EXTRA} ${CFLAGS_DEBUG}'
110 profile: clean
111 @$(MAKE) CFLAGS_AUTO='' LDFLAGS_AUTO='' CFLAGS_EXTRA='-pg -O2'
113 coverage: clean
114 @$(MAKE) CFLAGS_EXTRA='--coverage'
116 test-update:
117 git submodule init
118 git submodule update --remote --rebase
120 test:
121 [ -e test/Makefile ] || $(MAKE) test-update
122 @$(MAKE) -C test
124 testclean:
125 @echo cleaning the test artifacts
126 [ ! -e test/Makefile ] || $(MAKE) -C test clean
128 clean:
129 @echo cleaning
130 @rm -f $(ELF) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno
132 distclean: clean testclean
133 @echo cleaning build configuration
134 @rm -f config.h config.mk
136 dist: distclean
137 @echo creating dist tarball
138 @git archive --prefix=vis-${VERSION}/ -o vis-${VERSION}.tar.gz HEAD
140 man:
141 @for m in ${MANUALS}; do \
142 echo "Generating $$m"; \
143 sed -e "s/VERSION/${VERSION}/" "man/$$m" | mandoc -W warning -T utf8 -T html -O man=%N.%S.html -O style=mandoc.css 1> "man/$$m.html" || true; \
144 done
146 luadoc:
147 @cd lua/doc && ldoc . && sed -e "s/RELEASE/${VERSION}/" -i index.html
149 luadoc-all:
150 @cd lua/doc && ldoc -a . && sed -e "s/RELEASE/${VERSION}/" -i index.html
152 luacheck:
153 @luacheck --config .luacheckrc lua test/lua | less -RFX
155 install: $(ELF)
156 @echo installing executable files to ${DESTDIR}${PREFIX}/bin
157 @mkdir -p ${DESTDIR}${PREFIX}/bin
158 @for e in ${EXECUTABLES}; do \
159 cp -f "$$e" ${DESTDIR}${PREFIX}/bin && \
160 chmod 755 ${DESTDIR}${PREFIX}/bin/"$$e"; \
161 done
162 @test ${CONFIG_LUA} -eq 0 || { \
163 echo installing support files to ${DESTDIR}${SHAREPREFIX}/vis; \
164 mkdir -p ${DESTDIR}${SHAREPREFIX}/vis; \
165 cp -r lua/* ${DESTDIR}${SHAREPREFIX}/vis; \
166 rm -rf "${DESTDIR}${SHAREPREFIX}/vis/doc"; \
168 @echo installing documentation to ${DESTDIR}${DOCPREFIX}/vis
169 @mkdir -p ${DESTDIR}${DOCPREFIX}/vis
170 @for d in ${DOCUMENTATION}; do \
171 cp "$$d" ${DESTDIR}${DOCPREFIX}/vis && \
172 chmod 644 "${DESTDIR}${DOCPREFIX}/vis/$$d"; \
173 done
174 @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
175 @mkdir -p ${DESTDIR}${MANPREFIX}/man1
176 @for m in ${MANUALS}; do \
177 sed -e "s/VERSION/${VERSION}/" < "man/$$m" > "${DESTDIR}${MANPREFIX}/man1/$$m" && \
178 chmod 644 "${DESTDIR}${MANPREFIX}/man1/$$m"; \
179 done
181 install-strip: install
182 @echo stripping executables
183 @for e in $(ELF); do \
184 ${STRIP} ${DESTDIR}${PREFIX}/bin/"$$e"; \
185 done
187 uninstall:
188 @echo removing executable file from ${DESTDIR}${PREFIX}/bin
189 @for e in ${EXECUTABLES}; do \
190 rm -f ${DESTDIR}${PREFIX}/bin/"$$e"; \
191 done
192 @echo removing documentation from ${DESTDIR}${DOCPREFIX}/vis
193 @for d in ${DOCUMENTATION}; do \
194 rm -f ${DESTDIR}${DOCPREFIX}/vis/"$$d"; \
195 done
196 @echo removing manual pages from ${DESTDIR}${MANPREFIX}/man1
197 @for m in ${MANUALS}; do \
198 rm -f ${DESTDIR}${MANPREFIX}/man1/"$$m"; \
199 done
200 @echo removing support files from ${DESTDIR}${SHAREPREFIX}/vis
201 @rm -rf ${DESTDIR}${SHAREPREFIX}/vis
203 .PHONY: all clean testclean dist distclean install install-strip uninstall debug profile coverage test test-update luadoc luadoc-all luacheck man docker-kill docker docker-clean