C8051F32x firmware infrastructure

Sign in or create your account | Project List | Help

C8051F32x firmware infrastructure Git Source Tree

Root/fw/common/Makefile.common

1#
2# common/Makefile.common - Common rules and definitions
3#
4# Written 2008, 2010 by Werner Almesberger
5# Copyright 2008, 2010 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14CC=sdcc
15CFLAGS=--std-c99 -I. -I$(F32XBASE)/fw/common \
16       -DPAYLOAD_START=$(PAYLOAD_START) -DPAYLOAD_SIZE=$(PAYLOAD_SIZE)
17LDFLAGS=--xram-size 1024
18
19
20CPP := $(CPP) # make sure changing CC won't affect CPP
21
22CC_normal := $(CC)
23CC_quiet = @echo " CC " $@ && $(CC_normal)
24GEN_quiet = @echo " GENERATE " $@ &&
25
26ifeq ($(V),1)
27    CC = $(CC_normal)
28    GEN =
29else
30    CC = $(CC_quiet)
31    GEN = $(GEN_quiet)
32endif
33
34
35.SUFFIXES: .rel .ihx .bin
36
37.PHONY: clean spotless upload version
38
39all: $(MAIN).bin
40
41
42# ----- automatic build version information -----------------------------------
43
44
45version version.c:
46        @if [ -f .version ]; then \
47            v=`cat .version`; \
48            expr $$v + 1 >.version; \
49        else \
50            echo 0 >.version; \
51        fi
52        @[ -s .version ] || echo 0 >.version
53        @echo '/* MACHINE-GENERATED. DO NOT EDIT ! */' >version.c
54        @echo '#include "version.h"' >>version.c
55        @echo "const char *build_date = \"`date`\";" >>version.c
56        @echo "const uint16_t build_number = `cat .version`;" \
57          >>version.c
58
59version.rel: version
60
61
62# ----- build rules -----------------------------------------------------------
63
64
65$(MAIN).ihx: $(OBJS:%=%.rel)
66        $(GEN) $(CC_normal) $(CFLAGS) $(LDFLAGS) $(OBJS:%=%.rel)
67
68.ihx.bin:
69        $(GEN) objcopy -I ihex $< -O binary $@
70        @echo "build #`cat .version`, `ls -l $@`"
71
72.rel.ihx:
73        $(CC) $(CFLAGS) $<
74
75.c.rel:
76        $(CC) $(CFLAGS) -c $<
77
78
79# ----- dependencies ----------------------------------------------------------
80
81
82# below, set dummy UART speed to make dependencies build without error
83
84depend .depend:
85        >.depend
86        touch version.c
87        for n in $(OBJS:%=%.c); do \
88            $(CPP) $(CFLAGS) -DUART_115200_BPS -MM -MG \
89              `[ -f $$n ] || echo ../common/`$$n >>.depend || \
90              { rm -f .depend; exit 1; }; \
91        done
92
93ifeq (.depend,$(wildcard .depend))
94include .depend
95endif
96
97
98# ----- specific object files -------------------------------------------------
99
100
101boot.rel: $(F32XBASE)/fw/boot/boot.c
102        $(CC) $(CFLAGS) -o $@ -c $<
103
104usb.rel: $(F32XBASE)/fw/common/usb.c
105        $(CC) $(CFLAGS) -o $@ -c $<
106
107dfu.rel: $(F32XBASE)/fw/boot/dfu.c
108        $(CC) $(CFLAGS) -o $@ -c $<
109
110
111# ----- clean -----------------------------------------------------------------
112
113
114clean::
115        rm -f $(OBJS:%=%.rel)
116        rm -f $(OBJS:%=%.asm) $(OBJS:%=%.lst)
117        rm -f $(OBJS:%=%.rst) $(OBJS:%=%.sym)
118        rm -f $(MAIN).ihx $(MAIN).lnk $(MAIN).map $(MAIN).mem
119
120
121# ----- spotless --------------------------------------------------------------
122
123
124spotless:: clean
125        rm -f $(MAIN).bin .depend
126

Archive Download this file

Branches:
master



interactive