From owner-freebsd-doc@FreeBSD.ORG Fri Oct 25 07:43:05 2013 Return-Path: Delivered-To: freebsd-doc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5105B617 for ; Fri, 25 Oct 2013 07:43:05 +0000 (UTC) (envelope-from kuuse.redantigua@gmail.com) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [IPv6:2607:f8b0:400c:c01::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0DD92240E for ; Fri, 25 Oct 2013 07:43:04 +0000 (UTC) Received: by mail-ve0-f173.google.com with SMTP id jw12so2261623veb.4 for ; Fri, 25 Oct 2013 00:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=lo7GqNKSv0vsboscq1LeajgoDIQaOtVwYTWKUlzVloE=; b=aAAC7j5Kmklkuiw7dKGmOuJ5/hWlIln3hz0pZ4Ob2xiZrAGDUBWQt+zejt04CKdorJ dHhYpHls5EL1TOYnjGRcir/0uOFnK6XFhHz4IljqPWh3+JKnqctZx1tiC2x176tBiF14 6VGjRIk13HwChBYG8fF83rd8cePP1Iv1C04fzcCki+xzv53Wnl9TZ+BU00LSyJctyu3t t6xtrp6+/PayfFcZegVqJUlQCNZ3WhQ++MeKZrV9g840Ue5Cl3IoWp0pvoS80u+N3Dln aqLrLRa020woIzaoC+FY3c2tc1g7dlOU6VugJvp5BQO3u/evx4amDw7wEVG/mpPdbwm9 JOGA== MIME-Version: 1.0 X-Received: by 10.52.171.79 with SMTP id as15mr3192535vdc.1.1382686984094; Fri, 25 Oct 2013 00:43:04 -0700 (PDT) Sender: kuuse.redantigua@gmail.com Received: by 10.58.2.106 with HTTP; Fri, 25 Oct 2013 00:43:04 -0700 (PDT) In-Reply-To: <20131024214923.CB0AF5807E@chaos.jnpr.net> References: <20131024214923.CB0AF5807E@chaos.jnpr.net> Date: Fri, 25 Oct 2013 09:43:04 +0200 X-Google-Sender-Auth: S4gntjPSzbZkM6gD34Df7iyHXbo Message-ID: Subject: Re: FreeBSD Make question From: Johan Kuuse To: "Simon J. Gerraty" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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 07:43:05 -0000 On Thu, Oct 24, 2013 at 11:49 PM, Simon J. Gerraty wrote: > >Simon: do we allow whitespace in target names in either fmake or bmake? > >If so, what are the escaping rules? > Thanks Benjamin for the hints, I'll check out the -hackers list. > > Whether it is "allowed" or not, it isn't something I would consider > doing. > Hi Simon, I definitely agree that whitespaces shouldn't go into targets if it could be avoided. 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 contains whitespaces? (God forbid!) > > 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