mirror of
git://projects.qi-hardware.com/f32xbase.git
synced 2025-04-21 12:27:27 +03:00
fw/common/ - copied from IDBG and generalized a little
This commit is contained in:
100
fw/common/Makefile.common
Normal file
100
fw/common/Makefile.common
Normal file
@@ -0,0 +1,100 @@
|
||||
#
|
||||
# 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../common \
|
||||
-DPAYLOAD_START=$(PAYLOAD_START) -DPAYLOAD_SIZE=$(PAYLOAD_SIZE) \
|
||||
-D`cat ../.target`
|
||||
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
|
||||
|
||||
version version.h:
|
||||
@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
|
||||
|
||||
$(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 $<
|
||||
|
||||
$(OBJS:%=%.rel): ../.target
|
||||
|
||||
# below, set dummy UART speed to make dependencies build without error
|
||||
|
||||
depend .depend:
|
||||
>.depend
|
||||
touch version.h 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
|
||||
|
||||
.depend: ../.target
|
||||
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
endif
|
||||
|
||||
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: clean
|
||||
rm -f $(MAIN).bin .depend
|
||||
|
||||
upload:
|
||||
ssh lab neo 'cat \>$(MAIN).bin' <$(MAIN).bin
|
||||
Reference in New Issue
Block a user