141 lines
3.6 KiB
Makefile
141 lines
3.6 KiB
Makefile
# -*- makefile -*-
|
|
|
|
ifndef BOARD
|
|
default: allboards
|
|
else
|
|
default: all
|
|
endif
|
|
.PHONY: default
|
|
|
|
CROSS_COMPILE := arm-linux-
|
|
|
|
LINKERSCRIPT := $(MC1322X)/mc1322x.lds
|
|
LIBMC1322X := $(MC1322X)/lib
|
|
|
|
include $(MC1322X)/config.mk
|
|
|
|
include $(MC1322X)/board/Makefile.board
|
|
|
|
include $(LIBMC1322X)/Makefile.lib
|
|
|
|
CFLAGS += -I$(MC1322X)/src -I.
|
|
|
|
ifdef TARGET_ROM_VARS
|
|
START = $(MC1322X)/src/start-romvars.o
|
|
endif
|
|
|
|
# default start and isr
|
|
ifndef START
|
|
START = $(MC1322X)/src/start.o
|
|
endif
|
|
ifndef ISR
|
|
ISR = $(MC1322X)/src/isr.o
|
|
endif
|
|
SRCOBJS += $(MC1322X)/src/default_lowlevel.o $(ISR) $(START)
|
|
BOARDOBJS := $(addprefix $(OBJDIR)/,$(COBJS))
|
|
|
|
ARCH = arm
|
|
CPU = arm7tdmi-s
|
|
export ARCH CPU VENDOR
|
|
|
|
.SECONDARY:
|
|
|
|
### See http://make.paulandlesley.org/autodep.html#advanced
|
|
ifdef BOARD
|
|
-include ${addprefix $(OBJDIR)/,$(addsuffix .d,$(TARGETS))}
|
|
endif
|
|
|
|
define FINALIZE_DEPENDENCY
|
|
cp $(@:.o=.d) $(@:.o=.$$$$); \
|
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.$$$$) >> $(@:.o=.d); \
|
|
rm -f $(@:.o=.$$$$)
|
|
endef
|
|
|
|
$(START): $(START:.o=.s)
|
|
$(CC) $(AFLAGS) -c -o $@ $<
|
|
$(MC1322X)/src/start-romvars.s: $(MC1322X)/src/start.S
|
|
$(CPP) $(AFLAGS) -DUSE_INTS -DUSE_ROM_VECTS -DUSE_ROM_VARS -o $@ $<
|
|
$(MC1322X)/src/start-romvects.s: $(MC1322X)/src/start.S
|
|
$(CPP) $(AFLAGS) -DUSE_INTS -DUSE_ROM_VECTS -o $@ $<
|
|
|
|
$(ISR): $(ISR:.o=.c)
|
|
$(CC) $(CFLAGS) $(ARM_FLAGS) -MMD $< -c -o $@
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
|
|
ifdef COBJS
|
|
BOARDARCS := $(OBJDIR)/board.a(${filter $(OBJDIR)/%.o,$(BOARDOBJS)})
|
|
endif
|
|
empty-board-a:
|
|
$(AR) $(ARFLAGS) $(OBJDIR)/board.a
|
|
.PHONY: empty-board-a
|
|
|
|
$(OBJDIR)/board.a: empty-board-a $(BOARDARCS) $(BOARDOBJS)
|
|
$(MC1322X)/src/src.a: $(MC1322X)/src/src.a($(SRCOBJS))
|
|
|
|
%_$(BOARD).elf: $(OBJDIR)/%.o $(START) $(ISR) $(SRCOBJS) $(LINKERSCRIPT) $(LIBMC1322X)/libmc1322x.a $(OBJDIR)/board.a $(MC1322X)/src/src.a
|
|
$(CC) $(LDFLAGS) \
|
|
-L $(LIBMC1322X) -L $(MC1322X)/src -L $(OBJDIR) $< -o $@ $(START) $(MC1322X)/src/src.a --start-group $(OBJDIR)/board.a $(LIBMC1322X)/libmc1322x.a --end-group
|
|
|
|
%.srec: %.elf
|
|
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
|
|
|
|
%.ihex: %.elf
|
|
$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
|
|
|
|
%.bin: %.elf
|
|
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
|
|
|
|
%.dis: %.elf
|
|
$(OBJDUMP) -SD $< > $@
|
|
|
|
%.s: %.S
|
|
$(CPP) $(AFLAGS) -o $@ $<
|
|
%.o: %.S
|
|
$(CC) $(AFLAGS) -MMD -c -o $@ $<
|
|
@$(FINALIZE_DEPENDENCY)
|
|
%.o: %.c
|
|
$(CC) $(CFLAGS) $(THUMB_FLAGS) -MMD -c -o $@ $<
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
$(OBJDIR)/%.s: %.S
|
|
$(CPP) $(AFLAGS) -o $@ $<
|
|
$(OBJDIR)/%.o: %.S
|
|
$(CC) $(AFLAGS) -MMD -c -o $@ $<
|
|
@$(FINALIZE_DEPENDENCY)
|
|
$(OBJDIR)/%.o: %.c
|
|
$(CC) $(CFLAGS) $(THUMB_FLAGS) -MMD -c -o $@ $<
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
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' -o -name '*.d' \) -print \
|
|
| xargs rm -rf
|
|
rm -fr *.*~
|
|
find \
|
|
\( -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' -o -name '*.d' \) -print \
|
|
| xargs rm -rf
|
|
rm -fr *.*~
|
|
|
|
clobber \
|
|
mrproper \
|
|
distclean: clean
|
|
|
|
.PHONY: clean clobber mrproper distclean
|
|
|
|
all: $(OBJDIR)/board.h
|
|
-git submodule update
|
|
for target in $(TARGETS); do make $$target\_$(BOARD).bin; done
|
|
for target in $(TARGETS_WITH_ROM_VARS); do make TARGET_ROM_VARS=1 $$target\_$(BOARD).bin; done
|
|
|
|
allboards:
|
|
for board in $(BOARDS); do make BOARD=$$board all; done
|
|
|
|
.PHONY: all allboards
|
|
|
|
|