#20 Syntax error with $(warning text...)


Given the makefile "test_if.mk" like so:

#condition-is-not-a-and-b := condition
and-op = $(strip $(1))-and-$(strip $(2))
not-op = not-$(strip $(1))
if-result = $(if $(condition-is-$(call not-op, $(call and-op, a, b))),then-part,else-part)
.PHONY: default
$(warning $(if-result) = $$(if $(condition-is-$(call not-op, $(call and-op, a, b))),then-part,else-part))

% make -f test_if.mk
test_if.mk:7: else-part = $(if ,then-part,else-part)
make: Nothing to be done for `default'.
sunnyvale [no job set:~/Desktop] 182% make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

This program built for x86_64-redhat-linux-gnu
% makepp -f test_if.mk
makepp: Loading makefile `/usr/home/jkankiewi/Desktop/test_if.mk'
makepp: warning: else-part = $(if ,then-part,else-part at `/usr/home/jkankiewi/Desktop/test_if.mk:6'
makepp: Entering directory `/usr/home/jkankiewi/Desktop'
/bin/sh: -c: line 0: syntax error near unexpected token `)'
/bin/sh: -c: line 0: `)'
makepp: error: Failed to build target `/usr/home/jkankiewi/Desktop/default' [2]
makepp: 0 files updated, 0 phony targets built and 1 target failed
% makepp --version
makepp version 1.50-08049-07304-07191
Makepp may be copied only under the terms of either the Artistic License or
the GNU General Public License, either version 2, or (at your option) any
later version.
For more details, see the makepp homepage at http://makepp.sourceforge.net.


  • Jason Kankiewicz

    Logged In: YES
    Originator: YES

    The problem is caused by makepp's parser's failure to consume the closing ')' of the '$(warning...' when it contains an '$'-escaped literal. In this case it's "$$(if ...".

  • Daniel Pfeiffer

    Daniel Pfeiffer - 2009-07-06

    I would consider makepp's behaviour correct here, in that it skips nested $(), $(()), ${} and ${{}}. $$() otoh, is not a meaningful make construct, so there is no need to skip it, making the ) end $(warning) and leaving a trailing ).

    The problem is that gmake also skips nested () and I don't know why it would do that. Is it worthwhile adapting (major change) makepp's parser to match this?

  • Daniel Pfeiffer

    Daniel Pfeiffer - 2009-07-06
    • status: open --> open-later
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2011-11-23
    • status: open-later --> closed-later
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2011-11-23

    It's not a bug, it's a feature: unlike gmake, makepp does not consider lonely parentheses as special, only those following $ must be paired. This allows using parentheses freely in $(shell) or $(perl). Where this is an issue, put parentheses into ${...} and vice versa, or use double $((...)) which may include single parentheses.

    While this is more flexible than gmake's pairing of all parentheses, it poses a problem for some legacy makefiles. To address this, version 2.1 may provide a command line option to do things the old way. But for now, you must transform this to the mpp way, e.g. ${warning $$(...)}


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks