Skip to content

Commit 8d0988d

Browse files
committed
Prevent unconditional generation of the man pages, fix the executable name for a2x on Mac OS X
1 parent 4280831 commit 8d0988d

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

src/Makefile

+32-22
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
@@ -44,6 +45,7 @@ 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,26 +78,30 @@ 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

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)
90+
@for f in $^; do \
91+
pagename="$${f##*/}"; pagename="$${pagename%.*}"; \
92+
$(A2X) -f manpage "$$f"; \
93+
sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$${pagename^^}\"," \
94+
-e "/^\.SH \"NAME\"/,+1d" "$${f}.1"; \
95+
gzip -f "$${f}.1"; \
96+
mv "$${f}.1.gz" "$${f/.1/}.gz"; \
97+
done
98+
8199
test:
82100
cd ../test && ./run
83101
tags:
84102
ctags -R
85-
86103
man: ../doc/kak.1.gz
87-
doc: $(addsuffix .1,$(addprefix ../doc/manpages/,$(docs)))
88-
@for f in $^; do \
89-
pagename="$${f##*/}"; pagename="$${pagename%.*}"; \
90-
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-
done
104+
doc: $(mandocs)
95105

96106
clean:
97107
rm -f .*.o .*.d kak tags

0 commit comments

Comments
 (0)