Subject: Re: Makefile.mbr problem - fix?
To: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
From: Darrin B. Jewell <dbj@netbsd.org>
List: tech-toolchain
Date: 05/05/2003 10:15:53
Hubert,
Thanks for noticing that this doesn't work in our shell and fixing
our tree quickly. I had been cross compiling and therefore didn't
notice the problem.
However, I did consult the SUSv3 before making this change. It would
appear that our shell is out of spec.
From the SUSv3 on arithmetic expansion in the shell:
"Only the decimal-constant, octal-constant, and hexadecimal-constant
constants specified in the ISO C standard, Section 6.4.4.1 are
required to be recognized as constants."
I will file a PR about the shell bug.
Thanks,
Darrin
Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de> writes:
> Regarding the recent problems in sys/arch/i386/stand/mbr/Makefile.mbr that
> arise because our /bin/sh doesn't want to properly convert a hex value
> into a decimal value (" echo $(( 0xdeadbeef )) "), below's a possible
> solution that uses nm(1) to do the conversion to dec.
>
> Problem is that it uses sed(1) to strip leading zeroes, and I'm not sure
> that's ok. At least there is no $(SED) macro defined, is it ok to use
> sed(1) in that way? (Thinking about cross builds...)
>
>
> - Hubert
>
> Index: Makefile.mbr
> ===================================================================
> RCS file: /cvsroot/src/sys/arch/i386/stand/mbr/Makefile.mbr,v
> retrieving revision 1.2
> diff -u -r1.2 Makefile.mbr
> --- Makefile.mbr 2003/05/05 02:47:42 1.2
> +++ Makefile.mbr 2003/05/05 13:16:01
> @@ -26,8 +26,8 @@
>
> ${PROG}: ${OBJS}
> ${LD} -o ${PROG}.tmp ${LDFLAGS} -Ttext 0x600 ${OBJS}
> - @ set -- $$( ${NM} -t x ${PROG}.tmp | grep '\<mbr_space\>' ); \
> - echo "#### There are $$((0x$$1)) free bytes in ${PROG}"
> + @ set -- $$( ${NM} -t d ${PROG}.tmp | grep '\<mbr_space\>' | sed 's/^0*//' ); \
> + echo "#### There are $$1 free bytes in ${PROG}"
> ${OBJCOPY} -O binary ${PROG}.tmp ${PROG}
> rm -f ${PROG}.tmp
>
> --
> Want to get a clue on IPv6 but don't know where to start? Try this:
> * Basics -> http://www.onlamp.com/pub/a/onlamp/2001/05/24/ipv6_tutorial.html
> * Setup -> http://www.onlamp.com/pub/a/onlamp/2001/06/01/ipv6_tutorial.html
> Of course with your #1 IPv6 ready operating system -> http://www.NetBSD.org/