File: generate_man1.patch

package info (click to toggle)
fribidi 1.0.16-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,024 kB
  • sloc: ansic: 8,767; sh: 4,766; makefile: 361; python: 27
file content (76 lines) | stat: -rw-r--r-- 2,537 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Description: Generate fribidi man page in upstream build system
Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmoudy@users.sourceforge.net>
Forwarded: https://github.com/fribidi/fribidi/pull/228

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 5993577..89c2876 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -15,7 +15,17 @@ AM_CPPFLAGS = \
 
 LDADD = $(top_builddir)/lib/libfribidi.la
 
+dist_man_MANS = $(bin_PROGRAMS:=.1)
+MAINTAINERCLEANFILES = $(man1)
+
+man1 = $(dist_man_MANS)
+
 $(top_builddir)/lib/libfribidi.la:
 	cd $(top_builddir)/lib && $(MAKE) $(AM_MAKEFLAGS) libfribidi.la
 
+%.1: %
+	@$(top_srcdir)/missing --run help2man ./$< --no-info \
+	--version-string=- -n "$(shell ./$< --help | head -n 2 | tail -n 1)" \
+	--output=$@
+
 -include $(top_srcdir)/git.mk
diff --git a/bin/meson.build b/bin/meson.build
index b4bbd68..2d3a74c 100644
--- a/bin/meson.build
+++ b/bin/meson.build
@@ -1,5 +1,6 @@
 # The fribidi binary is used by the test setup, so if bin=false we still
 # need to build it for internal usage, we just won't install it.
+gen_man_pages = 'fribidi.1'
 fribidi = executable('fribidi',
   'fribidi-main.c', 'getopt.c', 'getopt1.c', fribidi_unicode_version_h,
   c_args: ['-DHAVE_CONFIG_H'] + fribidi_static_cargs,
@@ -9,6 +10,7 @@ fribidi = executable('fribidi',
 
 if not get_option('bin')
   subdir_done()
+  gen_man_pages = []
 endif
 
 executable('fribidi-benchmark',
@@ -41,3 +43,30 @@ if get_option('fuzzer_ldflags') != ''
     link_args: get_option('fuzzer_ldflags').split(),
     install: false)
 endif
+
+python3 = import('python').find_installation()
+result = run_command(python3, '-c', '''import os.path; import sys
+sys.exit(0 if os.path.isfile('@0@') else 1)'''.format(join_paths(meson.current_source_dir(), gen_man_pages)),
+  check: false)
+have_man_pages = result.returncode() == 0
+message('Have pre-generated man pages: @0@'.format(have_man_pages))
+
+if have_man_pages
+  install_man(gen_man_pages)
+else
+  help2man = find_program('help2man', required: false)
+  if not help2man.found()
+    error('help2man is required to build documentation from git.')
+  endif
+
+  target = fribidi.name() + '.1'
+  custom_target(target,
+    input: fribidi,
+    output: target,
+    command: [help2man, '--no-info', '--version-string=-',
+      '-n "$(@INPUT@ --help | head -n 3 | tail -n 1)"',
+      '--output=' + '@OUTPUT@', '@INPUT@'],
+    depends: [fribidi],
+    install_dir: join_paths(get_option('prefix'), get_option('mandir'), 'man1'),
+    install: true)
+endif