From owner-freebsd-doc@FreeBSD.ORG Fri Oct 25 18:33:10 2013 Return-Path: Delivered-To: freebsd-doc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C1A99994 for ; Fri, 25 Oct 2013 18:33:10 +0000 (UTC) (envelope-from sjg@juniper.net) Received: from co1outboundpool.messaging.microsoft.com (co1ehsobe001.messaging.microsoft.com [216.32.180.184]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7FF452916 for ; Fri, 25 Oct 2013 18:33:10 +0000 (UTC) Received: from mail66-co1-R.bigfish.com (10.243.78.250) by CO1EHSOBE020.bigfish.com (10.243.66.83) with Microsoft SMTP Server id 14.1.225.22; Fri, 25 Oct 2013 17:47:46 +0000 Received: from mail66-co1 (localhost [127.0.0.1]) by mail66-co1-R.bigfish.com (Postfix) with ESMTP id 44D2EC00269; Fri, 25 Oct 2013 17:47:46 +0000 (UTC) X-Forefront-Antispam-Report: CIP:66.129.224.54; KIP:(null); UIP:(null); IPV:NLI; H:P-EMF01-SAC.jnpr.net; RD:none; EFVD:NLI X-SpamScore: 5 X-BigFish: VPS5(zz98dI9371Ic85dh1432I7cabkzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6h1082kzz8275ch1de098h1de097h74efjz2fh2a8h839hd25hf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1b88h1fb3h1d0ch1d2eh1d3fh1de2h1dfeh1dffh1e23h1fe8h1ff5h1155h) Received-SPF: pass (mail66-co1: domain of juniper.net designates 66.129.224.54 as permitted sender) client-ip=66.129.224.54; envelope-from=sjg@juniper.net; helo=P-EMF01-SAC.jnpr.net ; SAC.jnpr.net ; Received: from mail66-co1 (localhost.localdomain [127.0.0.1]) by mail66-co1 (MessageSwitch) id 1382723242708060_11588; Fri, 25 Oct 2013 17:47:22 +0000 (UTC) Received: from CO1EHSMHS016.bigfish.com (unknown [10.243.78.249]) by mail66-co1.bigfish.com (Postfix) with ESMTP id AA13D4005D; Fri, 25 Oct 2013 17:47:22 +0000 (UTC) Received: from P-EMF01-SAC.jnpr.net (66.129.224.54) by CO1EHSMHS016.bigfish.com (10.243.66.26) with Microsoft SMTP Server (TLS) id 14.16.227.3; Fri, 25 Oct 2013 17:47:22 +0000 Received: from magenta.juniper.net (172.17.27.123) by P-EMF01-SAC.jnpr.net (172.24.192.21) with Microsoft SMTP Server (TLS) id 14.3.146.0; Fri, 25 Oct 2013 10:47:21 -0700 Received: from chaos.jnpr.net (chaos.jnpr.net [172.24.29.229]) by magenta.juniper.net (8.11.3/8.11.3) with ESMTP id r9PHlKL12314; Fri, 25 Oct 2013 10:47:20 -0700 (PDT) (envelope-from sjg@juniper.net) Received: from chaos.jnpr.net (localhost [127.0.0.1]) by chaos.jnpr.net (Postfix) with ESMTP id 870B35807E; Fri, 25 Oct 2013 10:47:20 -0700 (PDT) To: Johan Kuuse Subject: Re: FreeBSD Make question In-Reply-To: References: <20131024214923.CB0AF5807E@chaos.jnpr.net> Comments: In-reply-to: Johan Kuuse message dated "Fri, 25 Oct 2013 09:43:04 +0200." From: "Simon J. Gerraty" X-Mailer: MH-E 7.82+cvs; nmh 1.3; GNU Emacs 22.3.1 Date: Fri, 25 Oct 2013 10:47:20 -0700 Message-ID: <20131025174720.870B35807E@chaos.jnpr.net> MIME-Version: 1.0 Content-Type: text/plain X-OriginatorOrg: juniper.net X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: freebsd-doc@freebsd.org X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 18:33:10 -0000 On Fri, 25 Oct 2013 09:43:04 +0200, Johan Kuuse writes: >The background is that I'm trying to create a system of nonrecursive >Makefiles, where all paths must be absolute. >This implies using absolute paths as target names. This works fine - my dirdeps.mk uses absolute paths of directories (plus added attributes) as targets >What if a path contains whitespaces? (God forbid!) You lose. Ideally you throw an error. .error "Sorry ${USER}, I cannot let you do that" Alternatively you could try substituting the spaces with glob chars. That may cause more trouble than it fixes. fixing make to handle this would not be trivial. > >> >> What is the problem we are trying to solve? >> >> >Problem described above, below goes a sample Makefile, trying several ways >to escaping whitespaces in target names. > >The Makefile: > >Makefile.freebsd-questions >-------- ># MY_TARGET=/home/joe/directory name with spaces/hello.c ># MY_SECOND_TARGET=/home/joe/directory name with spaces/world.c > ># MY_TARGET='/home/joe/directory name with spaces/hello.c' ># MY_SECOND_TARGET='/home/joe/directory name with spaces/world.c' > ># MY_TARGET="/home/joe/directory name with spaces/hello.c" ># MY_SECOND_TARGET="/home/joe/directory name with spaces/world.c" > >MY_TARGET=/home/joe/directory\ name\ with\ spaces/hello.c >MY_SECOND_TARGET=/home/joe/directory\ name\ with\ spaces/world.c > >all: ${MY_TARGET} ${MY_SECOND_TARGET} >@echo This is Make version $(MAKE_VERSION) > >${MY_TARGET}: > @echo $@ > >${MY_SECOND_TARGET}: > @echo $@ >-------- > >The output: > >FreeBSD Make: >make -f Makefile.freebsd-questions >-------- >"Makefile.freebsd-questions", line 20: warning: duplicate script for target >"/home/joe/directory\" ignored >"Makefile.freebsd-questions", line 20: warning: duplicate script for target >"name\" ignored >"Makefile.freebsd-questions", line 20: warning: duplicate script for target >"with\" ignored >/home/joe/directory\ >name\ >with\ >spaces/hello.c >spaces/world.c >This is Make version 9201120530 >-------- > >GNU Make: >gmake -f Makefile.freebsd-questions >-------- >/home/joe/directory name with spaces/hello.c >/home/joe/directory name with spaces/world.c >This is Make version 3.82 >-------- > > >The only possible workaround I have found so far with FreeBSD Make, is >to substitute whitespaces with another character in the target >variables, for example '+', (i.e. >/home/joe/directory+name+with+spaces/hello.c) and using the modified >variable as the target name. In the target rule, the variable >substitution then has to be "reversed" to obtain the "real" target >name: > ># MY_TARGET=/home/joe/directory name with spaces/hello.c# >MY_TARGET_PLUS != echo "$(MY_TARGET)" | sed -e 's/ /+/g' > > >${MY_TARGET_PLUS}: @echo "${@:C/\+/ /g}" > >Using this ugly hack, the warnings disappears in the example above, but it >doesn't really resolve the problem, as MY_TARGET_PLUS will always be a >non-existing target. So using this hack, targets will always be >executed/rebuilt, even if MY_TARGET is up to date. >Best regards, Johan Kuuse > >--047d7b6d91d485fa2504e98be68f >Content-Type: text/html; charset="ISO-8859-1" >Content-Transfer-Encoding: quoted-printable > >

= >On Thu, Oct 24, 2013 at 11:49 PM, Simon J. Gerraty < href=3D"mailto:sjg@juniper.net" target=3D"_blank">sjg@juniper.net><= >/span> wrote:
>
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p= >adding-left:1ex">
>Simon: do we allow whitespace in tar= >get names in either fmake or bmake?
> >>If so, what are the escaping rules?

v>
Thanks Benjamin for the hints, I'll check out the -hackers list.= >
=A0
px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);borde= >r-left-style:solid;padding-left:1ex"> >
>
>
Whether it is "allowed" or not, it isn't something I wo= >uld consider
>doing.

