cpattern-matchinggnu-makeautomakelibtool

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


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?


Solution

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