2008-12-03 05:40:16 +00:00
|
|
|
# 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
|
|
|
|
|
2011-03-14 10:33:49 +00:00
|
|
|
LIBS = -lm
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
# flags for the compiler
|
|
|
|
CFLAGS ?= -Wall -W -Wno-unused-parameter -Wno-sign-compare
|
2012-10-17 08:32:07 +00:00
|
|
|
CFLAGS += -g -Os -std=gnu99 -fgnu89-inline -D_XOPEN_SOURCE=600 -DNDEBUG
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2008-12-03 13:22:20 +00:00
|
|
|
#############################################################################
|
|
|
|
#Settings for Simulator build
|
|
|
|
|
2013-01-04 05:43:36 +00:00
|
|
|
#ugly hack to define a newline (yes, there are two blank lines, on purpose!!)
|
|
|
|
define n
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2012-12-27 16:55:13 +00:00
|
|
|
OSTYPE = $(shell uname)
|
2009-07-18 16:55:02 +00:00
|
|
|
MACHINE = $(shell uname -m)
|
2008-12-28 21:49:28 +00:00
|
|
|
|
2013-01-04 05:43:36 +00:00
|
|
|
ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN)
|
2012-10-17 08:29:41 +00:00
|
|
|
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -D_WIN32 -D_XOPEN_SOURCE=600
|
2014-03-01 08:09:21 +00:00
|
|
|
ifeq ($(MACHINE),x86_64)
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS_SIM = -T ld_scripts/i386pep.x
|
2014-03-01 08:09:21 +00:00
|
|
|
else
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS_SIM = -T ld_scripts/i386pe.x
|
2014-03-01 08:09:21 +00:00
|
|
|
endif
|
2012-10-17 08:29:41 +00:00
|
|
|
LIBS_SIM = -lgdi32 -lwinmm -lm
|
2008-12-28 21:49:28 +00:00
|
|
|
else
|
2012-12-27 16:55:13 +00:00
|
|
|
ifeq ($(OSTYPE),FreeBSD)
|
|
|
|
CFLAGS_SIM = -g -I/usr/local/include -Wall -pedantic -std=c99 -O0 -D_XOPEN_SOURCE=600
|
|
|
|
ifeq ($(MACHINE),amd64)
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS_SIM = -L/usr/local/lib -T ld_scripts/elf_x86_64_fbsd.x
|
2012-12-27 16:55:13 +00:00
|
|
|
else
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS_SIM = -L/usr/local/lib -T ld_scripts/elf_i386_fbsd.x
|
2012-12-27 16:55:13 +00:00
|
|
|
endif
|
|
|
|
LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm
|
2009-07-18 16:55:02 +00:00
|
|
|
else
|
2013-01-04 05:43:36 +00:00
|
|
|
ifeq ($(OSTYPE),Linux)
|
|
|
|
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -D_XOPEN_SOURCE=600
|
|
|
|
ifeq ($(MACHINE),x86_64)
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS_SIM = -T ld_scripts/elf_x86_64.x
|
2013-01-04 05:43:36 +00:00
|
|
|
else
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS_SIM = -T ld_scripts/elf_i386.x
|
2013-01-04 05:43:36 +00:00
|
|
|
endif
|
|
|
|
LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm
|
2012-12-27 16:55:13 +00:00
|
|
|
else
|
2013-01-04 05:43:36 +00:00
|
|
|
($(error $(n)$(n)Simulator build is not supported on your system.$(n)$(n)\
|
|
|
|
Currently supported platforms:$(n) \
|
|
|
|
Linux on x86 and amd64$(n) \
|
|
|
|
FreeBSD on x86 and amd64$(n) \
|
|
|
|
Windows (through Cygwin) on x86 and amd64)
|
2012-12-27 16:55:13 +00:00
|
|
|
endif
|
2009-07-18 16:55:02 +00:00
|
|
|
endif
|
2008-12-28 21:49:28 +00:00
|
|
|
endif
|
2008-12-03 13:22:20 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
# the default target
|
|
|
|
$(TARGET):
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# include user's config.mk file
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
config.mk:
|
2008-12-03 05:40:16 +00:00
|
|
|
@echo "# Put your own config here!" > $@
|
|
|
|
@echo "#F_CPU = $(F_CPU)" >> $@
|
|
|
|
@echo "#MCU = $(MCU)" >> $@
|
|
|
|
@echo "created default config.mk, tune your settings there!"
|
2014-03-18 06:00:13 +00:00
|
|
|
-include config.mk
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# configure load address for bootloader, if enabled
|
|
|
|
#
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
ifneq ($(MAKECMDGOALS),mrproper)
|
|
|
|
ifneq ($(MAKECMDGOALS),menuconfig)
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
include $(MAKETOPDIR)/.config
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
CPPFLAGS += -DF_CPU=$(FREQ)UL -mmcu=$(MCU)
|
|
|
|
|
2014-03-11 19:44:13 +00:00
|
|
|
# flags for the linker
|
|
|
|
ifeq ($(findstring atmega128,$(MCU)),atmega128)
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS += -T ld_scripts/avr51.x -Wl,-Map,image.map -mmcu=$(MCU)
|
2014-03-11 19:44:13 +00:00
|
|
|
else
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS += -T ld_scripts/avr5.x -Wl,-Map,image.map -mmcu=$(MCU)
|
2014-03-11 19:44:13 +00:00
|
|
|
endif
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
endif # MAKECMDGOALS!=menuconfig
|
|
|
|
endif # MAKECMDGOALS!=mrproper
|
|
|
|
endif # MAKECMDGOALS!=clean
|
|
|
|
|
|
|
|
ifeq ($(BOOTLOADER_SUPPORT),y)
|
2014-03-18 06:00:13 +00:00
|
|
|
LDFLAGS += -Wl,--section-start=.text=0xE000
|
|
|
|
CFLAGS += -mcall-prologues
|
2008-12-03 05:40:16 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
%.s: %.c
|
|
|
|
$(CC) -o $@ -O0 $(CPPFLAGS) -S $<
|
|
|
|
|
|
|
|
%.E: %.c
|
|
|
|
$(CC) -o $@ -O0 $(CPPFLAGS) -C -E -dD $<
|
|
|
|
|