2 # Generate .chk from .out with awk (generic), based upon the automake logic.
4 # Copyright (C) 2016 Glenn Randers-Pehrson
5 # Written by Roger Leigh, 2016
7 # This code is released under the libpng license.
8 # For conditions of distribution and use, see the disclaimer
11 # Variables substituted from CMakeLists.txt
12 set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
16 get_filename_component(INPUTEXT "${INPUT}" EXT)
17 get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
18 get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
19 get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
20 get_filename_component(INPUTDIR "${INPUT}" PATH)
21 get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
23 if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk")
24 # Generate .chk from .out with awk (generic)
25 file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new")
26 execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/checksym.awk"
27 "${SRCDIR}/scripts/${INPUTBASE}.def"
28 "of=${OUTPUTDIR}/${OUTPUTBASE}.new"
30 RESULT_VARIABLE AWK_FAIL)
32 message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new")
34 file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}")
36 message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")