Merge remote-tracking branch 'lenormf/manpage'

This commit is contained in:
Maxime Coste 2016-02-05 09:39:40 +00:00
commit 51c9a1563a
3 changed files with 40 additions and 28 deletions

View File

@ -102,6 +102,7 @@ Kakoune dependencies are:
* A C++11 compliant compiler (GCC >= 4.8 or clang >= 3.4) * A C++11 compliant compiler (GCC >= 4.8 or clang >= 3.4)
* boost (>= 1.50) * boost (>= 1.50)
* ncurses with wide-characters support (>= 5.3, generally referred to as libncursesw) * ncurses with wide-characters support (>= 5.3, generally referred to as libncursesw)
* asciidoc (for the `a2k` tool), to generate man pages
To build, just type *make* in the src directory To build, just type *make* in the src directory

View File

@ -1,9 +1,9 @@
kakoune(1) kak(1)
========== ======
NAME NAME
---- ----
kakoune - a vim inspired, selection oriented code editor kak - a vim inspired, selection oriented code editor
SYNOPSIS SYNOPSIS
-------- --------

View File

@ -20,15 +20,16 @@ endif
sources := $(wildcard *.cc) sources := $(wildcard *.cc)
objects := $(addprefix ., $(sources:.cc=$(suffix).o)) objects := $(addprefix ., $(sources:.cc=$(suffix).o))
deps := $(addprefix ., $(sources:.cc=$(suffix).d)) deps := $(addprefix ., $(sources:.cc=$(suffix).d))
docs := commands \ docs := ../doc/manpages/commands \
execeval \ ../doc/manpages/execeval \
expansions \ ../doc/manpages/expansions \
faces \ ../doc/manpages/faces \
highlighters \ ../doc/manpages/highlighters \
hooks \ ../doc/manpages/hooks \
options \ ../doc/manpages/options \
registers \ ../doc/manpages/registers \
shortcuts \ ../doc/manpages/shortcuts
mandocs := $(addsuffix .gz,$(docs))
PREFIX ?= /usr/local PREFIX ?= /usr/local
DESTDIR ?= # root dir DESTDIR ?= # root dir
@ -38,12 +39,13 @@ NCURSESW_INCLUDE ?= /usr/include/ncursesw
bindir := $(DESTDIR)$(PREFIX)/bin bindir := $(DESTDIR)$(PREFIX)/bin
sharedir := $(DESTDIR)$(PREFIX)/share/kak sharedir := $(DESTDIR)$(PREFIX)/share/kak
docdir := $(DESTDIR)$(PREFIX)/share/doc/kak docdir := $(DESTDIR)$(PREFIX)/share/doc/kak
mandir := $(DESTDIR)$(PREFIX)/man/man1 mandir := $(DESTDIR)$(PREFIX)/share/man/man1
os := $(shell uname) os := $(shell uname)
ifeq ($(os),Darwin) ifeq ($(os),Darwin)
LIBS += -lncurses -lboost_regex-mt LIBS += -lncurses -lboost_regex-mt
A2X ?= a2x.py
else ifeq ($(os),FreeBSD) else ifeq ($(os),FreeBSD)
LIBS += -ltinfow -lncursesw -lboost_regex LIBS += -ltinfow -lncursesw -lboost_regex
CPPFLAGS += -I/usr/local/include CPPFLAGS += -I/usr/local/include
@ -62,6 +64,10 @@ else
LDFLAGS += -rdynamic LDFLAGS += -rdynamic
endif endif
# The `a2x` tool is used as-is (`a2x.py`) in some distributions, or as a symlink in others (`a2x` → `a2x.py`)
# Picking the right name is done in the system detection switch above
A2X ?= a2x
CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare
kak : $(objects) kak : $(objects)
@ -72,26 +78,30 @@ kak : $(objects)
.%$(suffix).o: %.cc .%$(suffix).o: %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $< $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
%.1: % # Generate the man page
a2x -f manpage $< ../doc/kak.1.gz: ../doc/kak.1.txt
%.1.gz: %.1.txt $(A2X) -f manpage $<
a2x -f manpage $<
gzip -f $(basename $<) gzip -f $(basename $<)
# Generate the editor's documentation pages
# Since `a2x` won't generate man pages if some sections are missing (which we don't need),
# we generate the pages, patch them and then compress them
$(mandocs): $(docs)
@for f in $^; do \
pagename="$${f##*/}"; pagename="$${pagename%.*}"; \
$(A2X) -f manpage "$$f"; \
sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$${pagename^^}\"," \
-e "/^\.SH \"NAME\"/,+1d" "$${f}.1"; \
gzip -f "$${f}.1"; \
mv "$${f}.1.gz" "$${f/.1/}.gz"; \
done
test: test:
cd ../test && ./run cd ../test && ./run
tags: tags:
ctags -R ctags -R
man: ../doc/kak.1.gz
man: ../doc/kakoune.1.gz doc: $(mandocs)
doc: $(addsuffix .1,$(addprefix ../doc/manpages/,$(docs)))
@for f in $^; do \
pagename="$${f##*/}"; pagename="$${pagename%.*}"; \
sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$${pagename^^}\"," \
-e "/^\.SH \"NAME\"/,+1d" $$f; \
gzip -f "$$f"; \
mv "$${f}.gz" "$${f/.1/}.gz"; \
done
clean: clean:
rm -f .*.o .*.d kak tags rm -f .*.o .*.d kak tags
@ -112,8 +122,9 @@ install: kak man doc
mkdir -p $(sharedir)/colors mkdir -p $(sharedir)/colors
install -m 0644 ../colors/* $(sharedir)/colors install -m 0644 ../colors/* $(sharedir)/colors
mkdir -p $(docdir)/manpages mkdir -p $(docdir)/manpages
mkdir -p $(mandir)
install -m 0644 ../README.asciidoc $(docdir) install -m 0644 ../README.asciidoc $(docdir)
install -m 0644 ../doc/manpages/*.gz $(docdir)/manpages install -m 0644 ../doc/manpages/*.gz $(docdir)/manpages
install -m 0644 ../doc/kakoune.1.gz $(mandir) install -m 0644 ../doc/kak.1.gz $(mandir)
.PHONY: tags install .PHONY: tags install