1#! /usr/bin/env perl 2# Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. 3# 4# Licensed under the Apache License 2.0 (the "License"). You may not use 5# this file except in compliance with the License. You can obtain a copy 6# in the file LICENSE in the source distribution or at 7# https://www.openssl.org/source/license.html 8 9 10require 5.10.0; 11use warnings; 12use strict; 13 14use FindBin; 15use lib "$FindBin::Bin/perl"; 16 17use OpenSSL::Util::Pod; 18 19if ($#ARGV + 1 != 5 || $ARGV[0] !~ /^(un)?install$/) { 20 print "Usage: write-man-symlinks [install|uninstall] src-dir build-dir man-page-name target-dir\n"; 21 exit; 22} 23 24my $action = $ARGV[0]; 25my $srcdir = $ARGV[1]; 26my $builddir = $ARGV[2]; 27my $manname = $ARGV[3]; 28my $targetdir = $ARGV[4]; 29 30$manname =~ m|(.+)\.(.+)|; 31my $mainf = $1; 32my $section = $2; 33die "Bad src file" if !defined $mainf; 34my $podfile = "$srcdir/$mainf.pod"; 35#Some pod files are generated and are in the build dir 36unless (-e $podfile) { 37 $podfile = "$builddir/$mainf.pod"; 38} 39my %podinfo = extract_pod_info($podfile); 40 41for my $name (@{$podinfo{names}}) { 42 next if $name eq $mainf; 43 if ($action eq "install") { 44 symlink "$manname", "$targetdir/$name.$section"; 45 } else { 46 unlink "$targetdir/$name.$section"; 47 } 48} 49