1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Allow standalone cmake in the doc subdirectory.

It's silly to require all the time-consuming cmake configuration for
the source code, if all you want to do is to build the documentation.
My own website update script will like this optimisation, and so will
Buildscr.

In order to make doc/CMakeLists.txt work standalone, I had to add a
'project' header (citing no languages, so that cmake won't even bother
looking for a C compiler); include FindGit, which cmake/setup.cmake
now won't be doing for it; change all references to CMAKE_SOURCE_DIR
to CMAKE_CURRENT_SOURCE_DIR/.. (since now the former will be defined
differently in a nested or standalone doc build); and spot whether
we're nested or not in order to conditionalise things designed to
interoperate with the parent CMakeLists.
This commit is contained in:
Simon Tatham 2021-05-08 10:11:56 +01:00
parent c931c7f02a
commit d77ecacc27
2 changed files with 62 additions and 36 deletions

View File

@ -123,9 +123,9 @@ in putty do echo '$#define BINARY_VERSION $(Winvercommas)' >> version.h
in putty do sed -i '/set(DEFAULT_COMMIT/s/unavailable/$(vcsfullid)/' cmake/gitcommit.cmake in putty do sed -i '/set(DEFAULT_COMMIT/s/unavailable/$(vcsfullid)/' cmake/gitcommit.cmake
in . do mkdir docbuild in . do mkdir docbuild
in docbuild do cmake ../putty in docbuild do cmake ../putty/doc
in docbuild do make -j$(nproc) VERBOSE=1 doc in docbuild do make -j$(nproc) VERBOSE=1
in putty/doc do cp ../../docbuild/doc/*.1 . in putty/doc do cp ../../docbuild/*.1 .
in putty do ./mksrcarc.sh in putty do ./mksrcarc.sh
in putty do ./mkunxarc.sh '$(Uxarcsuffix)' in putty do ./mkunxarc.sh '$(Uxarcsuffix)'
@ -198,10 +198,10 @@ ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -N -i h
in putty do for hash in md5 sha1 sha256 sha512; do for dir_plat in "build32 w32" "build64 w64" "abuild32 wa32" "abuild64 wa64"; do set -- $$dir_plat; (cd windows/$$1 && $${hash}sum *.exe | sed 's!\( \+\)!\1'$$2'/!;s!$$! (installer version)!') >> $${hash}sums.installer; done; done in putty do for hash in md5 sha1 sha256 sha512; do for dir_plat in "build32 w32" "build64 w64" "abuild32 wa32" "abuild64 wa64"; do set -- $$dir_plat; (cd windows/$$1 && $${hash}sum *.exe | sed 's!\( \+\)!\1'$$2'/!;s!$$! (installer version)!') >> $${hash}sums.installer; done; done
# Build a WiX MSI installer, for each build flavour. # Build a WiX MSI installer, for each build flavour.
in putty/windows with wixonlinux do candle -arch x86 -dRealPlatform=x86 -dDllOk=yes -dBuilddir=build32/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/doc/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installer32.msi -spdb in putty/windows with wixonlinux do candle -arch x86 -dRealPlatform=x86 -dDllOk=yes -dBuilddir=build32/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installer32.msi -spdb
in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=x64 -dDllOk=yes -dBuilddir=build64/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/doc/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installer64.msi -spdb in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=x64 -dDllOk=yes -dBuilddir=build64/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installer64.msi -spdb
in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=Arm -dDllOk=no -dBuilddir=abuild32/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/doc/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installera32.msi -spdb in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=Arm -dDllOk=no -dBuilddir=abuild32/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installera32.msi -spdb
in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=Arm64 -dDllOk=no -dBuilddir=abuild64/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/doc/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installera64.msi -spdb in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=Arm64 -dDllOk=no -dBuilddir=abuild64/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" -dHelpFilePath="../../docbuild/putty.chm" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installera64.msi -spdb
# Change the width field for our dialog background image so that it # Change the width field for our dialog background image so that it
# doesn't stretch across the whole dialog. (WiX's default one does; we # doesn't stretch across the whole dialog. (WiX's default one does; we
@ -223,13 +223,13 @@ ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -i http
# Build the standalone binaries, in both 32- and 64-bit flavours. # Build the standalone binaries, in both 32- and 64-bit flavours.
# These differ from the previous set in that they embed the help file. # These differ from the previous set in that they embed the help file.
in putty/windows/build32 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/doc/putty.chm) in putty/windows/build32 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/putty.chm)
in putty/windows/build32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1 in putty/windows/build32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/build64 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/doc/putty.chm) in putty/windows/build64 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/putty.chm)
in putty/windows/build64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1 in putty/windows/build64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/abuild32 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/doc/putty.chm) in putty/windows/abuild32 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/putty.chm)
in putty/windows/abuild32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1 in putty/windows/abuild32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/abuild64 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/doc/putty.chm) in putty/windows/abuild64 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../../docbuild/putty.chm)
in putty/windows/abuild64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1 in putty/windows/abuild64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
# Build the 'old' binaries, which should still run on all 32-bit # Build the 'old' binaries, which should still run on all 32-bit
@ -257,12 +257,12 @@ in putty/windows do mkdir deliver
in putty/windows do for subdir in build32 abuild32 build64 abuild64 buildold; do mkdir deliver/$$subdir; done in putty/windows do for subdir in build32 abuild32 build64 abuild64 buildold; do mkdir deliver/$$subdir; done
in putty/windows do while read x; do mv $$x deliver/$$x; mv $$x.map deliver/$$x.map; done < to-sign.txt in putty/windows do while read x; do mv $$x deliver/$$x; mv $$x.map deliver/$$x.map; done < to-sign.txt
in putty/windows/deliver/buildold do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/doc/putty.chm in putty/windows/deliver/buildold do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/putty.chm
in putty/windows/deliver/build32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/doc/putty.chm in putty/windows/deliver/build32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/putty.chm
in putty/windows/deliver/build64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/doc/putty.chm in putty/windows/deliver/build64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/putty.chm
in putty/windows/deliver/abuild32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/doc/putty.chm in putty/windows/deliver/abuild32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/putty.chm
in putty/windows/deliver/abuild64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/doc/putty.chm in putty/windows/deliver/abuild64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../../docbuild/putty.chm
in docbuild/doc/html do zip puttydoc.zip *.html in docbuild/html do zip puttydoc.zip *.html
# Deliver the actual PuTTY release directory into a subdir `putty'. # Deliver the actual PuTTY release directory into a subdir `putty'.
deliver putty/windows/deliver/buildold/*.exe putty/w32old/$@ deliver putty/windows/deliver/buildold/*.exe putty/w32old/$@
@ -279,10 +279,10 @@ deliver putty/windows/deliver/abuild32/*.exe putty/wa32/$@
deliver putty/windows/deliver/abuild32/putty.zip putty/wa32/$@ deliver putty/windows/deliver/abuild32/putty.zip putty/wa32/$@
deliver putty/windows/deliver/abuild64/*.exe putty/wa64/$@ deliver putty/windows/deliver/abuild64/*.exe putty/wa64/$@
deliver putty/windows/deliver/abuild64/putty.zip putty/wa64/$@ deliver putty/windows/deliver/abuild64/putty.zip putty/wa64/$@
deliver docbuild/doc/html/puttydoc.zip putty/$@ deliver docbuild/html/puttydoc.zip putty/$@
deliver docbuild/doc/putty.chm putty/$@ deliver docbuild/putty.chm putty/$@
deliver docbuild/doc/puttydoc.txt putty/$@ deliver docbuild/puttydoc.txt putty/$@
deliver docbuild/doc/html/*.html putty/htmldoc/$@ deliver docbuild/html/*.html putty/htmldoc/$@
deliver putty/putty-src.zip putty/$@ deliver putty/putty-src.zip putty/$@
deliver putty/*.tar.gz putty/$@ deliver putty/*.tar.gz putty/$@

View File

@ -1,3 +1,13 @@
cmake_minimum_required(VERSION 3.12)
project(putty-documentation LANGUAGES)
# This build script can be run standalone, or included as a
# subdirectory of the main PuTTY cmake build system. If the latter, a
# couple of things change: it has to set variables telling the rest of
# the build system what manpages are available to be installed, and it
# will change whether the 'make doc' target is included in 'make all'.
include(FindGit)
include(FindPerl) include(FindPerl)
find_program(HALIBUT halibut) find_program(HALIBUT halibut)
@ -23,9 +33,9 @@ if(HALIBUT AND PERL_EXECUTABLE)
-DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DOUTPUT_FILE=${INTERMEDIATE_VERSION_BUT} -DOUTPUT_FILE=${INTERMEDIATE_VERSION_BUT}
-DOUTPUT_TYPE=halibut -DOUTPUT_TYPE=halibut
-P ${CMAKE_SOURCE_DIR}/cmake/gitcommit.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/gitcommit.cmake
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/gitcommit.cmake DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/gitcommit.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
COMMENT "Checking current git commit") COMMENT "Checking current git commit")
add_custom_target(cmake_version_but add_custom_target(cmake_version_but
BYPRODUCTS ${VERSION_BUT} BYPRODUCTS ${VERSION_BUT}
@ -36,13 +46,13 @@ if(HALIBUT AND PERL_EXECUTABLE)
endif() endif()
add_custom_command(OUTPUT copy.but add_custom_command(OUTPUT copy.but
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/licence.pl COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../licence.pl
--copyrightdoc -o copy.but --copyrightdoc -o copy.but
DEPENDS ${CMAKE_SOURCE_DIR}/licence.pl ${CMAKE_SOURCE_DIR}/LICENCE) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../licence.pl ${CMAKE_CURRENT_SOURCE_DIR}/../LICENCE)
add_custom_command(OUTPUT licence.but add_custom_command(OUTPUT licence.but
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/licence.pl COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../licence.pl
--licencedoc -o licence.but --licencedoc -o licence.but
DEPENDS ${CMAKE_SOURCE_DIR}/licence.pl ${CMAKE_SOURCE_DIR}/LICENCE) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../licence.pl ${CMAKE_CURRENT_SOURCE_DIR}/../LICENCE)
set(manual_sources set(manual_sources
${CMAKE_CURRENT_BINARY_DIR}/copy.but ${CMAKE_CURRENT_BINARY_DIR}/copy.but
@ -93,6 +103,14 @@ if(HALIBUT AND PERL_EXECUTABLE)
list(APPEND doc_outputs puttydoc.txt) list(APPEND doc_outputs puttydoc.txt)
endif() endif()
macro(register_manpage title section)
list(APPEND manpage_outputs ${title}.${section})
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Only set this variable if there _is_ a parent scope.
set(HAVE_MANPAGE_${title}_${section} ON PARENT_SCOPE)
endif()
endmacro()
macro(manpage title section) macro(manpage title section)
if(HALIBUT) if(HALIBUT)
add_custom_command(OUTPUT ${title}.${section} add_custom_command(OUTPUT ${title}.${section}
@ -101,15 +119,13 @@ macro(manpage title section)
${CMAKE_CURRENT_SOURCE_DIR}/man-${title}.but ${CMAKE_CURRENT_SOURCE_DIR}/man-${title}.but
DEPENDS DEPENDS
mancfg.but man-${title}.but) mancfg.but man-${title}.but)
list(APPEND manpage_outputs ${title}.${section}) register_manpage(${title} ${section})
set(HAVE_MANPAGE_${title}_${section} ON PARENT_SCOPE)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section}) elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section})
add_custom_command(OUTPUT ${title}.${section} add_custom_command(OUTPUT ${title}.${section}
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section} ${title}.${section} ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section} ${title}.${section}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section}) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section})
list(APPEND manpage_outputs ${title}.${section}) register_manpage(${title} ${section})
set(HAVE_MANPAGE_${title}_${section} ON PARENT_SCOPE)
endif() endif()
endmacro() endmacro()
@ -124,7 +140,17 @@ manpage(pageant 1)
manpage(psocks 1) manpage(psocks 1)
manpage(psusan 1) manpage(psusan 1)
add_custom_target(manpages ALL add_custom_target(manpages ALL DEPENDS ${manpage_outputs})
DEPENDS ${manpage_outputs}) add_custom_target(doc DEPENDS ${doc_outputs} manpages)
add_custom_target(doc
DEPENDS ${doc_outputs} manpages) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# If we're doing a cmake from just the doc subdir, we expect the
# user to want to make all the documentation, including HTML and so
# forth. (What else would be the point?)
#
# But if we're included from the main makefile, then by default we
# only make the man pages (which are necessary for 'make install'),
# and we leave everything else to a separate 'make doc' target which
# the user can invoke if they need to.
add_custom_target(doc-default ALL DEPENDS doc)
endif()