Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portable equivalent of GNU make %-style pattern rules

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.

like image 844
Wes Avatar asked Oct 15 '22 16:10

Wes


1 Answers

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 $@ $<
like image 72
adl Avatar answered Oct 20 '22 16:10

adl