Skip to content

Commit

Permalink
Abort build unless target is little endian
Browse files Browse the repository at this point in the history
  • Loading branch information
ndim committed Sep 5, 2024
1 parent 30e19f2 commit e73b71b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
# =====================================
Expand Down
17 changes: 17 additions & 0 deletions src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit e73b71b

Please sign in to comment.