-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile_x86_64
executable file
·124 lines (94 loc) · 2.59 KB
/
makefile_x86_64
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
118
119
120
121
122
123
#######################################################################
###### That-Is-The-Box-Of-My-Wife ######
#######################################################################
###### Project: AVR-Crontab
###### Developer: Peter Shaw
###### Date: 2013
###### URL: https://github.com/petershaw/AVR-Crontab
#######################################################################
PROJECTNAME = libavrcron_x68_64
# Directory to generate objects
OBJECTDIR=./build/_x68_64
# directory to store the product
TARGETDIR=./target
CC = gcc
AR = ar
REMOVE = rm -f
MKDIR_P = mkdir -p
# Name of target controller
MCU = atmega328p
# Frequency of the controller
F_CPU = 16000000UL
# C Source files
PRJSRC = $(shell find ./src* -name *.c)
# additional includes (e.g. -I/path/to/mydir)
INC =
# libraries to link in (e.g. -lmylib)
LIBS =
# Optimization level,
# use s (size opt), 1, 2, 3 or 0 (off)
OPTLEVEL = s
# compiler
CFLAGS = -I $(INC) \
-g -Wall \
-pedantic \
--std=gnu99 \
-DIGNOREINTESTS=1 \
-static \
-Wgnu
# linker
LDFLAGS = -I. $(INC) -DIGNOREINTESTS=1 -L "$${LIBPATH}" -lm $(LIBS)
##### automatic target names ####
TRG=$(TARGETDIR)/$(PROJECTNAME).out
DUMPTRG=$(TARGETDIR)/$(PROJECTNAME).s
# Start by splitting source files by type
# C
CFILES=$(filter %.c, $(PRJSRC))
# List all object files we need to create
_OBJDEPS=$(CFILES:.c=.o)
OBJDEPS=$(_OBJDEPS:./src=$(OBJECTDIR)/src)
# Define all lst files.
LST=$(filter %.lst, $(OBJDEPS:.o=.lst))
# All the possible generated assembly
# files (.s files)
GENASMFILES=$(filter %.s, $(OBJDEPS:.o=.s))
.SUFFIXES : .c .o .out .s .h .hex .ee.hex
dir_guard=$(MKDIR_P) $(OBJECTDIR)/$(@D)
# Make targets:
# all, disasm, stats, hex, writeflash/install, clean
all: prepare $(TRG) $(HEXTRG)
prepare:
$(MKDIR_P) $(OBJECTDIR)
$(MKDIR_P) $(TARGETDIR)
$(TRG): $(OBJDEPS)
$(AR) rv $(TARGETDIR)/$(PROJECTNAME).a $(shell find $(OBJECTDIR) -type f -name *.o)
#### Generating assembly ####
# asm from C
%.s: %.c
$(dir_guard)
$(CC) -S $(CFLAGS) $< -o $(OBJECTDIR)/$@
#### Generating object files ####
# object from C
.c.o:
$(dir_guard)
$(CC) $(CFLAGS) -c $< -o $(OBJECTDIR)/$@
#### Upload ####
upload:
$(AVRDUDE) -c $(PROGRAMMER) -B$(BOOTLOADER_BAUD) -Uflash:w:$(HEXROMTRG) -p $(PROGRAMMER_MCU)
#### screen terminal ####
term:
screen $(BOOTLOADER_PORT) $(BOOTLOADER_TERM)
#### Information ####
info:
which $(CC)
$(CC) -v
avr-ld -v
#### Cleanup ####
clean:
$(REMOVE) $(TRG) $(TRG).map $(DUMPTRG)
$(REMOVE) -r $(TARGETDIR)
$(REMOVE) $(OBJDEPS)
$(REMOVE) $(LST)
$(REMOVE) $(GENASMFILES)
$(REMOVE) -r $(OBJECTDIR)
$(MAKE) -C tests clean