1 # $NetBSD: endian.mk,v 1.5 2007/03/08 23:11:20 rillig Exp $
3 # Determine the endianness of the platform by checking header files.
5 # This file is used as follows:
7 # .include "../../mk/endian.mk"
9 # .if ${MACHINE_ENDIAN} == "big"
10 # # ...big endian stuff...
11 # .elif ${MACHINE_ENDIAN} == "little"
12 # # ...little endian stuff...
14 # BROKEN= "Unknown endianness"
17 .
include "../../mk/bsd.prefs.mk"
19 .if
!defined
(MACHINE_ENDIAN
)
20 . if exists
(/usr
/include/endian.h
)
21 _ENDIAN_H
= endian.h
# Linux
22 . elif exists
(/usr
/include/sys
/endian.h
)
23 _ENDIAN_H
= sys
/endian.h
# NetBSD>=1.5
24 . elif exists
(/usr
/include/machine
/endian.h
)
25 _ENDIAN_H
= machine
/endian.h
# NetBSD<1.5
26 . elif exists
(/usr
/include/sys
/byteorder.h
)
27 _ENDIAN_H
= sys
/byteorder.h
# Solaris
33 { ${ECHO} "\#if defined(__sgi)"; \
34 ${ECHO} "\# include <standards.h>"; \
36 ${ECHO} "\#include <${_ENDIAN_H}>"; \
37 ${ECHO} "\#ifndef BYTE_ORDER"; \
38 ${ECHO} "\#ifdef _BIG_ENDIAN"; \
39 ${ECHO} "\#define BYTE_ORDER 4321"; \
41 ${ECHO} "\#define BYTE_ORDER 1234"; \
44 ${ECHO} "BYTE_ORDER"; } |
${CC} -E
- | \
45 { while read line
; do \
47 1234) ${ECHO} "little"; exit
0 ;; \
48 4321) ${ECHO} "big"; exit
0 ;; \
53 MAKEFLAGS
+= MACHINE_ENDIAN
=${MACHINE_ENDIAN
:Q
}