-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefaults.mk
128 lines (108 loc) · 3.73 KB
/
defaults.mk
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
124
125
126
127
# ethersex project specific defaults, each can be overridden in config.mk
F_CPU = 20000000UL
MCU = atmega644
CC=avr-gcc
AR=avr-ar
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AS = avr-as
CP = cp
RM = rm -f
AVRDUDE = avrdude
AVRDUDE_BAUDRATE = 115200
SIZE = avr-size
STRIP = avr-strip
HOSTCC := gcc
export HOSTCC
LIBS = -lm
# flags for the compiler
CFLAGS ?= -Wall -W -Wno-unused-parameter -Wno-sign-compare
CFLAGS += -g -Os -std=gnu99 -fgnu89-inline -D_XOPEN_SOURCE=600 -DNDEBUG
#############################################################################
#Settings for Simulator build
#ugly hack to define a newline (yes, there are two blank lines, on purpose!!)
define n
endef
OSTYPE = $(shell uname)
MACHINE = $(shell uname -m)
ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN)
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -D_WIN32 -D_XOPEN_SOURCE=600
LDFLAGS_SIM =
LIBS_SIM = -lgdi32 -lwinmm -lm
else
ifeq ($(OSTYPE),FreeBSD)
CFLAGS_SIM = -g -I/usr/local/include -Wall -pedantic -std=c99 -O0
CFLAGS_SIM += -D_XOPEN_SOURCE=600
LDFLAGS_SIM = -L/usr/local/lib
LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm
else
ifeq ($(OSTYPE),NetBSD)
CFLAGS_SIM = -g -I /usr/pkg/include -I/usr/X11R7/include -Wall -pedantic -std=c99 -O0
CFLAGS_SIM += -D_XOPEN_SOURCE=600
LDFLAGS_SIM = -L/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/pkg/lib,-R/usr/X11R7/lib
LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm
else
ifeq ($(OSTYPE),OpenBSD)
CFLAGS_SIM = -g -I/usr/local/include -I/usr/X11R6/include -Wall -pedantic -std=c99 -O0
CFLAGS_SIM += -D_XOPEN_SOURCE=600
LDFLAGS_SIM = -L/usr/local/lib -L/usr/X11R6/lib
LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm
else
ifeq ($(OSTYPE),Darwin)
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -DOSX_
LDFLAGS_SIM = -Wall -prebind
LIBS_SIM = -lpthread -framework Carbon -framework GLUT -framework OpenGL -framework Foundation -framework AppKit
else
ifeq ($(OSTYPE),Linux)
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -D_XOPEN_SOURCE=600
LDFLAGS_SIM =
LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm
else
($(warning $(n)$(n)Simulator build is not supported on your system.$(n)$(n)\
Currently supported platforms:$(n) \
Linux on i386 and amd64$(n) \
FreeBSD on i386 and amd64$(n) \
NetBSD on i386 and amd64$(n) \
Windows (via Cygwin) on i386 and amd64)
endif
endif
endif
endif
endif
endif
##############################################################################
# the default target
$(TARGET):
##############################################################################
# include user's config.mk file
$(MAKETOPDIR)/config.mk:
@echo "# Customize your config here!" >$@
@echo "# Add further CFLAGS by using the += operator, eg." >>$@
@echo "# CFLAGS += -mstrict-X" >>$@
@echo "#" >>$@
@echo "# In case you wonder: -mstrict-X produces smaller code, but" >>$@
@echo "# is only available on avr-gcc 4.7.0 or higher." >>$@
@echo "#" >>$@
@echo "# Other flags you might want to tune: CPPFLAGS, LDFLAGS ..." >>$@
@echo "Created default config.mk, tune your settings there!"
-include $(MAKETOPDIR)/config.mk
##############################################################################
# configure load address for bootloader, if enabled
#
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),mrproper)
ifneq ($(MAKECMDGOALS),menuconfig)
include $(MAKETOPDIR)/.config
CPPFLAGS += -DF_CPU=$(FREQ)UL -mmcu=$(MCU)
LDFLAGS += -Wl,-Map,image.map -mmcu=$(MCU)
endif # MAKECMDGOALS!=menuconfig
endif # MAKECMDGOALS!=mrproper
endif # MAKECMDGOALS!=clean
ifeq ($(BOOTLOADER_SUPPORT),y)
LDFLAGS += -Wl,--section-start=.text=0xE000
CFLAGS += -mcall-prologues
endif
%.s: %.c
$(CC) -o $@ -O0 $(CPPFLAGS) -S $<
%.E: %.c
$(CC) -o $@ -O0 $(CPPFLAGS) -C -E -dD $<