automake
[Top][All Lists]
Advanced

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

Re: building executables with pattern rules


From: Will Estes
Subject: Re: building executables with pattern rules
Date: Fri, 18 Jul 2014 16:33:31 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

The % should have been present in the rule. I added it in and reran things and 
yes, the rules are copied in. I note that explicit rules for the individual 
programs are also copied in, so I assume that's what is overriding the pattern 
rules.

I can't do this with suffix rules since $(EXE) when it's nonempty has a . in 
it, so...

.opt$(EXE).$(OBJEXT):
        $(LINK) -o $@ $<
    
would be invalid as asuffix rule specifier, for example. So, I'm stuck with 
pattern rules -- or enumerating out a long list of individual rules.

On Friday, 18 July 2014,  9:03 pm +0100, Gavin Smith <address@hidden> wrote:

> On Mon, Jul 14, 2014 at 6:49 PM, Will Estes <address@hidden> wrote:
> > I have the following in my Makefile.am, and automake is not using the rule 
> > to build the executable.
> >
> > tableopts_nr%.c: tableopts.l4
> >         $(FLEX) -P $(subst -,_,$(*F)) $* -o $@ $<
> >
> > tableopts_nr%.$(OBJEXT): tableopts_nr%.c
> >         $(COMPILE) -c -o $@ $<
> >
> > tableopts_nr%.tableopts$(EXEEXT): tableopts_nr.$(OBJEXT)
> >         $(LINK) $^
> >
> > The % is matching various things like -Ca and so on that are options to 
> > flex for different kinds of tables that flex can produce. This is in the 
> > test suite and I've generated the long list of _SOURCES variables and the 
> > programs are listed in CHECK_PROGRAMS and TESTS.
> >
> > The .tableopts  suffix is present because I'm using the parallel test 
> > harness to distinguish between various kinds of tests in the flex test 
> > suite that need different kinds of arguments when they're run.
> >
> > THe output from trying to build the program with the Makefile.am as above 
> > looks like this:
> >
> > /bin/bash ../libtool  --tag=CC   --mode=link gcc  -g -O2   -o 
> > tableopts_nr-Ca.tableopts   -lm
> > libtool: link: gcc -g -O2 -o tableopts_nr-Ca.tableopts  -lm
> > /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In 
> > function `_start':
> > (.text+0x20): undefined reference to `main'
> > collect2: error: ld returned 1 exit status
> >
> > As a test, I did try explicitly listing tableopts_nr-Ca.tableopts$(EXEEXT) 
> > as a target and make did build the program correctly.
> >
> > How do I get automake to recognize my pattern rule? Or, if there's another 
> > way to do this that's easier / better, what is that?
> 
> Try checking your generated "Makefile.in" and "Makefile" files to see
> if automake has copied these rules through. If not, it could be
> because automake doesn't recognize GNU make extensions (pattern rules
> with % don't exist in some other make programs). However, if it did
> succeed in passing them through, it could be a problem with your
> rules. I thought it was strange that in the rule
> 
> > tableopts_nr%.tableopts$(EXEEXT): tableopts_nr.$(OBJEXT)
> >         $(LINK) $^
> 
> the object file doesn't have a % in it (so the same file will be used
> for all matches of this pattern), but in
> 
> 
> > tableopts_nr%.$(OBJEXT): tableopts_nr%.c
> >         $(COMPILE) -c -o $@ $<
> 
> there is a % there. Try making a simple Makefile to check the logic of
> your rules first and then try to incorporate it in your Makefile.am.



reply via email to

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