Skip to content

Commit 51c9a15

Browse files
committed
Merge remote-tracking branch 'lenormf/manpage'
2 parents 263ef0b + 3a8b856 commit 51c9a15

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

README.asciidoc

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

doc/kakoune.1.txt doc/kak.1.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
kakoune(1)
2-
==========
1+
kak(1)
2+
======
33

44
NAME
55
----
6-
kakoune - a vim inspired, selection oriented code editor
6+
kak - a vim inspired, selection oriented code editor
77

88
SYNOPSIS
99
--------

src/Makefile

+36-25
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ endif
2020
sources := $(wildcard *.cc)
2121
objects := $(addprefix ., $(sources:.cc=$(suffix).o))
2222
deps := $(addprefix ., $(sources:.cc=$(suffix).d))
23-
docs := commands \
24-
execeval \
25-
expansions \
26-
faces \
27-
highlighters \
28-
hooks \
29-
options \
30-
registers \
31-
shortcuts \
23+
docs := ../doc/manpages/commands \
24+
../doc/manpages/execeval \
25+
../doc/manpages/expansions \
26+
../doc/manpages/faces \
27+
../doc/manpages/highlighters \
28+
../doc/manpages/hooks \
29+
../doc/manpages/options \
30+
../doc/manpages/registers \
31+
../doc/manpages/shortcuts
32+
mandocs := $(addsuffix .gz,$(docs))
3233

3334
PREFIX ?= /usr/local
3435
DESTDIR ?= # root dir
@@ -38,12 +39,13 @@ NCURSESW_INCLUDE ?= /usr/include/ncursesw
3839
bindir := $(DESTDIR)$(PREFIX)/bin
3940
sharedir := $(DESTDIR)$(PREFIX)/share/kak
4041
docdir := $(DESTDIR)$(PREFIX)/share/doc/kak
41-
mandir := $(DESTDIR)$(PREFIX)/man/man1
42+
mandir := $(DESTDIR)$(PREFIX)/share/man/man1
4243

4344
os := $(shell uname)
4445

4546
ifeq ($(os),Darwin)
4647
LIBS += -lncurses -lboost_regex-mt
48+
A2X ?= a2x.py
4749
else ifeq ($(os),FreeBSD)
4850
LIBS += -ltinfow -lncursesw -lboost_regex
4951
CPPFLAGS += -I/usr/local/include
@@ -62,6 +64,10 @@ else
6264
LDFLAGS += -rdynamic
6365
endif
6466

67+
# The `a2x` tool is used as-is (`a2x.py`) in some distributions, or as a symlink in others (`a2x` → `a2x.py`)
68+
# Picking the right name is done in the system detection switch above
69+
A2X ?= a2x
70+
6571
CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare
6672

6773
kak : $(objects)
@@ -72,27 +78,31 @@ kak : $(objects)
7278
.%$(suffix).o: %.cc
7379
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
7480

75-
%.1: %
76-
a2x -f manpage $<
77-
%.1.gz: %.1.txt
78-
a2x -f manpage $<
81+
# Generate the man page
82+
../doc/kak.1.gz: ../doc/kak.1.txt
83+
$(A2X) -f manpage $<
7984
gzip -f $(basename $<)
8085

81-
test:
82-
cd ../test && ./run
83-
tags:
84-
ctags -R
85-
86-
man: ../doc/kakoune.1.gz
87-
doc: $(addsuffix .1,$(addprefix ../doc/manpages/,$(docs)))
86+
# Generate the editor's documentation pages
87+
# Since `a2x` won't generate man pages if some sections are missing (which we don't need),
88+
# we generate the pages, patch them and then compress them
89+
$(mandocs): $(docs)
8890
@for f in $^; do \
8991
pagename="$${f##*/}"; pagename="$${pagename%.*}"; \
92+
$(A2X) -f manpage "$$f"; \
9093
sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$${pagename^^}\"," \
91-
-e "/^\.SH \"NAME\"/,+1d" $$f; \
92-
gzip -f "$$f"; \
93-
mv "$${f}.gz" "$${f/.1/}.gz"; \
94+
-e "/^\.SH \"NAME\"/,+1d" "$${f}.1"; \
95+
gzip -f "$${f}.1"; \
96+
mv "$${f}.1.gz" "$${f/.1/}.gz"; \
9497
done
9598

99+
test:
100+
cd ../test && ./run
101+
tags:
102+
ctags -R
103+
man: ../doc/kak.1.gz
104+
doc: $(mandocs)
105+
96106
clean:
97107
rm -f .*.o .*.d kak tags
98108

@@ -112,8 +122,9 @@ install: kak man doc
112122
mkdir -p $(sharedir)/colors
113123
install -m 0644 ../colors/* $(sharedir)/colors
114124
mkdir -p $(docdir)/manpages
125+
mkdir -p $(mandir)
115126
install -m 0644 ../README.asciidoc $(docdir)
116127
install -m 0644 ../doc/manpages/*.gz $(docdir)/manpages
117-
install -m 0644 ../doc/kakoune.1.gz $(mandir)
128+
install -m 0644 ../doc/kak.1.gz $(mandir)
118129

119130
.PHONY: tags install

0 commit comments

Comments
 (0)