2010-08-13 14:47:13 +03:00
|
|
|
#
|
|
|
|
# common/Makefile.common - Common rules and definitions
|
|
|
|
#
|
|
|
|
# Written 2008, 2010 by Werner Almesberger
|
|
|
|
# Copyright 2008, 2010 Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
CC=sdcc
|
2010-08-19 07:01:08 +03:00
|
|
|
CFLAGS=--std-c99 -I. -I$(F32XBASE)/fw/common \
|
2010-08-19 06:34:19 +03:00
|
|
|
-DPAYLOAD_START=$(PAYLOAD_START) -DPAYLOAD_SIZE=$(PAYLOAD_SIZE)
|
2010-08-13 14:47:13 +03:00
|
|
|
LDFLAGS=--xram-size 1024
|
|
|
|
|
|
|
|
|
|
|
|
CPP := $(CPP) # make sure changing CC won't affect CPP
|
|
|
|
|
|
|
|
CC_normal := $(CC)
|
|
|
|
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
|
|
|
GEN_quiet = @echo " GENERATE " $@ &&
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
CC = $(CC_normal)
|
|
|
|
GEN =
|
|
|
|
else
|
|
|
|
CC = $(CC_quiet)
|
|
|
|
GEN = $(GEN_quiet)
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
.SUFFIXES: .rel .ihx .bin
|
|
|
|
|
|
|
|
.PHONY: clean spotless upload version
|
|
|
|
|
|
|
|
all: $(MAIN).bin
|
|
|
|
|
2010-08-19 07:11:14 +03:00
|
|
|
|
|
|
|
# ----- automatic build version information -----------------------------------
|
|
|
|
|
|
|
|
|
2010-08-20 20:26:35 +03:00
|
|
|
version version.c:
|
2010-08-13 14:47:13 +03:00
|
|
|
@if [ -f .version ]; then \
|
|
|
|
v=`cat .version`; \
|
|
|
|
expr $$v + 1 >.version; \
|
|
|
|
else \
|
|
|
|
echo 0 >.version; \
|
|
|
|
fi
|
|
|
|
@[ -s .version ] || echo 0 >.version
|
|
|
|
@echo '/* MACHINE-GENERATED. DO NOT EDIT ! */' >version.c
|
|
|
|
@echo '#include "version.h"' >>version.c
|
|
|
|
@echo "const char *build_date = \"`date`\";" >>version.c
|
|
|
|
@echo "const uint16_t build_number = `cat .version`;" \
|
|
|
|
>>version.c
|
|
|
|
|
|
|
|
version.rel: version
|
|
|
|
|
2010-08-19 07:11:14 +03:00
|
|
|
|
|
|
|
# ----- build rules -----------------------------------------------------------
|
|
|
|
|
|
|
|
|
2010-08-13 14:47:13 +03:00
|
|
|
$(MAIN).ihx: $(OBJS:%=%.rel)
|
|
|
|
$(GEN) $(CC_normal) $(CFLAGS) $(LDFLAGS) $(OBJS:%=%.rel)
|
|
|
|
|
|
|
|
.ihx.bin:
|
|
|
|
$(GEN) objcopy -I ihex $< -O binary $@
|
|
|
|
@echo "build #`cat .version`, `ls -l $@`"
|
|
|
|
|
|
|
|
.rel.ihx:
|
|
|
|
$(CC) $(CFLAGS) $<
|
|
|
|
|
|
|
|
.c.rel:
|
|
|
|
$(CC) $(CFLAGS) -c $<
|
|
|
|
|
2010-08-19 07:11:14 +03:00
|
|
|
|
|
|
|
# ----- dependencies ----------------------------------------------------------
|
|
|
|
|
|
|
|
|
2010-08-13 14:47:13 +03:00
|
|
|
# below, set dummy UART speed to make dependencies build without error
|
|
|
|
|
|
|
|
depend .depend:
|
|
|
|
>.depend
|
2010-08-20 20:26:35 +03:00
|
|
|
touch version.c
|
2010-08-13 14:47:13 +03:00
|
|
|
for n in $(OBJS:%=%.c); do \
|
|
|
|
$(CPP) $(CFLAGS) -DUART_115200_BPS -MM -MG \
|
|
|
|
`[ -f $$n ] || echo ../common/`$$n >>.depend || \
|
|
|
|
{ rm -f .depend; exit 1; }; \
|
|
|
|
done
|
|
|
|
|
|
|
|
ifeq (.depend,$(wildcard .depend))
|
|
|
|
include .depend
|
|
|
|
endif
|
|
|
|
|
2010-08-19 07:11:14 +03:00
|
|
|
|
|
|
|
# ----- specific object files -------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
boot.rel: $(F32XBASE)/fw/boot/boot.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
usb.rel: $(F32XBASE)/fw/common/usb.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
dfu.rel: $(F32XBASE)/fw/boot/dfu.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
|
|
|
|
# ----- clean -----------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2010-08-13 14:47:13 +03:00
|
|
|
clean:
|
|
|
|
rm -f $(OBJS:%=%.rel)
|
|
|
|
rm -f $(OBJS:%=%.asm) $(OBJS:%=%.lst)
|
|
|
|
rm -f $(OBJS:%=%.rst) $(OBJS:%=%.sym)
|
|
|
|
rm -f $(MAIN).ihx $(MAIN).lnk $(MAIN).map $(MAIN).mem
|
|
|
|
|
2010-08-19 07:11:14 +03:00
|
|
|
|
|
|
|
# ----- spotless --------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2010-08-13 14:47:13 +03:00
|
|
|
spotless: clean
|
|
|
|
rm -f $(MAIN).bin .depend
|