Skip to content

Commit e73b71b

Browse files
committed
Abort build unless target is little endian
1 parent 30e19f2 commit e73b71b

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
# cmake -B build
2121
# cmake --build build
2222

23+
# Some useful tool versions to know about:
24+
# cmake 3.14.0 2019-03-14 Current minimum requirement
25+
# cmake 3.20.0 2021-03-23 Adds CMAKE_C_BYTE_ORDER
26+
2327
cmake_minimum_required(VERSION 3.14)
2428
project(avrdude VERSION 8.0 LANGUAGES C)
2529

@@ -51,6 +55,21 @@ include(GNUInstallDirs)
5155
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
5256
set(AVRDUDE_FULL_VERSION ${CMAKE_PROJECT_VERSION})
5357

58+
59+
# =====================================================================
60+
# Abort the build for non-little endian targets
61+
#
62+
# Our minimum cmake requirement is 3.14, so we cannot use
63+
# CMAKE_C_BYTE_ORDER (cmake >= 3.20) to detect the byte order.
64+
# =====================================================================
65+
66+
include (TestBigEndian)
67+
test_big_endian(AVRDUDE_TARGET_IS_BIG_ENDIAN)
68+
if(AVRDUDE_TARGET_IS_BIG_ENDIAN)
69+
message(FATAL_ERROR "avrdude cannot be built for a Big Endian target at this time")
70+
endif()
71+
72+
5473
# =====================================
5574
# Get Git commit info
5675
# =====================================

src/configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dnl
2424
dnl 2019-03-14 cmake 3.13
2525
dnl
2626
dnl 2006-10-23 autoconf 2.60 used to be avrdude's requirement
27+
dnl 2012-04-24 autoconf 2.62 AC_C_BIGENDIAN
2728
dnl 2012-04-24 autoconf 2.69
2829
dnl 2021-01-28 autoconf 2.71
2930
dnl
@@ -169,6 +170,22 @@ fi
169170
dnl Makefile.am:77: compiling `config_gram.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
170171
AM_PROG_CC_C_O
171172

173+
174+
ad_target_is_little_endian=false
175+
AC_C_BIGENDIAN([dnl
176+
], [dnl
177+
dnl Target is Little Endian, which avrdude actually supports.
178+
ad_target_is_little_endian=:
179+
], [dnl
180+
], [dnl
181+
])
182+
183+
AS_IF([$ad_target_is_little_endian], [dnl
184+
], [dnl
185+
AC_MSG_ERROR([avrdude only supports building for little endian targets at this time])
186+
])
187+
188+
172189
# Checks for libraries.
173190
# For MinGW.
174191
AC_CHECK_LIB([ws2_32], [WSAStartup])

0 commit comments

Comments
 (0)