diff --git a/CMakeLists.txt b/CMakeLists.txt index 67e384935..2c2f3dfdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,10 @@ # cmake -B build # cmake --build build +# Some useful tool versions to know about: +# cmake 3.14.0 2019-03-14 Current minimum requirement +# cmake 3.20.0 2021-03-23 Adds CMAKE_C_BYTE_ORDER + cmake_minimum_required(VERSION 3.14) project(avrdude VERSION 8.0 LANGUAGES C) @@ -51,6 +55,21 @@ include(GNUInstallDirs) set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}") set(AVRDUDE_FULL_VERSION ${CMAKE_PROJECT_VERSION}) + +# ===================================================================== +# Abort the build for non-little endian targets +# +# Our minimum cmake requirement is 3.14, so we cannot use +# CMAKE_C_BYTE_ORDER (cmake >= 3.20) to detect the byte order. +# ===================================================================== + +include (TestBigEndian) +test_big_endian(AVRDUDE_TARGET_IS_BIG_ENDIAN) +if(AVRDUDE_TARGET_IS_BIG_ENDIAN) + message(FATAL_ERROR "avrdude cannot be built for a Big Endian target at this time") +endif() + + # ===================================== # Get Git commit info # ===================================== diff --git a/src/configure.ac b/src/configure.ac index 91f6a4459..2476233fb 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -24,6 +24,7 @@ dnl dnl 2019-03-14 cmake 3.13 dnl dnl 2006-10-23 autoconf 2.60 used to be avrdude's requirement +dnl 2012-04-24 autoconf 2.62 AC_C_BIGENDIAN dnl 2012-04-24 autoconf 2.69 dnl 2021-01-28 autoconf 2.71 dnl @@ -169,6 +170,22 @@ fi dnl Makefile.am:77: compiling `config_gram.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac' AM_PROG_CC_C_O + +ad_target_is_little_endian=false +AC_C_BIGENDIAN([dnl +], [dnl + dnl Target is Little Endian, which avrdude actually supports. + ad_target_is_little_endian=: +], [dnl +], [dnl +]) + +AS_IF([$ad_target_is_little_endian], [dnl +], [dnl + AC_MSG_ERROR([avrdude only supports building for little endian targets at this time]) +]) + + # Checks for libraries. # For MinGW. AC_CHECK_LIB([ws2_32], [WSAStartup])