SDL: wikiheaders.pl: add --manpath argument

From 77b8edb5adfacbdcf62b44d6acf89340491b9aae Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 18 Mar 2023 00:25:44 +0100
Subject: [PATCH] wikiheaders.pl: add --manpath argument

---
 build-scripts/wikiheaders.pl | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl
index a20b20802d6b..4633ef1d6a97 100755
--- a/build-scripts/wikiheaders.pl
+++ b/build-scripts/wikiheaders.pl
@@ -2,6 +2,7 @@
 
 use warnings;
 use strict;
+use File::Path;
 use Text::Wrap;
 
 $Text::Wrap::huge = 'overflow';
@@ -29,6 +30,7 @@
 my $optionsfname = undef;
 my $wikipreamble = undef;
 my $changeformat = undef;
+my $manpath = undef;
 
 foreach (@ARGV) {
     $warn_about_missing = 1, next if $_ eq '--warn-about-missing';
@@ -42,6 +44,9 @@
     } elsif (/\A--changeformat=(.*)\Z/) {
         $changeformat = $1;
         next;
+    } elsif (/\A--manpath=(.*)\Z/) {
+        $manpath = $1;
+        next;
     }
     $srcpath = $_, next if not defined $srcpath;
     $wikipath = $_, next if not defined $wikipath;
@@ -54,6 +59,10 @@
     $optionsfname = $default_optionsfname;
 }
 
+if (not defined $manpath) {
+    $manpath = "$srcpath/man";
+}
+
 if (defined $optionsfname) {
     open OPTIONS, '<', $optionsfname or die("Failed to open options file '$optionsfname': $!\n");
     while (<OPTIONS>) {
@@ -474,7 +483,7 @@ sub filecopy {
 }
 
 sub usage {
-    die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing]\n\n");
+    die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing] [--manpath=<man path>]\n\n");
 }
 
 usage() if not defined $srcpath;
@@ -1412,10 +1421,8 @@ sub usage {
 } elsif ($copy_direction == -2) { # --copy-to-manpages
     # This only takes from the wiki data, since it has sections we omit from the headers, like code examples.
 
-    my $manpath = "$srcpath/man";
-    mkdir($manpath);
     $manpath .= "/man3";
-    mkdir($manpath);
+    File::Path::make_path($manpath);
 
     $dewikify_mode = 'manpage';
     $wordwrap_mode = 'manpage';