summaryrefslogtreecommitdiffstats
path: root/doxygen/Makefile.am
blob: e4fc0ebe1d95c4d49209e298ec8d380016b92015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
if HAVE_DOXYGEN

doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')

doxyfile.stamp: $(doc_srcs) Makefile.am
	rm -rf html man
	doxygen doxygen.cfg >/dev/null
# We need to use bash for its associative array facility
# (`bash -p` prevents import of functions from the environment).
# The command has to be a single line so the functions work
# and so `make` gives all lines to `bash -c`
# (hence ";\" at the end of every line but the last).
	bash -p -c 'declare -A renamed_page;\
main(){ set -e; cd man/man3; rm -f _*;\
  count_real_pages;\
  rename_real_pages;\
  make_symlinks;\
};\
count_real_pages(){ page_count=0;\
  for i in $$(ls -S);\
  do head -n1 $$i | grep -E -q '^\.so' && break;\
    page_count=$$(($$page_count + 1));\
  done;\
  first_link=$$(($$page_count + 1));\
};\
rename_real_pages(){ for i in $$(ls -S | head -n$$page_count);\
  do for j in $$(ls -S | tail -n+$$first_link);\
    do grep -E -q $$i$$ $$j && break;\
    done;\
    mv -f $$i $$j;\
    renamed_page[$$i]=$$j;\
  done;\
};\
make_symlinks(){ for j in $$(ls -S | tail -n+$$first_link);\
  do ln -sf $${renamed_page[$$(cat $$j | cut -f2 -d/)]} $$j;\
  done;\
};\
main'

	touch doxyfile.stamp

CLEANFILES = doxyfile.stamp

all-local: doxyfile.stamp
clean-local:
	rm -rf $(top_srcdir)/doxygen/man $(top_srcdir)/doxygen/html
install-data-local:
	mkdir -p $(DESTDIR)$(mandir)/man3
	cp --no-dereference --preserve=links,mode,timestamps man/man3/*.3\
	  $(DESTDIR)$(mandir)/man3/

# make distcheck needs uninstall-local
uninstall-local:
	rm -r $(DESTDIR)$(mandir) man html doxyfile.stamp
endif