]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
os400: build cli manual.
authorPatrick Monnerat <patrick@monnerat.net>
Sat, 27 Jul 2024 22:36:09 +0000 (00:36 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 28 Jul 2024 13:59:21 +0000 (15:59 +0200)
Use PASE perl to run manual generation scripts.

As PASE perl is not aware of all possible input file encoding, convert
all files to UTF-8 upon build start (this might be lengthy).

OS/400 terminal emulation may only offer 76 columns, thus a new -c
parameter has been added to the managen program, defining the allowed
width.

If perl is not available, omit generation and disable online manual.

Closes #14289

packages/Makefile.am
packages/OS400/config400.default
packages/OS400/initscript.sh
packages/OS400/make-docs.sh [new file with mode: 0755]
packages/OS400/make-src.sh
packages/OS400/makefile.sh
scripts/managen

index b7bf1e5916cac77c809f66167f7340be063a0d75..96f52bdb4c866c052d678af90baa22ecc029410e 100644 (file)
@@ -33,6 +33,7 @@ EXTRA_DIST = README.md \
   OS400/curl.inc.in \
   OS400/initscript.sh \
   OS400/config400.default \
+  OS400/make-docs.sh \
   OS400/make-include.sh \
   OS400/make-lib.sh \
   OS400/make-src.sh \
index 91a82771fb9eff350da65430de8ee837e4252278..4e7ddbac5772f58f44a2e0ef3602bfebf599cc33 100644 (file)
@@ -39,6 +39,7 @@ setenv OUTPUT           '*NONE'                 # Compilation output option.
 setenv TGTRLS           '*CURRENT'              # Target OS release.
 setenv IFSDIR           '/curl'                 # Installation IFS directory.
 setenv QADRTDIR         '/QIBM/ProdData/qadrt'  # QADRT IFS directory.
+setenv PASEPERL         '/QOpenSys/pkgs/bin/perl'       # PASE Perl interpreter.
 
 #       Define ZLIB availability and locations.
 
index cdb8fab3cebf6d097d044fa1ddbca80b9699499a..2f6d78c24503ae36891843c6f1d80cde6585f68d 100755 (executable)
@@ -69,6 +69,9 @@ if [ -f "${SCRIPTDIR}/config400.override" ]
 then    . "${SCRIPTDIR}/config400.override"
 fi
 
+#       Check if perl available.
+{ [ -n "${PASEPERL}" ] && [ -x "${PASEPERL}" ]; } || PASEPERL=
+
 #       Need to get the version definitions.
 
 LIBCURL_VERSION=$(grep '^#define  *LIBCURL_VERSION '                    \
diff --git a/packages/OS400/make-docs.sh b/packages/OS400/make-docs.sh
new file mode 100755 (executable)
index 0000000..b79b19e
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+#
+#       Documentation build script for the OS/400.
+#
+
+
+SCRIPTDIR=$(dirname "${0}")
+. "${SCRIPTDIR}/initscript.sh"
+
+[ -n "${PASEPERL}" ] || exit 0  # Perl needed for doc build.
+cd "${TOPDIR}/docs" || exit 1
+[ -d "${IFSDIR}/docs" ] || mkdir "${IFSDIR}/docs"
+
+
+#       Command line options.
+
+(
+        cd cmdline-opts || exit 1
+        MANPAGE=curl.1
+        TEXTPAGE=curl.txt
+        get_make_vars Makefile.inc
+        rm -f "${IFSDIR}/docs/${MANPAGE}" "${IFSDIR}/docs/${TEXTPAGE}"
+
+        #       Prepare online manual.
+        # shellcheck disable=SC2086
+        ${PASEPERL} "${TOPDIR}/scripts/managen" -c 75                   \
+                listhelp ${DPAGES} > "${TOPDIR}/src/tool_listhelp.c"
+
+        #       Generate text manual and copy it to DB2.
+        # shellcheck disable=SC2086
+        ${PASEPERL} "${TOPDIR}/scripts/managen" -I "${TOPDIR}/include"  \
+               -c 75 ascii ${DPAGES} > "${IFSDIR}/docs/${TEXTPAGE}"
+        MEMBER="${LIBIFSNAME}/DOCS.FILE/MANUAL.MBR"
+        CMD="CPY OBJ('${IFSDIR}/docs/${TEXTPAGE}') TOOBJ('${MEMBER}')"
+        CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
+        CLcommand "${CMD}"
+
+#       Man page is useless as OS/400 has no man command.
+#       # shellcheck disable=SC2086
+#       ${PASEPERL} "${TOPDIR}/scripts/managen" -I "${TOPDIR}/include"  \
+#               mainpage ${DPAGES} > "${IFSDIR}/docs/${MANPAGE}"
+)
index 6775f98bd363d74efc373d1b875d65b457bcb867..21fd0015b464fef8ebb480ac32c1b97a110e2e84 100755 (executable)
@@ -30,6 +30,15 @@ SCRIPTDIR=$(dirname "${0}")
 cd "${TOPDIR}/src" || exit 1
 
 
+#       Check if built-in manual can be generated.
+
+USE_MANUAL=
+if [ -f "${IFSDIR}/docs/curl.txt" ] && [ -n "${PASEPERL}" ]
+then    "${PASEPERL}" ./mkhelp.pl < "${IFSDIR}/docs/curl.txt" > tool_hugehelp.c
+        USE_MANUAL="'USE_MANUAL'"
+fi
+
+
 #       Get source lists.
 #       CURL_CFILES are in the current directory.
 #       CURLX_CFILES are in the lib directory and need to be recompiled because
@@ -49,12 +58,12 @@ INCLUDES="'${TOPDIR}/lib'"
 for SRC in ${CURLX_CFILES}
 do      MODULE=$(db2_name "${SRC}")
         MODULE=$(db2_name "X${MODULE}")
-        make_module "${MODULE}" "${SRC}"
+        make_module "${MODULE}" "${SRC}" "${USE_MANUAL}"
 done
 
 for SRC in ${CURL_CFILES}
 do      MODULE=$(db2_name "${SRC}")
-        make_module "${MODULE}" "${SRC}"
+        make_module "${MODULE}" "${SRC}" "${USE_MANUAL}"
 done
 
 
index e58b835e1f37c8b74d932114cd4fcfe9e423f9eb..fb1f1467132ca339450975d67031d43258ae235e 100755 (executable)
@@ -33,6 +33,18 @@ SCRIPTDIR=$(dirname "${0}")
 cd "${TOPDIR}" || exit 1
 
 
+#       Make sure all files are UTF8-encoded.
+
+# shellcheck disable=SC2038
+find "${TOPDIR}" -type f -print | xargs ls -S | while read -r CCSID FILE
+do      if [ "${CCSID}" != 1208 ]
+        then    CMD="CPY OBJ('${FILE}') TOOBJ('${FILE}') FROMCCSID(*OBJ)"
+                CMD="${CMD} TOCCSID(1208) DTAFMT(*TEXT) REPLACE(*YES)"
+                (CLcommand "${CMD}")
+        fi
+done
+
+
 #       Create the OS/400 library if it does not exist.
 
 if action_needed "${LIBIFSNAME}"
@@ -117,7 +129,7 @@ fi
 
 #       Build in each directory.
 
-# for SUBDIR in include lib src tests
-for SUBDIR in include lib src
+# for SUBDIR in include lib docs src tests
+for SUBDIR in include lib docs src
 do      "${SCRIPTDIR}/make-${SUBDIR}.sh"
 done
index 03c06d197867c7081101d707b242f0d82a54bc99..7cdb6581782173cbe40680f7c6d566849177943b 100755 (executable)
@@ -1196,6 +1196,12 @@ elsif($cmd eq "-I") {
     $cmd = shift @ARGV;
     goto check;
 }
+elsif($cmd eq "-c") {
+    # Column width
+    $colwidth = 0 + shift @ARGV;
+    $cmd = shift @ARGV;
+    goto check;
+}
 
 my @files = @ARGV; # the rest are the files