Subject: Re: bi-endian etc/pwd.db
To: None <tech-userlevel@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-userlevel
Date: 11/26/2000 11:48:47
Todd Vierling wrote:
> On Sat, 25 Nov 2000, Jaromír Dolecek wrote:
>
> : > Anyone against putting:
> : >
> : > TARGET_ENDIANNESS!= \
> : > printf "\#include <machine/endian_machdep.h>\n_BYTE_ORDER\n" | \
> : > ${CC} -I${DESTDIR}/usr/include -E - | tail -1
> :
> : Ah, true :) I was wondering how one can make echo print newline portably
> : and forgot printf completely :)
>
> There's an easier solution which is already used for the HAVE_GCC28
> definitions (and thus should be reused for uniformity). Just add "; echo"
> to the end of the command to add an extra newline. The make(1) program
> strips this as whitespace.
Ok, how about:
Index: Makefile
===================================================================
RCS file: /cvsroot/basesrc/etc/Makefile,v
retrieving revision 1.170
diff -d -p -u -r1.170 Makefile
--- Makefile 2000/11/09 20:01:54 1.170
+++ Makefile 2000/11/26 00:47:21
@@ -121,8 +121,9 @@ PCS= pcs750.bin
# find out endianness of target and set proper flag for pwd_mkdb so that
# it creates database in same endianness
.if exists(${DESTDIR}/usr/include/machine/endian_machdep.h)
-TARGET_ENDIANNESS!= awk '/_BYTE_ORDER/{print $$3}' \
- ${DESTDIR}/usr/include/machine/endian_machdep.h
+TARGET_ENDIANNESS!= \
+ ( echo "\#include <machine/endian_machdep.h>" ; echo _BYTE_ORDER ) | \
+ ${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}'
.else
TARGET_ENDIANNESS=
.endif
This doesn't rely on printf(1) being available (better for cross compiling).
Simon.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Sales, Support and Service: http://www.wasabisystems.com/