Hi,

I would like to list both the object files and linker script as prerequisites to linker pattern rule. However the linker script needs to appear as an argument to a linker option. I'm having trouble coming up with a clean way to handle this. Here is what I've come up with.


TARGET = foo
TARGET_ARCH = -mmcu=attiny25
VPATH = $(SRCDIR)
SRCS= main.c serial.c state.c

LD_SCRIPT = avr25.x

LDFLAGS = -Wl,-Map=$(TARGET).map -o $@
# Add linker script option if script file name is set.
ifneq ($(strip $(LD_SCRIPT)),)
  LDFLAGS += -Wl,-T$(SRCDIR)/$(LD_SCRIPT)
endif

CC = avr-gcc
O = .o
ABS = .elf

OBJS= ${SRCS:.c=$(O)}

%$(ABS) : $(LD_SCRIPT) $(OBJS)
        $(CC) $(LDFLAGS) $(TARGET_ARCH) $(filter-out %.x,$^) \
          $(LOADLIBES) $(LDLIBS) -o $@


Is there a better way to deal with a case like this where one of the prerequisites needs special treatment? Or should I give up on the idea of a using generic pattern rule.

thanks,
galen
--
Galen Seitz
[email protected]


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to