Is Makefile.inc1 in 6 wrong?
Jung-uk Kim
jkim at FreeBSD.org
Tue Apr 4 22:51:17 UTC 2006
On Tuesday 04 April 2006 06:19 pm, Lars Eighner wrote:
> On Tue, 4 Apr 2006, Jung-uk Kim wrote:
> > On Tuesday 04 April 2006 05:32 pm, Lars Eighner wrote:
> >> On Tue, 4 Apr 2006, Jung-uk Kim wrote:
> >>> On Tuesday 04 April 2006 05:14 pm, Lars Eighner wrote:
> >>>> It appears to me that either I have a wrong version of awk or
> >>>> this Makefile.inc1 is wrong:
> >>>>
> >>>> #
> >>>> # $FreeBSD: src/Makefile.inc1,v 1.499.2.11 2006/04/04 14:24:03
> >>>> glebius Exp $ #
> >>>>
> >>>> <Snippage>
> >>>>
> >>>> MAKEOBJDIRPREFIX?= /usr/obj
> >>>> .if !defined(OSRELDATE)
> >>>> .if exists(/usr/include/osreldate.h)
> >>>> OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ {
> >>>> print $$3 }' \ /usr/include/osreldate.h
> >>>> .else
> >>>> OSRELDATE= 0
> >>>>
> >>>>
> >>>> In particular with the double dollar sign in the awk
> >>>> statement, I get no return, therefore OSRELDATE gets set to 0.
> >>>> The awk statement also fails from the command line. But if I
> >>>> use only one $, the awk statement succeeds.
> >>>>
> >>>> Is there a reason for the double dollar sign?
> >>>
> >>> Yes. See make(1):
> >>>
> >>> $ A single dollar sign `$', i.e. `$$' expands to a single
> >>> dollar sign.
>
> I think this is wrong for a SINGLE QUOTED argument to be passed
> to awk. The Makefile is wrong. I am right.
I think you are taking it too literally. Man page does not imply you
have to use quoted argument.
> >> Then why does it get the wrong answer?
> >
> > Because you ran it from command line. ;-) You can copy and paste
> > the same lines to *Makefile* like this:
> >
> > ------------
> > .if !defined(OSRELDATE)
> > .if exists(/usr/include/osreldate.h)
> > OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print
> > $$3 }' \ /usr/include/osreldate.h
> > .else
> > OSRELDATE= 0
> > .endif
> > .endif
> >
> > all:
> > @echo "reldate = ${OSRELDATE}"
> > ------------
> >
> > and run make. You will see something like this (depending on
> > your header file):
> >
> > %make
> > reldate = 600034
>
> But it doesn't
>
> [1;42;37mTue Apr 04 17:11:38 bash3.1:ttyp0:eighner
> goodwill~$[0mmake -V OSRELDATE -f /usr/src/Makefile.inc1
> 0
> [1;42;37mTue Apr 04 17:12:25 bash3.1:ttyp0:eighner
> goodwill~$[0mexit
> exit
>
> where /usr/include/osreldate.h =
>
> /*-
> * Copyright (c) 1992-2006 The FreeBSD Project.
> * All rights reserved.
>
> <snippage>
> * SUCH DAMAGE.
> *
> */
>
> #ifdef _KERNEL
> #error "<osreldate.h> cannot be used in the kernel, use
> <sys/param.h>" #else
> #undef __FreeBSD_version
> #define __FreeBSD_version 504105
> #endif
Works for me on two different machines:
%make -V OSRELDATE -f /usr/src/Makefile.inc1
600034
%awk -V
awk version 20050424 (FreeBSD)
and
%make -V OSRELDATE -f src/Makefile.inc1
700014
%awk -V
awk version 20050424 (FreeBSD)
> >> Also is there a difference when the accent mark is used in front
> >> instead of a real single quote?
> >
> > Where do you see it?
>
> Where you wrote:
> >>> $ A single dollar sign `$', i.e. `$$' expands to a single
> >>> dollar sign.
>
> And also in man make. The ` is an accent key, not a quote key.
> Yes, they are aka backticks and do mean something when they are
> paired, but `something' is nonsense so far as I can tell.
See above.
> Why would make tamper with anything in single quotes that is
> passed to a command? How do you write an argument for a command
> so that make won't tamper with it? What would double quoting
> the argument be for?
People (even me) get confused some times but make(1) is not sh(1).
Jung-uk Kim
More information about the freebsd-stable
mailing list