2010-02-26 12:16:06 +00:00
|
|
|
# -*- makefile -*-
|
2010-02-26 12:30:53 +00:00
|
|
|
|
2010-03-12 21:51:49 +00:00
|
|
|
ifndef BOARD
|
|
|
|
default: allboards
|
|
|
|
else
|
|
|
|
default: all
|
|
|
|
endif
|
2010-03-12 22:00:53 +00:00
|
|
|
.PHONY: default
|
2010-03-12 21:51:49 +00:00
|
|
|
|
2010-02-26 12:30:53 +00:00
|
|
|
CROSS_COMPILE := arm-linux-
|
|
|
|
|
2010-02-23 23:14:32 +00:00
|
|
|
LINKERSCRIPT := $(MC1322X)/mc1322x.lds
|
2010-03-02 14:51:58 +00:00
|
|
|
LIBMC1322X := $(MC1322X)/lib
|
2010-02-21 22:34:27 +00:00
|
|
|
|
2010-02-21 23:47:12 +00:00
|
|
|
include $(MC1322X)/config.mk
|
2010-02-21 22:34:27 +00:00
|
|
|
|
2010-02-21 23:47:12 +00:00
|
|
|
include $(MC1322X)/board/Makefile.board
|
|
|
|
|
2010-03-02 14:51:58 +00:00
|
|
|
include $(LIBMC1322X)/Makefile.lib
|
2010-02-21 22:34:27 +00:00
|
|
|
|
2010-02-26 19:04:10 +00:00
|
|
|
CFLAGS += -I$(MC1322X)/src -I.
|
|
|
|
|
2010-03-02 19:32:34 +00:00
|
|
|
ifdef TARGET_ROM_VARS
|
2010-03-02 15:38:32 +00:00
|
|
|
START = $(MC1322X)/src/start-romvars.o
|
|
|
|
endif
|
|
|
|
|
2010-02-26 19:04:10 +00:00
|
|
|
# default start and isr
|
2010-02-22 17:19:39 +00:00
|
|
|
ifndef START
|
|
|
|
START = $(MC1322X)/src/start.o
|
|
|
|
endif
|
|
|
|
ifndef ISR
|
|
|
|
ISR = $(MC1322X)/src/isr.o
|
|
|
|
endif
|
2010-03-02 19:32:34 +00:00
|
|
|
SRCOBJS += $(MC1322X)/src/default_lowlevel.o $(ISR) $(START)
|
2010-02-26 19:04:10 +00:00
|
|
|
BOARDOBJS := $(addprefix $(OBJDIR)/,$(COBJS))
|
2010-02-22 17:19:39 +00:00
|
|
|
|
2010-02-21 22:34:27 +00:00
|
|
|
ARCH = arm
|
|
|
|
CPU = arm7tdmi-s
|
|
|
|
export ARCH CPU VENDOR
|
|
|
|
|
2010-02-22 23:58:45 +00:00
|
|
|
.SECONDARY:
|
|
|
|
|
2010-03-01 21:27:58 +00:00
|
|
|
### 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
|
|
|
|
|
2010-02-22 23:58:45 +00:00
|
|
|
$(START): $(START:.o=.s)
|
|
|
|
$(CC) $(AFLAGS) -c -o $@ $<
|
2010-03-02 15:38:32 +00:00
|
|
|
$(MC1322X)/src/start-romvars.s: $(MC1322X)/src/start.S
|
2010-03-02 19:32:34 +00:00
|
|
|
$(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 $@ $<
|
2010-02-21 22:34:27 +00:00
|
|
|
|
2010-02-22 17:19:39 +00:00
|
|
|
$(ISR): $(ISR:.o=.c)
|
2010-03-01 21:27:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(ARM_FLAGS) -MMD $< -c -o $@
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2010-02-21 22:34:27 +00:00
|
|
|
|
2010-03-11 21:17:18 +00:00
|
|
|
|
2010-03-11 21:31:21 +00:00
|
|
|
ifdef COBJS
|
2010-03-13 12:43:44 +00:00
|
|
|
BOARDARCS := $(OBJDIR)/board.a(${filter $(OBJDIR)/%.o,$(BOARDOBJS)})
|
2010-03-11 21:17:18 +00:00
|
|
|
endif
|
2010-03-10 16:19:43 +00:00
|
|
|
empty-board-a:
|
|
|
|
$(AR) $(ARFLAGS) $(OBJDIR)/board.a
|
2010-03-12 22:00:53 +00:00
|
|
|
.PHONY: empty-board-a
|
|
|
|
|
2010-03-13 12:43:44 +00:00
|
|
|
$(OBJDIR)/board.a: empty-board-a $(BOARDARCS) $(BOARDOBJS)
|
2010-03-02 19:32:34 +00:00
|
|
|
$(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) \
|
2010-03-11 17:22:47 +00:00
|
|
|
-L $(LIBMC1322X) -L $(MC1322X)/src -L $(OBJDIR) $< -o $@ $(START) $(MC1322X)/src/src.a --start-group $(OBJDIR)/board.a $(LIBMC1322X)/libmc1322x.a --end-group
|
2010-02-21 22:34:27 +00:00
|
|
|
|
2010-02-23 20:53:00 +00:00
|
|
|
%.srec: %.elf
|
|
|
|
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
|
|
|
|
|
|
|
|
%.ihex: %.elf
|
|
|
|
$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
|
|
|
|
|
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
|
|
|
|
|
|
|
|
%.dis: %.elf
|
|
|
|
$(OBJDUMP) -SD $< > $@
|
|
|
|
|
2010-03-02 15:38:32 +00:00
|
|
|
%.s: %.S
|
|
|
|
$(CPP) $(AFLAGS) -o $@ $<
|
|
|
|
%.o: %.S
|
|
|
|
$(CC) $(AFLAGS) -MMD -c -o $@ $<
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2010-03-01 23:02:29 +00:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(THUMB_FLAGS) -MMD -c -o $@ $<
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
|
2010-02-22 23:58:45 +00:00
|
|
|
$(OBJDIR)/%.s: %.S
|
|
|
|
$(CPP) $(AFLAGS) -o $@ $<
|
|
|
|
$(OBJDIR)/%.o: %.S
|
2010-03-01 21:27:58 +00:00
|
|
|
$(CC) $(AFLAGS) -MMD -c -o $@ $<
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2010-02-22 23:58:45 +00:00
|
|
|
$(OBJDIR)/%.o: %.c
|
2010-03-01 21:27:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(THUMB_FLAGS) -MMD -c -o $@ $<
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2010-02-22 23:58:45 +00:00
|
|
|
|
2010-02-21 22:34:27 +00:00
|
|
|
clean:
|
2010-02-23 00:01:18 +00:00
|
|
|
find $(MC1322X) \
|
2010-02-21 22:34:27 +00:00
|
|
|
\( -name 'core' -o -name '*.bak' -o -name '*~' \
|
2010-02-23 00:01:18 +00:00
|
|
|
-o -name '*.o' -o -name '*.a' -o -name '*.obj' -o -name '*.elf' -o -name '*.s' -o -name '*.map' \
|
2010-03-01 21:27:58 +00:00
|
|
|
-o -name 'obj_*_board' -o -name '.depend' -o -name '*.bin' -o -name '*.dis' -o -name '*.d' \) -print \
|
2010-02-23 00:01:18 +00:00
|
|
|
| xargs rm -rf
|
2010-02-22 17:24:56 +00:00
|
|
|
rm -fr *.*~
|
2010-02-27 20:42:28 +00:00
|
|
|
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' \
|
2010-03-01 21:27:58 +00:00
|
|
|
-o -name 'obj_*_board' -o -name '.depend' -o -name '*.bin' -o -name '*.dis' -o -name '*.d' \) -print \
|
2010-02-27 20:42:28 +00:00
|
|
|
| xargs rm -rf
|
|
|
|
rm -fr *.*~
|
2010-03-17 01:58:27 +00:00
|
|
|
make -C $(MC1322X)/tools/ftditools/ clean
|
2010-02-22 17:24:56 +00:00
|
|
|
clobber \
|
2010-02-21 22:34:27 +00:00
|
|
|
mrproper \
|
2010-02-22 17:24:56 +00:00
|
|
|
distclean: clean
|
2010-02-23 23:27:12 +00:00
|
|
|
|
2010-03-12 22:00:53 +00:00
|
|
|
.PHONY: clean clobber mrproper distclean
|
|
|
|
|
2010-02-23 23:54:50 +00:00
|
|
|
all: $(OBJDIR)/board.h
|
2010-03-17 00:24:32 +00:00
|
|
|
-git submodule update
|
2010-02-23 23:54:50 +00:00
|
|
|
for target in $(TARGETS); do make $$target\_$(BOARD).bin; done
|
2010-03-02 19:32:34 +00:00
|
|
|
for target in $(TARGETS_WITH_ROM_VARS); do make TARGET_ROM_VARS=1 $$target\_$(BOARD).bin; done
|
2010-02-23 23:54:50 +00:00
|
|
|
|
|
|
|
allboards:
|
|
|
|
for board in $(BOARDS); do make BOARD=$$board all; done
|
|
|
|
|
2010-03-12 22:00:53 +00:00
|
|
|
.PHONY: all allboards
|
2010-02-23 23:54:50 +00:00
|
|
|
|
2010-02-23 23:27:12 +00:00
|
|
|
|