Hi Simon,
I definitely= > agree that whitespaces shouldn't go into targets if it could be avoide= >d.

The background is that I'm trying to create= > a system of nonrecursive Makefiles, where all paths must be absolute.> >
This implies using absolute paths as target names. What if a path cont= >ains whitespaces? (God forbid!)
=A0
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;borde= >r-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> > >
>What is the problem we are trying to solve?
>

Problem described above, below goes a = >sample Makefile, trying several ways to escaping whitespaces in target name= >s.

The Makefile:=A0
"gmail_extra"> >
or:rgb(0,0,0)">Makefile.freebsd-questions
--------
# MY_TARGET=3D/hom= >e/joe/directory name with spaces/hello.c
# MY_SECOND_TARGET=3D/home/joe/= >directory name with spaces/world.c
>
# MY_TARGET=3D'/home/joe/directory name with spaces/hello.c'r># MY_SECOND_TARGET=3D'/home/joe/directory name with spaces/world.c= >9;

# MY_TARGET=3D"/home/joe/directory name with spaces/hello.c= >"
># MY_SECOND_TARGET=3D"/home/joe/directory name with spaces/world.c&quo= >t;

MY_TARGET=3D/home/joe/directory\ name\ with\ spaces/hello.c
M= >Y_SECOND_TARGET=3D/home/joe/directory\ name\ with\ spaces/world.c

