diff --git a/meson.build b/meson.build index 0e421b7bb22354e6a359dacc415542c66d8aa7b6..e064258f06f187698603959ba4731f7b1226781c 100644 --- a/meson.build +++ b/meson.build @@ -138,6 +138,23 @@ if dep_sdl.found() and dep_mpv.found() , install_dir: 'lib/lektor' ) endif +# Man pages +man_sh = find_program('scripts/man.sh') +man_header = run_command('realpath', 'doc/header').stdout().strip() +man_footer = run_command('realpath', 'doc/footer').stdout().strip() +man_files = [ [ 'lektord', '1' ] + ] + +foreach man: man_files + man_name = man.get(0) + man_section = man.get(1, '1') + custom_target( '@0@.@1@'.format(man_name, man_section) + , input: 'doc/@0@.@1@'.format(man_name, man_section) + , output: '@0@.@1@'.format(man_name, man_section) + , command: [ man_sh, '@INPUT@', '@OUTPUT@', man_header, man_footer ] + , install: true + , install_dir: join_paths(get_option('mandir'), 'man@0@'.format(man_section)) ) +endforeach + # Install -install_man('doc/lektord.1') meson.add_install_script('scripts/install.sh') diff --git a/scripts/man.sh b/scripts/man.sh index 94b311ccb4aa5eeea5e64bfb2bbaed250cee779e..50bff11fac7f998288ee5861e293afc1d174c3a5 100755 --- a/scripts/man.sh +++ b/scripts/man.sh @@ -3,12 +3,16 @@ # $0: script name # $1: input # $2: output -[ $# -ne 2 ] && exit 1 +# $3: header +# $4: footer +[ $# -ne 4 ] && exit 1 [ "$1" == "$2" ] && exit 2 # Global variables -HEADER="doc/header" -FOOTER="doc/footer" +HEADER="$3" +FOOTER="$4" +INPUT="$1" +OUTPUT="$2" # Functions function the_day() { @@ -37,5 +41,5 @@ function mk_manpage() { the_page "$2" '___PAGE___' } -mk_manpage "$1" "$2" +mk_manpage "$INPUT" "$OUTPUT" exit 0