Subject: toolchain/17309: Avoid depending on sys/endian.h
To: None <gnats-bugs@gnats.netbsd.org>
From: Ian Dall <Ian.Dall@dsto.defence.gov.au>
List: netbsd-bugs
Date: 06/19/2002 15:56:30
>Number:         17309
>Category:       toolchain
>Synopsis:       Avoid depending on sys/endian.h
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 18 23:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ian Dall
>Release:        NetBSD 1.5ZC
>Organization:
private
>Environment:
	
	
System: Linux paprika 2.4.17 #2 Wed Jan 30 09:35:56 CST 2002 i686 unknown
Architecture:
Machine: i686
>Description:
When cross building on non NetBSD hosts, sys/machine may not exist. Some of
tools/compat require sys/endian.h for the HOST.

>How-To-Repeat:
	
>Fix:
	
Here is a patch to test for host endianness and create a sys/endian.h.

Index: netbsd/src/tools/compat/configure.ac
diff -c netbsd/src/tools/compat/configure.ac:1.1.1.8 netbsd/src/tools/compat/configure.ac:1.2
*** netbsd/src/tools/compat/configure.ac:1.1.1.8	Mon Apr 29 23:01:49 2002
--- netbsd/src/tools/compat/configure.ac	Fri Jun  7 16:44:19 2002
***************
*** 51,56 ****
--- 51,72 ----
  		mv -f include/$ac_header.new include/$ac_header
  	fi])
  
+ AC_C_BIGENDIAN
+ AC_CHECK_HEADERS(sys/endian.h,,
+ 	[echo '#include "config.h"' >include/$ac_header.new
+ 	echo '#define LITTLE_ENDIAN 1234' >>include/$ac_header.new
+ 	echo '#define BIG_ENDIAN 4321' >>include/$ac_header.new
+ 	echo '#ifdef WORDS_BIGENDIAN' >>include/$ac_header.new
+ 	echo '#define BYTE_ENDIAN BIG_ENDIAN' >>include/$ac_header.new
+ 	echo '#else' >>include/$ac_header.new
+ 	echo '#define BYTE_ENDIAN LITTLE_ENDIAN' >>include/$ac_header.new
+ 	echo '#endif' >>include/$ac_header.new
+ 	if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
+ 		rm -f include/$ac_header.new
+ 	else
+ 		mv -f include/$ac_header.new include/$ac_header
+ 	fi])
+ 
  # Typedefs.
  AC_TYPE_SIZE_T
  AC_CHECK_TYPES([id_t, long long, u_quad_t])
>Release-Note:
>Audit-Trail:
>Unformatted: