bug-make
[Top][All Lists]
Advanced

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

ifeq and ifneq not working


From: Sedrubal
Subject: ifeq and ifneq not working
Date: Sat, 23 Apr 2016 17:26:32 +0200

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

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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