# ******************************************************************************
# (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__=8                        \
                           __MINGW__                         \
                           __attribute__()=

CFLAGS_BASE      = -m64                                      \
                   -ffunction-sections                       \
                   -fdata-sections

CFLAGS_OPT_SPACE = -Os                                       \

CFLAGS_OPT_SPEED = -O3

CFLAGS_OPT_DEBUG = -O1                                       \
                   -g

CFLAGS_WARN_NONE = -w

CFLAGS_WARN_ALL  = -Wall                                     \
                   -Wextra                                   \
                   -pedantic                                 \
                   -Wmain                                    \
                   -Wsign-conversion                         \
                   -Wunused-parameter                        \
                   -Wuninitialized                           \
                   -Wunreachable-code                        \
                   -Wswitch-default                          \
                   -Wcast-align                              \
                   -Wmissing-include-dirs                    \
                   -Winit-self                               \
                   -Wdouble-promotion                        \
                   -Wno-unknown-pragmas                      \
                   -Wno-unused-variable                      \
                   -Wno-unused-parameter                     \
                   -Wno-misleading-indentation

CFLAGS_DEFAULT   = -x c                                      \
                   -std=c99                                  \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_OPT_DEBUG)                       \
                   $(CFLAGS_WARN_ALL)                        \
                   -Wunsuffixed-float-constants

CFLAGS_NOWARN    = -x c                                      \
                   -std=c99                                  \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_OPT_SPEED)                       \
                   $(CFLAGS_WARN_NONE)

CFLAGS_DEBUG     = -x c                                      \
                   -std=c99                                  \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_OPT_DEBUG)                       \
                   $(CFLAGS_WARN_ALL)

CFLAGS_COVER     = -g                                        \
                   -fprofile-arcs                            \
                   -ftest-coverage

CPPFLAGS         = -x c++                                    \
                   -std=c++11                                \
                   $(CFLAGS_CORE)                            \
                   $(CFLAGS_OPT_SPEED)                       \
                   $(CFLAGS_WARN_ALL)

CPPFLAGS_NOWARN  = -x c++                                    \
                   -std=c++11                                \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_OPT_SPEED)                       \
                   $(CFLAGS_WARN_NONE)

CPPFLAGS_DEBUG   = -x c++                                    \
                   -std=c++11                                \
                   $(CFLAGS_BASE)                            \
                   $(CFLAGS_OPT_DEBUG)                       \
                   $(CFLAGS_WARN_ALL)

AFLAGS           = -x assembler                              \
                   $(CFLAGS_BASE)

LDFLAGS          = -x none                                   \
                   -flto                                     \
                   -Wl,--gc-sections                         \
                   $(CFLAGS_BASE)
