Hash :
4edbb4da
Author :
Date :
2024-01-22T17:24:59
build: Move scripts/*.cmake.in to scripts/cmake/; add cmake/AUTHORS.md From the libpng licensing point of view, the build projects, the build scripts, the test scripts, the CI verification scripts, et cetera, have not traditionally been part of libpng proper, although some of these, including the CMake-based build, have been released under the libpng license. Considering how the CMake build grew as a result of many contributions from many contributing authors over a long time, one may argue that it almost became an individual piece of software in its own right. Moving on, everything CMake-related shall be placed in the subdirectory scripts/cmake/ (except, of course, the main CMakeLists.txt). Moreover, contributing authors shall be acknowledged in scripts/cmake/AUTHORS.md. Please see scripts/cmake/README.md for more information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
# gensrc.cmake.in
# Generate source files with awk, based upon the automake logic.
# Copyright (c) 2022-2024 Cosmin Truta
# Copyright (c) 2016 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
#
# Use, modification and distribution are subject to
# the same licensing terms and conditions as libpng.
# Please see the copyright notice in png.h or visit
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
#
# SPDX-License-Identifier: libpng-2.0
# Variables substituted from CMakeLists.txt
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
set(AWK "@AWK@")
set(DFA_XTRA "@DFA_XTRA@")
set(PNG_PREFIX "@PNG_PREFIX@")
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
if(OUTPUT STREQUAL "scripts/pnglibconf.c")
# Generate scripts/pnglibconf.c
file(REMOVE "${BINDIR}/pnglibconf.tf6" "${BINDIR}/pnglibconf.tf7")
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "com ${PNGLIB_VERSION} STANDARD API DEFINITION"
COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
"out=pnglibconf.tf6" "logunsupported=1" "version=search"
"${SRCDIR}/pngconf.h" "-"
"${SRCDIR}/scripts/pnglibconf.dfa"
WORKING_DIRECTORY "${BINDIR}"
RESULT_VARIABLE AWK_FAIL)
if(AWK_FAIL)
message(FATAL_ERROR "Failed to generate pnglibconf.tf6")
endif()
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
"out=pnglibconf.tf7" "pnglibconf.tf6"
WORKING_DIRECTORY "${BINDIR}"
RESULT_VARIABLE AWK_FAIL)
if(AWK_FAIL)
message(FATAL_ERROR "Failed to generate pnglibconf.tf7")
endif()
file(REMOVE "pnglibconf.tf6")
file(MAKE_DIRECTORY "${BINDIR}/scripts")
file(RENAME "pnglibconf.tf7" "${BINDIR}/scripts/pnglibconf.c")
elseif(OUTPUT STREQUAL "pnglibconf.c")
# Generate pnglibconf.c
file(REMOVE "${BINDIR}/pnglibconf.tf4" "${BINDIR}/pnglibconf.tf5")
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
out=pnglibconf.tf4 version=search
${SRCDIR}/pngconf.h ${SRCDIR}/scripts/pnglibconf.dfa
${SRCDIR}/pngusr.dfa ${DFA_XTRA}
WORKING_DIRECTORY "${BINDIR}"
RESULT_VARIABLE AWK_FAIL)
if(AWK_FAIL)
message(FATAL_ERROR "Failed to generate pnglibconf.tf4")
endif()
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
out=pnglibconf.tf5 pnglibconf.tf4
WORKING_DIRECTORY "${BINDIR}"
RESULT_VARIABLE AWK_FAIL)
if(AWK_FAIL)
message(FATAL_ERROR "Failed to generate pnglibconf.tf5")
endif()
file(REMOVE "pnglibconf.tf4")
file(MAKE_DIRECTORY "${BINDIR}/scripts")
file(RENAME "pnglibconf.tf5" "${BINDIR}/pnglibconf.c")
elseif(OUTPUT STREQUAL "pnglibconf.h")
# Generate pnglibconf.h
file(REMOVE "${BINDIR}/${OUTPUT}")
if(PNG_PREFIX)
file(REMOVE "pnglibconf.tf8")
execute_process(COMMAND "${AWK}" "s==0 && NR>1{print prev}
s==0{prev=\$0}
s==1{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}
s==2{print \"#define ${PNG_PREFIX}png_\" \$1, \"PNG_\" \$1}
END{print prev}" s=0 pnglibconf.out s=1 "${BINDIR}/scripts/prefix.out"
s=2 "${SRCDIR}/scripts/macro.lst"
OUTPUT_FILE pnglibconf.tf8
RESULT_VARIABLE AWK_FAIL)
if(AWK_FAIL)
message(FATAL_ERROR "Failed to generate pnglibconf.tf8")
endif()
file(RENAME "pnglibconf.tf8" "${BINDIR}/${OUTPUT}")
else()
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINDIR}/pnglibconf.out"
"${BINDIR}/${OUTPUT}"
RESULT_VARIABLE COPY_FAIL)
if(COPY_FAIL)
message(FATAL_ERROR "Failed to create pnglibconf.h")
endif()
endif()
elseif(OUTPUT STREQUAL "pngprefix.h")
# Generate pngprefix.h
file(REMOVE "${BINDIR}/${OUTPUT}")
if(PNG_PREFIX)
file(REMOVE "pngprefix.tf1")
execute_process(COMMAND "${AWK}"
"{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}"
"${BINDIR}/scripts/intprefix.out"
OUTPUT_FILE "pngprefix.tf1"
RESULT_VARIABLE AWK_FAIL)
if(AWK_FAIL)
message(FATAL_ERROR "Failed to generate pngprefix.tf1")
endif()
file(RENAME "pngprefix.tf1" "${BINDIR}/${OUTPUT}")
else()
file(WRITE "${BINDIR}/${OUTPUT}" "/* No libpng symbol prefix configured. */")
endif()
elseif(OUTPUT STREQUAL "scripts/pnglibconf.h.prebuilt")
# Generate scripts/pnglibconf.h.prebuilt (fails build)
message(STATUS "Attempting to build scripts/pnglibconf.h.prebuilt")
message(STATUS "This is a machine generated file, but if you want to make")
message(STATUS "a new one simply build the 'png_genfiles' target, and copy")
message(STATUS "scripts/pnglibconf.out to scripts/pnglibconf.h.prebuilt")
message(STATUS "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)")
message(FATAL_ERROR "Stopping build")
else()
message(FATAL_ERROR "Unsupported output: ${OUTPUT}")
endif()