help-make
[Top][All Lists]
Advanced

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

handling two types of prerequisites differently in pattern rule


From: Galen Seitz
Subject: handling two types of prerequisites differently in pattern rule
Date: Thu, 04 Mar 2010 17:38:24 -0800
User-agent: Thunderbird 2.0.0.22 (X11/20090625)

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
address@hidden




reply via email to

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