Question

I'm following the directions on the Using Check with the Autotools page in an attempt to build in support for unit test in a (currently) small C project. Although I am using Cgreen instead of Check.

I'm having trouble with step 9, which is causing automake to emit a warning about the use of `%'-style pattern rules being a GNU make extension.

The particular make rule is:

check_%.$(OBJEXT) : $(srcdir)/%.c
    $(COMPILE) -DCHECKING -c -o $@ $^

I'm wondering if there is an equivalent way of specifying this rule that does not rely on gnu make extensions.

Was it helpful?

Solution

Portable make rules can only use different suffixes, the prefixes should be the same.

.c.o:
        $(COMPILE) -DCHECKING -c -o $@ $<

The suffix does not necessarily starts with a dot, however. (In that case you have to tell Automake what your suffixes are, because it cannot guess.) So for instance you could have something as follows if you rename check_showdns.o to showdns_check.o:

SUFFIXES = _check.o 
check_libapdns_LDADD        = @CHECK_LIBS@ showdns_check.o
.c_check.o:
        $(COMPILE) -DCHECKING -c -o $@ $<

OTHER TIPS

I'd rather try to disable the warning or just ignore it. GNU make exists for all relevant Unix-like platforms; there is no practical reason to spend time maintaining makefile portability. GNU make is also feature-wise superior to most other make dialects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top