mirror of
git://projects.qi-hardware.com/f32xbase.git
synced 2024-11-05 10:10:16 +02:00
2a5850591c
we create it when making dependencies. - fw/common/Makefile.common (depend): don't touch version.h - fw/common/Makefile.common (version): we build version.c, not version.c
126 lines
2.8 KiB
Makefile
126 lines
2.8 KiB
Makefile
#
|
|
# 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
|
|
CFLAGS=--std-c99 -I. -I$(F32XBASE)/fw/common \
|
|
-DPAYLOAD_START=$(PAYLOAD_START) -DPAYLOAD_SIZE=$(PAYLOAD_SIZE)
|
|
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
|
|
|
|
|
|
# ----- automatic build version information -----------------------------------
|
|
|
|
|
|
version version.c:
|
|
@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
|
|
|
|
|
|
# ----- build rules -----------------------------------------------------------
|
|
|
|
|
|
$(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 $<
|
|
|
|
|
|
# ----- dependencies ----------------------------------------------------------
|
|
|
|
|
|
# below, set dummy UART speed to make dependencies build without error
|
|
|
|
depend .depend:
|
|
>.depend
|
|
touch version.c
|
|
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
|
|
|
|
|
|
# ----- 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 -----------------------------------------------------------------
|
|
|
|
|
|
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
|
|
|
|
|
|
# ----- spotless --------------------------------------------------------------
|
|
|
|
|
|
spotless: clean
|
|
rm -f $(MAIN).bin .depend
|