# ******************************************************************************
# (C) Automotive-Lighting Reutlingen GmbH  -  ALRT/EEG
#     Tuebinger Strasse 123, 72762 Reutlingen, Germany
# ******************************************************************************

# ------------------------------------------------------------------------------
# file   Hal_030_Flags.gmk
#
# \brief compiler/assembler/linker options on HAL level
#
# \descr
#
# ------------------------------------------------------------------------------

# Result of this file:
#  CFLAGS_DEFAULT (Compiler flags for C)
#  CFLAGS_NOWARN  (Compiler flags for C, all warnings disabled)
#  CFLAGS_DEBUG   (Compiler flags for C, debug info available and optimization disabled)
#  CPPFLAGS       (Compiler flags for C++)
#  AFLAGS         (Compiler flags for assembler)
#  LDFLAGS        (Compiler flags for linker)

C_DEFINES       := $(C_DEFINES)

C_DEFINES_TOOL_INTERNAL := $(C_DEFINES_TOOL_INTERNAL)         \
                           __GNUC__=9                         \
                           __attribute__()=

CFLAGS_BASE      =

CFLAGS_OPT_SPACE = -Os

CFLAGS_OPT_SPEED = -O2

CFLAGS_OPT_DEBUG = -O0

CFLAGS_WARN_NONE = -w

CFLAGS_WARN_ALL  =

ifeq ($(TYP_CORE),M0P)
CFLAGS_CORE_M0P  = -mabi=aapcs                               \
                   -mcpu=cortex-m0plus                       \
                   -mtune=cortex-m0plus                      \
                   -march=armv6s-m                           \
                   -mthumb                                   \
                   -mfloat-abi=soft                          \
                   -mno-long-calls

CFLAGS_CORE      = $(CFLAGS_CORE_M0P)
endif

ifeq ($(TYP_CORE),M3)
CFLAGS_CORE_M3   = -mcpu=cortex-m3                           \
                   -mtune=cortex-m3                          \
                   -mthumb                                   \
                   -mfloat-abi=soft                          \
                   -mno-unaligned-access                     \
                   -mno-long-calls

CFLAGS_CORE      = $(CFLAGS_CORE_M3)
endif

ifeq ($(TYP_CORE),M4F)
CFLAGS_CORE_M4F  = -mcpu=cortex-m4                           \
                   -mtune=cortex-m4                          \
                   -mthumb                                   \
                   -mfloat-abi=hard                          \
                   -mfpu=fpv4-sp-d16                         \
                   -ffast-math                               \
                   -mno-unaligned-access                     \
                   -mno-long-calls

CFLAGS_CORE      = $(CFLAGS_CORE_M4F)
endif

CFLAGS_DEFAULT   = -x c                                      \
                   -std=c99                                  \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_CORE)                            \
                   $(CFLAGS_OPT_SPEED)                       \
                   $(CFLAGS_WARN_ALL)                        \
                   -Wunsuffixed-float-constants

CFLAGS_NOWARN    = -x c                                      \
                   -std=c99                                  \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_CORE)                            \
                   $(CFLAGS_OPT_SPEED)                       \
                   $(CFLAGS_WARN_NONE)

CFLAGS_DEBUG     = -x c                                      \
                   -std=c99                                  \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_CORE)                            \
                   $(CFLAGS_OPT_DEBUG)                       \
                   $(CFLAGS_WARN_ALL)

CPPFLAGS         = -x c++                                    \
                   -std=c++11                                \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_CORE)                            \
                   $(CFLAGS_OPT_SPEED)                       \
                   $(CFLAGS_WARN_ALL)

AFLAGS           = -x assembler                              \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_CORE)

LDFLAGS          = -nostdlib                                 \
                   -nostartfiles                             \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_CORE)
