Automake + libtool: pattern rule for per-object CFLAGS?

368 views Asked by At

I'm using GNU Automake and libtool to compile my program. My Makefile.am looks like this:

lib_LTLIBRARIES = \
    libObjectively.la

libObjectively_la_SOURCES = \
    Array.c \
    Class.c \
    Condition.c \
    Date.c \
    DateFormatter.c \
    Dictionary.c \
    Lock.c \
    Log.c \
    Object.c \
    String.c \
    Thread.c

libObjectively_la_CFLAGS = \
    -I ..

libObjectively_la_LDFLAGS = \
    -pthread \
    -shared

Everything compiles just fine. However, I would like to set CFLAGS for each source file using a pattern rule as well. In regular old Makefile syntax, this would look something like:

%.o: %.c
    $(CC) $(CFLAGS) -D__Class=$(subst .o,,$@) -o $@ $<

Is there a way to do this with Automake + libtool?

1

There are 1 answers

0
jdolan On BEST ANSWER

Turns out, there is no portable way to do this sort of thing.