Hi.  I have been trying to add support for our ESQL/C preprocessor to an
Automake makefile, but I'm having trouble with a couple of different
things.

1st, we're doing the primary work on this internal project under linux,
so I stole the dependency stuff from the Makefile.in (probably a bad
idea), but here's the current rule I have:

SUFFIXES                = .o .ec

.ec.o :
        $(INFORMIXC) esql $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_CFLAGS) $(CFLAGS) -Wp,-MD,.deps/$(*F).pp -c $<
        @sed -e 's/$*.c/$*.ec/' < .deps/$(*F).pp > .deps/$(*F).pp2
        @-cp .deps/$(*F).pp2 .deps/$(*F).P; \
        tr ' ' '\012' < .deps/$(*F).pp2 \
          | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/'
-e 's/\.c /\.ec /' \
            >> .deps/$(*F).P; \
        rm .deps/$(*F).pp .deps/$(*F).pp2
        rm $*.c

The extra sed command is there so that the dependencies will actually be
set to the .ec file instead of the generated .c file and the generated
file is removed at the end.  This works great as long as the esql
command completes successfully.  If the esql command fails, the
generated file is not removed and the next time the compile takes place,
it doesn't reprocess the .ec file due to the implicit rules.

I guess my questions boil down to:  1) is this the right way to
integrate a new target into the automake dependency rules, and 2)
without adding suffix rules for .ec -> .c -> .o, is there a better way
to do it?

With regards to the 1st question, I am wondering if the solution is
linux-specific and therefore won't work on other platforms with non GNU
C compilers.

With regards to the 2nd question, I am hesitant to add the .ec.c rule
because esql takes care of several system includes that I would then
have to add to the rest of the compiles, or create yet another set of
compilation flags to maintain in order to get the generated C files to
compile.

Thanks in advance,

ast

Reply via email to