diff options
author | jlam <jlam@pkgsrc.org> | 2005-04-30 03:01:06 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2005-04-30 03:01:06 +0000 |
commit | 183c1ce2f5b0b5384fddbf266e7410cd38a402a4 (patch) | |
tree | ec23d78c3bc3ad54940ccd5db519766e2db63150 /mk/endian.mk | |
parent | a6fed947f8ec2852b13ba25af225e6519398ae49 (diff) | |
download | pkgsrc-183c1ce2f5b0b5384fddbf266e7410cd38a402a4.tar.gz |
Rewrite to avoid needing egrep.
Diffstat (limited to 'mk/endian.mk')
-rw-r--r-- | mk/endian.mk | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/mk/endian.mk b/mk/endian.mk index 341ac3966a0..f08b5ac6b04 100644 --- a/mk/endian.mk +++ b/mk/endian.mk @@ -1,4 +1,4 @@ -# $NetBSD: endian.mk,v 1.3 2004/02/06 19:04:25 jlam Exp $ +# $NetBSD: endian.mk,v 1.4 2005/04/30 03:01:06 jlam Exp $ # # Determine the endianness of the platform by checking header files. # @@ -15,37 +15,37 @@ # .endif .include "../../mk/bsd.prefs.mk" + .if !defined(MACHINE_ENDIAN) -_ENDIAN_H_FILES= /usr/include/endian.h # Linux -_ENDIAN_H_FILES+= /usr/include/sys/endian.h # NetBSD=>1.5 -_ENDIAN_H_FILES+= /usr/include/machine/endian.h # NetBSD<1.5 -_ENDIAN_H_FILES+= /usr/include/sys/byteorder.h # Solaris -_ENDIAN_H_FILES+= /dev/null -. for FILE in ${_ENDIAN_H_FILES} -. if !defined(_ENDIAN_H) -. if exists(${FILE}) -_ENDIAN_H?= ${FILE:S/\/usr\/include\///} -. endif -. endif -. endfor +. if exists(/usr/include/endian.h) +_ENDIAN_H= /usr/include/endian.h # Linux +. elif exists(/usr/include/sys/endian.h) +_ENDIAN_H= /usr/include/sys/endian.h # NetBSD>=1.5 +. elif exists(/usr/include/machine/endian.h) +_ENDIAN_H= /usr/include/machine/endian.h # NetBSD<1.5 +. elif exists(/usr/include/sys/byteorder.h) +_ENDIAN_H= /usr/include/sys/byteorder.h # Solaris +. else +_ENDIAN_H= /dev/null +. endif + MACHINE_ENDIAN!= \ - byte_order=` \ - ( \ - ${ECHO} "\#include <${_ENDIAN_H}>"; \ - ${ECHO} "\#ifndef BYTE_ORDER"; \ - ${ECHO} "\#ifdef _BIG_ENDIAN"; \ - ${ECHO} "\#define BYTE_ORDER 4321"; \ - ${ECHO} "\#else"; \ - ${ECHO} "\#define BYTE_ORDER 1234"; \ - ${ECHO} "\#endif"; \ - ${ECHO} "\#endif"; \ - ${ECHO} "BYTE_ORDER"; \ - ) | ${CC} -E - | ${EGREP} "^(1234|4321)" \ - `; \ - case `${ECHO} $${byte_order}` in \ - 1234) ${ECHO} little ;; \ - 4321) ${ECHO} big ;; \ - *) ${ECHO} unknown ;; \ - esac -MAKEFLAGS+= MACHINE_ENDIAN=${MACHINE_ENDIAN} + { ${ECHO} "\#include <${_ENDIAN_H}>"; \ + ${ECHO} "\#ifndef BYTE_ORDER"; \ + ${ECHO} "\#ifdef _BIG_ENDIAN"; \ + ${ECHO} "\#define BYTE_ORDER 4321"; \ + ${ECHO} "\#else"; \ + ${ECHO} "\#define BYTE_ORDER 1234"; \ + ${ECHO} "\#endif"; \ + ${ECHO} "\#endif"; \ + ${ECHO} "BYTE_ORDER"; } | ${CC} -E - | \ + { while read line; do \ + case $$line in \ + 1234) ${ECHO} "little"; exit 0 ;; \ + 4321) ${ECHO} "big"; exit 0 ;; \ + esac; \ + done; \ + ${ECHO} "unknown"; } + +MAKEFLAGS+= MACHINE_ENDIAN=${MACHINE_ENDIAN:Q} .endif |