nes-proj/Makefile.include
Mariano Alvira 9a8004c177 working on nvm-read.
fixed lib ordering on link command
2010-02-26 12:37:13 -05:00

92 lines
1.7 KiB
Makefile

# -*- makefile -*-
CROSS_COMPILE := arm-linux-
LINKERSCRIPT := $(MC1322X)/mc1322x.lds
LIBMC1322X := $(MC1322X)/libmc1322x
include $(MC1322X)/config.mk
include $(MC1322X)/board/Makefile.board
include $(MC1322X)/libmc1322x/Makefile.lib
# default start and isr
CFLAGS += -I$(MC1322X)/src
ifndef START
START = $(MC1322X)/src/start.o
endif
ifndef ISR
ISR = $(MC1322X)/src/isr.o
endif
SRCOBJS += $(MC1322X)/src/default_lowlevel.o
ARCH = arm
CPU = arm7tdmi-s
export ARCH CPU VENDOR
.SECONDARY:
$(START): $(START:.o=.s)
$(CC) $(AFLAGS) -c -o $@ $<
$(ISR): $(ISR:.o=.c)
$(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@
%_$(BOARD).elf: %.elf
mv $< $@
%.elf: $(START) $(ISR) $(SRCOBJS) $(OBJDIR)/%.o $(LINKERSCRIPT) $(LIBMC1322X)/libmc1322x.a
$(CC) $(LDFLAGS) $(AOBJS) \
$(filter %.o %.a,$+) -o $@
%.srec: %.elf
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
%.ihex: %.elf
$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
%.bin: %.elf
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
%.dis: %.elf
$(OBJDUMP) -SD $< > $@
$(OBJDIR)/%.s: %.S
$(CPP) $(AFLAGS) -o $@ $<
$(OBJDIR)/%.o: %.S
$(CC) $(AFLAGS) -c -o $@ $<
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $(THUMB_FLAGS) -c -o $@ $<
clean:
find $(MC1322X) \
\( -name 'core' -o -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.a' -o -name '*.obj' -o -name '*.elf' -o -name '*.s' -o -name '*.map' \
-o -name 'obj_*_board' -o -name '.depend' -o -name '*.bin' -o -name '*.dis' \) -print \
| xargs rm -rf
rm -fr *.*~
clobber \
mrproper \
distclean: clean
#.DEFAULT_GOAL := all
ifndef BOARD
.DEFAULT_GOAL := allboards
else
.DEFAULT_GOAL := all
endif
all: $(OBJDIR)/board.h
for target in $(TARGETS); do make $$target\_$(BOARD).bin; done
allboards:
for board in $(BOARDS); do make BOARD=$$board all; done