blob: 331c11f0196f0e95404dd92660203ac03ad87696 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
include_rules
PROG = stamp-monitor
FATFS = $(TOP)/fatfs/src/ff.c
SRC = main.c
SRC += cli.c cli_readline.c command.c command_tbl.c
SRC += cmd_help.c cmd_date.c cmd_mem.c cmd_boot.c cmd_gpio.c cmd_misc.c
SRC += cmd_loadihex.c cmd_loadcpm3.c cmd_sd.c cmd_fat.c
SRC += env.c xmalloc.c con-utils.c print-utils.c getopt-min.c
SRC += timer.c serial.c i2c.c bcd.c pcf8583.c mmc.c
SRC += background.c z180-serv.c z80-if.c gpio.c
SRC += $(FATFS) $(TOP)/fatfs/src/option/unicode.c
#TODO: time lib
SRC += ../time/asctime_r.c ../time/gmtime_r.c ../time/mk_gmtime.c
SRC += ../time/print_lz.c ../time/isLeap.c
SRC += ../time/time.c ../time/fatfs_time.c
SRC += ../time/system_time.c ../time/set_system_time.c
ASRC += ../time/system_tick.S
SRC_Z = ../z180/hdrom.c
#TARGETS = $(PROG).elf
ifdef MCU
MCU_TARGET = @(MCU)
else
MCU_TARGET = atmega1281
endif
ifeq ($(MCU_TARGET),atmega1281)
DEFS += -DMCU_STRING=\"ATmega1281\"
else
DEFS += -DMCU_STRING=\"ATmega2561\"
endif
F_CPU = 18432000UL
DEFS += -DF_CPU=$(F_CPU)
INCLUDES += -I$(TOP)/include
#INCLUDES += -I../z180
###############################################################################
TOOLCHAINDIR =
TOOLCHAIN = avr
CC = $(TOOLCHAIN)-gcc
LD = $(TOOLCHAIN)-gcc
AR = $(TOOLCHAIN)-ar
AS = $(TOOLCHAIN)-as
OBJCOPY = $(TOOLCHAIN)-objcopy
OBJDUMP = $(TOOLCHAIN)-objdump
SIZE = $(TOOLCHAIN)-size
GDB = $(TOOLCHAIN)-gdb
###############################################################################
ifdef DEBUG
SRC += debug.c
DEFS += -DDEBUG=2
endif
CFLAGS = -g -Os
CFLAGS += -mmcu=$(MCU_TARGET)
CFLAGS += -std=gnu99
CFLAGS += -Wall -Wextra
CFLAGS += -Wredundant-decls
CFLAGS += -mrelax
CFLAGS += -fno-common
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
CFLAGS += -fno-tree-loop-optimize
CFLAGS += -fno-move-loop-invariants
CFLAGS += -fno-split-wide-types
#CFLAGS += -flto
CFLAGS += -fshort-enums
#CFLAGS += -fdiagnostics-color=always
#CFLAGS += -save-temps
CFLAGS_$(FATFS) = -fno-strict-aliasing
CFLAGS += $(INCLUDES)
CPPFLAGS += $(DEFS)
#ASFLAGS += -Wa,-adhlns=$(<:.S=.lst),-gstabs
ASFLAGS += -mmcu=$(MCU_TARGET) -x assembler-with-cpp $(ASFLAGS)
# Linker flags
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--cref
# Assemble: create object files from assembler source files.
#.S.o:
# $(CC) -c $(ALL_ASFLAGS) $< -o $@
!as = |> ^ AS %f^ $(CC) $(ASFLAGS) -c %f -o %o |> %B.o
!cc = |> ^ CC %f^ $(CC) $(CFLAGS) $(CPPFLAGS) $(CFLAGS_%f) -c %f -o %o |> %B.o
!LINK = |> ^ LINK %o^ $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-Map=%O.map %f $(LDLIBS) -o %o |> | %O.map
!OBJCOPY= |> ^ OBJCOPY %o^ $(OBJCOPY) -Oihex %f %o |>
!OBJDUMP= |> ^ OBJDUMP %o^ $(OBJDUMP) -h -S %f > %o |> %O.lss
!SIZE = |> ^ SIZE^ $(SIZE) %f |>
: foreach $(ASRC) |> !as |> {objs}
: foreach $(SRC) | ../z180/hdrom.h |> !cc |> {objs}
: $(SRC_Z) |> !cc -D'const=const __flash' |> {objs}
: {objs} |> !LINK |> $(PROG).elf
: $(PROG).elf |> !OBJCOPY |> %B.hex
: $(PROG).elf |> !OBJDUMP |> %B.lss
: $(PROG).elf |> !SIZE |>
|