Skip to content

Instantly share code, notes, and snippets.

@tritao
Created April 24, 2019 16:12
Show Gist options
  • Save tritao/352281e9dee9d8832c51772378b92102 to your computer and use it in GitHub Desktop.
Save tritao/352281e9dee9d8832c51772378b92102 to your computer and use it in GitHub Desktop.
############################################################################
# arch/avr/src/avr/Toolchain.defs
#
# Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
# Setup for the selected toolchain
#
# Handle old-style chip-specific toolchain names in the absence of
# a new-style toolchain specification, force the selection of a single
# toolchain and allow the selected toolchain to be overridden by a
# command-line selection.
#
ifeq ($(filter y, \
$(CONFIG_AVR_BUILDROOT_TOOLCHAIN) \
),y)
CONFIG_AVR_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, \
$(CONFIG_AVR_CROSSPACK_TOOLCHAIN) \
),y)
CONFIG_AVR_TOOLCHAIN ?= CROSSPACK
endif
ifeq ($(filter y, \
$(CONFIG_AVR_LINUXGCC_TOOLCHAIN) \
),y)
CONFIG_AVR_TOOLCHAIN ?= LINUXGCC
endif
ifeq ($(filter y, \
$(CONFIG_AVR_WINAVR_TOOLCHAIN) \
),y)
CONFIG_AVR_TOOLCHAIN ?= WINAVR
endif
ifeq ($(filter y, \
$(CONFIG_AVR_ATMEL_AVR_TOOLCHAIN) \
),y)
CONFIG_AVR_TOOLCHAIN ?= ATMEL
endif
# Chip-specific CPU flags
ifeq ($(CONFIG_ARCH_CHIP_ATMEGA128),y)
ARCHCPUFLAGS += -mmcu=atmega128
else ifeq ($(CONFIG_ARCH_CHIP_ATMEGA1284P),y)
ARCHCPUFLAGS += -mmcu=atmega1284p
else ifeq ($(CONFIG_ARCH_CHIP_AT90USB646),y)
ARCHCPUFLAGS += -mmcu=at90usb646
else ifeq ($(CONFIG_ARCH_CHIP_AT90USB647),y)
ARCHCPUFLAGS += -mmcu=at90usb647
else ifeq ($(CONFIG_ARCH_CHIP_AT90USB1286),y)
ARCHCPUFLAGS += -mmcu=at90usb1286
else ifeq ($(CONFIG_ARCH_CHIP_AT90USB1287),y)
ARCHCPUFLAGS += -mmcu=at90usb1287
else ifeq ($(CONFIG_ARCH_CHIP_ATMEGA2560),y)
ARCHCPUFLAGS += -mmcu=atmega2560
else
$(error "No valid CONFIG_ARCH_CHIP_ set in the configuration")
endif
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL)
endif
# NuttX buildroot GCC toolchain under Linux or Cygwin
ifeq ($(CONFIG_AVR_TOOLCHAIN),BUILDROOT)
CROSSDEV ?= avr-nuttx-elf-
MAXOPTIMIZATION ?= -O2
LDFLAGS += -nostartfiles -nodefaultlibs
endif
# AVR CrossPack under OS X
ifeq ($(CONFIG_AVR_TOOLCHAIN),CROSSPACK)
CROSSDEV ?= avr-
MAXOPTIMIZATION ?= -O2
LDFLAGS += -nostartfiles -nodefaultlibs
endif
# GCC toolchain under Linux
ifeq ($(CONFIG_AVR_TOOLCHAIN),LINUXGCC)
CROSSDEV ?= avr-
MAXOPTIMIZATION ?= -O2
LDFLAGS += -nostartfiles -nodefaultlibs
endif
# WinAVR or Atmel toolchain under Windows/Cygwin
_WINAVR = 0
ifeq ($(CONFIG_AVR_TOOLCHAIN),WINAVR)
_WINAVR = 1
endif
ifeq ($(CONFIG_AVR_TOOLCHAIN),ATMEL)
_WINAVR = 1
endif
ifeq ($(_WINAVR),1)
CROSSDEV ?= avr-
ifeq ($(CONFIG_WINDOWS_CYGWIN),y)
WINTOOL = y
endif
MAXOPTIMIZATION ?= -O2
LDFLAGS += -nostartfiles -nodefaultlibs
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment