Skip to content

Commit

Permalink
XXX same behaviour between automake and cmake builds
Browse files Browse the repository at this point in the history
  * use the same file names for messages and C code
  * print the same "Configuration summary" output
  • Loading branch information
ndim committed Nov 24, 2024
1 parent 6baf0b0 commit ad4c30c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ endif()
# Configuration
# =====================================

message(STATUS "Configuration summary:")
message(STATUS "----------------------")
message(STATUS "Configuration details:")
message(STATUS "---------------------")

if (DEBUG_CMAKE)
message(STATUS "CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
Expand Down Expand Up @@ -404,13 +404,6 @@ if (DEBUG_CMAKE)
message(STATUS "----------------------")
endif()

buildinfo_item("libelf" "yes")
buildinfo_item("libelf" "no")
buildinfo_item("libelf" "DO HAVE")
buildinfo_item("libelf" "DON'T HAVE")

buildinfo_output()

if(HAVE_LIBELF)
message(STATUS "DO HAVE libelf")
else()
Expand Down Expand Up @@ -503,3 +496,11 @@ else()
endif()

message(STATUS "----------------------")

buildinfo_item("libelf" "yes")
buildinfo_item("libelf" "no")
buildinfo_item("libelf" "DO HAVE")
buildinfo_item("libelf" "DON'T HAVE")

# print the output collected by earlier calls to buildinfo_item()
buildinfo_output()
26 changes: 25 additions & 1 deletion src/build-helpers/buildinfo.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
function(buildinfo_setup)
message(STATUS "BEGIN buildinfo_setup")
string(CONCAT BUILDINFO_INCLUDE_TOP
" /* buildinfo-include.c - DO NOT MODIFY THIS FILE! */\n"
" /* This include file buildinfo-include.c is AUTOGENERATED by configure. */\n"
" /* This file is meant to be \#include'ed, but is not a header file. */\n"
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/src/buildinfo-include.c"
"${BUILDINFO_INCLUDE_TOP}")
string(CONCAT BUILDINFO_SUMMARY_TOP
"Configuration summary:\n"
"----------------------\n"
"\n"
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/buildinfo-summary.txt"
"${BUILDINFO_SUMMARY_TOP}")
message(STATUS "END buildinfo_setup")
endfunction()

function(buildinfo_item KEY VAL)
cmake_parse_arguments(arg "" "" "" ${ARGN})
message(STATUS "BEGIN buildinfo_item")
message(STATUS " K,V: ${KEY}, ${VAL}")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/src/buildinfo-include.c"
" {\"AUTO-BUIDLINFO ${KEY}\", \"${VAL}\"},\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/buildinfo-summary.txt"
" * ${KEY}: ${VAL}\n")
message(STATUS "END buildinfo_item")
endfunction()

function(buildinfo_output)
message(STATUS "BEGIN buildinfo_output")
message(STATUS "END buildinfo_output")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/src/buildinfo-include.c"
" /* end of buildinfo-include.c */\n")
#file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/buildinfo-summary.txt"
# "\nThe End.\n")
file(READ "${CMAKE_CURRENT_BINARY_DIR}/buildinfo-summary.txt" msg)
message("\n${msg}")
# message(STATUS "END buildinfo_output")
endfunction()

buildinfo_setup()
25 changes: 13 additions & 12 deletions src/build-helpers/buildinfo.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ m4_pattern_forbid([^BUILDINFO_SETUP])dnl
dnl
AC_DEFUN([BUILDINFO_SETUP], [dnl
dnl AC_MSG_NOTICE([BEGIN ][[$0]])
cat>auto-buildinfo.msg<<EOF
cat>buildinfo-summary.txt<<EOF
AUTO-BUILDINFO
============
Configuration summary:
----------------------
EOF
cat>auto-buildinfo.c<<EOF
/* auto-buildinfo.c - DO NOT MODIFY THIS FILE! */
/* This include file auto-buildinfo.c is AUTOGENERATED by configure. */
cat>buildinfo-include.c<<EOF
/* buildinfo-include.c - DO NOT MODIFY THIS FILE! */
/* This include file buildinfo-include.c is AUTOGENERATED by configure. */
/* This file is meant to be \#include'ed, but is not a header file. */
EOF
dnl AC_MSG_NOTICE([END ][[$0]])
])dnl
Expand All @@ -36,8 +37,8 @@ dnl
AC_DEFUN([BUILDINFO_ITEM], [dnl
dnl AC_MSG_NOTICE([BEGIN ][[$0]])
AC_REQUIRE([BUILDINFO_SETUP])
printf " * %-15s %s\n" "$1:" "$2" >> auto-buildinfo.msg
printf " {\"AUTO-BUILDINFO %s\", \"%s\"},\n" "$1" "$2" >> auto-buildinfo.c
printf " * %-15s %s\n" "$1:" "$2" >> buildinfo-summary.txt
printf " {\"AUTO-BUILDINFO %s\", \"%s\"},\n" "$1" "$2" >> buildinfo-include.c
dnl AC_MSG_NOTICE([END ][[$0]])
])dnl
dnl
Expand All @@ -51,15 +52,15 @@ dnl
AC_DEFUN([BUILDINFO_OUTPUT], [dnl
dnl AC_MSG_NOTICE([BEGIN ][[$0]])
AC_REQUIRE([BUILDINFO_SETUP])
cat>>auto-buildinfo.msg<<EOF
cat>>buildinfo-summary.txt<<EOF
EOF
cat>>auto-buildinfo.c<<EOF
/* end of auto-buildinfo.c */
cat>>buildinfo-include.c<<EOF
/* end of buildinfo-include.c */
EOF
dnl AC_MSG_NOTICE([END ][[$0]])
cat auto-buildinfo.msg
cat buildinfo-summary.txt
])dnl
dnl
dnl ####################################################################
Expand Down
4 changes: 2 additions & 2 deletions src/build-helpers/buildinfo.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
EXTRA_DIST += build-helpers/buildinfo.m4
EXTRA_DIST += build-helpers/buildinfo.md

DISTCLEANFILES += auto-buildinfo.c
DISTCLEANFILES += auto-buildinfo.msg
DISTCLEANFILES += buildinfo-include.c
DISTCLEANFILES += buildinfo-summary.txt
2 changes: 1 addition & 1 deletion src/buildinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const avr_buildinfo libavrdude_buildinfo = {
{
{"buildsystem", AVRDUDE_BUILDSYSTEM},

#include <auto-buildinfo.c>
#include <buildinfo-include.c>

{"libelf",
#ifdef HAVE_LIBELF
Expand Down
2 changes: 2 additions & 0 deletions src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ BUILDINFO_ITEM([libelf], [yes])
BUILDINFO_ITEM([libelf], [no])
BUILDINFO_ITEM([libelf], [DO HAVE])
BUILDINFO_ITEM([libelf], [DON'T HAVE])

# print the output collected by earlier calls to BUILDINFO_ITEM()
BUILDINFO_OUTPUT()

echo ""
Expand Down

0 comments on commit ad4c30c

Please sign in to comment.