bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ifeq and ifneq not working


From: Martin Dorey
Subject: Re: ifeq and ifneq not working
Date: Sat, 23 Apr 2016 17:23:20 +0000

TESTSRC depends on $@, an automatic variable set at the time of recipe execution.  ifneq by contrast runs earlier.  https://www.gnu.org/software/make/manual/html_node/Conditionals.html#Conditionals explains "Conditionals control what make actually “sees” in the makefile, so they cannot be used to control recipes at the time of execution".

On Apr 23, 2016, at 09:12, Sedrubal <address@hidden> wrote:

Hi,

I'm not sure but I think I found a bug in ifeq and ifneq:

My project structure is like this:

$ tree
.
├── Makefile
├── subprojA
│   ├── src.cpp
│   ├── Makefile
│   └── test.cpp
└── subprojA
   ├── src.cpp
   ├── Makefile
   └── test.cpp

The upper Makefile should run `make test` for each sub project if "test.cpp" is
in this folder.

My Makefile is like this:

SUBDIRS    := $(wildcard */)
TESTDIRS    := $(SUBDIRS:%=test-%)

.PHONY: test $(SUBDIRS) $(TESTDIRS)

all: $(SUBDIRS)

test: $(TESTDIRS)

$(SUBDIRS):
   CC=$(CC) CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' $(MAKE) all -C $@

$(TESTDIRS):
   $(eval TARGETDIR := $(@:test-%=%))
   $(eval TESTSRC := $(TARGETDIR)test.cpp)
   @echo "$(wildcard $(TESTSRC))" # <-- prints subproj{A,B}/test.cpp if it
exists -> this is working
ifneq ("$(wildcard $(TESTSRC))","")
   @#file exists --> but even if the test src exists, this will never be
reached
   CC=$(CC) CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' $(MAKE) test -C
$(TARGETDIR)
else
   @echo "[i] $(TARGETDIR) has no tests..."
endif

Can you explain, why this shouldn't work? Is this a bug or only a fail in
Makefile logic?

Best regards and grml,

Sedrubal
_______________________________________________
Bug-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-make

reply via email to

[Prev in Thread] Current Thread [Next in Thread]