a= >ll: ${MY_TARGET} ${MY_SECOND_TARGET}
>@echo This is Make version $(MAKE_VERSION)

${MY_TARGET}:
@ec= >ho $@

${MY_SECOND_TARGET}:
@echo $@
--------

>
lor:rgb(0,0,0)">
>The o=
>utput:=A0 

FreeBSD Make:
make -f Makefile.freebsd-questio= >ns
--------
"Makefile.freebsd-questions", line 20: warning:= > duplicate script for target
>"/home/joe/directory\" ignored
"Makefile.freebsd-question= >s", line 20: warning: duplicate script for target
"name\"= > ignored
"Makefile.freebsd-questions", line 20: warning: dupli= >cate script for target
>"with\" ignored
/home/joe/directory\
name\
with\
spac= >es/hello.c
spaces/world.c
This is Make version 9201120530
--------= >

GNU Make:
gmake -f Makefile.freebsd-questions
--------
>/home/joe/directory name with spaces/hello.c
/home/joe/directory name wi= >th spaces/world.c
This is Make version 3.82
--------
=A0
id=3D"text-2" class=3D"" style=3D"margin-left:10px">gb(34,34,34);font-size:small;font-family:arial">The only possible workaroun= >d I have found so far with FreeBSD Make, is (34,34,34);font-family:arial">to substitute whitespaces with another charac= >ter in the target variables, for example '+', (i.e.le=3D"color:rgb(34,34,34);font-family:arial">=A0:rgb(0,0,0);font-family:arial">/home/joe/directory+name+with+spaces/hello.c= >) and using th= >e modified variable as the target name. In the target rule, the variable su= >bstitution then has to be "reversed" to obtain the "real&quo= >t; target name:
>
id=3D"text-2" class=3D"" style=3D"margin-left:10px">"># MY_TARGET=3D/home/joe/directory name with spaces/hello.c ># MY_TARGET_PLUS = >!=3D echo "$(>MY_TARGET)"=A0|<= >span style=3D"color:rgb(0,0,0);font-family:arial"> sed -e 's/ /+/g'= >
>
<=
>span style=3D"font-family:arial">
>${MY_TARGET_PLUS}:
>    @echo "$e=3D"font-family:arial">{@:C/n>\+al">/ /g}t-family:arial">"
>
>
Using th= >is ugly hack, the warnings disappears in the example above, but it doesn= >9;t really resolve the problem, as ont-family:arial">MY_TARGET_PLUS w= >ill always be a non-existing target. So using this hack, targets will alway= >s be executed/rebuilt, even if family:arial">MY_TARGET is up to date.al">
>
>Best regards, >Johan Kuuse
v> > >--047d7b6d91d485fa2504e98be68f--