flags.mk 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #-------------------------------------------------------------------------------
  2. # Copyright (c) 2012 Freescale Semiconductor, Inc.
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without modification,
  6. # are permitted provided that the following conditions are met:
  7. #
  8. # o Redistributions of source code must retain the above copyright notice, this list
  9. # of conditions and the following disclaimer.
  10. #
  11. # o Redistributions in binary form must reproduce the above copyright notice, this
  12. # list of conditions and the following disclaimer in the documentation and/or
  13. # other materials provided with the distribution.
  14. #
  15. # o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. # contributors may be used to endorse or promote products derived from this
  17. # software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. #-------------------------------------------------------------------------------
  30. #-------------------------------------------------------------------------------
  31. # Compiler flags
  32. #-------------------------------------------------------------------------------
  33. # Generate debug information.
  34. # Add '-O0' at the end of this line to turn off optimizations. This can make
  35. # debugging (especially asm) much easier but it greatly increases the size of
  36. # the code and reduces performance.
  37. CDEBUG = -g -O0 -DDEBUG=1
  38. # Turns on all -O2 except size increasers.
  39. # Any CDEBUG settings will come after this and can be used to override.
  40. COMMON_FLAGS += -Os
  41. COMMON_FLAGS += -mno-unaligned-access
  42. # Turn on dead code elimination.
  43. COMMON_FLAGS += -fdce
  44. # Enables all warnings and treat them as errors except those preceded with -Wno-
  45. C_FLAGS_WARNINGS = -Wall -Werror -Wno-uninitialized -Wno-strict-aliasing -Wno-unused-function -fdiagnostics-show-option
  46. C_FLAGS_WARNINGS += -Wno-unused-but-set-variable -Wno-format
  47. # Turn on all warnings.
  48. COMMON_FLAGS += $(C_FLAGS_WARNINGS)
  49. # Don't use common symbols. This is usually done in kernels. Makes
  50. # code size slightly larger and increases performance.
  51. COMMON_FLAGS += -fno-common
  52. # Use a freestanding build environment. Standard for kernels, implies
  53. # std library may not exist.
  54. COMMON_FLAGS += -ffreestanding -fno-builtin
  55. # Don't ever link anything against shared libs.
  56. COMMON_FLAGS += -static
  57. # Don't link against the system std library or compiler libraries.
  58. # Everything we link against MUST be specified with -I/-L explicitly.
  59. #COMMON_FLAGS += -nostdinc -nostdlib
  60. # Set the C standard to C99 with GNU extensions.
  61. # Use traditional GNU inline function semantics.
  62. C99_FLAGS = -std=gnu99 -fgnu89-inline
  63. # Generate code specifically for ARMv7-A, cortex-ax CPU.
  64. # Use the ARM Procedure Call Standard.
  65. ARM_FLAGS = -march=armv7-a -mcpu=$(CPU) -mtune=$(CPU) -mapcs
  66. ifeq "$(USE_THUMB)" "1"
  67. # Generate thumb2 instructions (mixed 16/32-bit).
  68. ARM_FLAGS += -mthumb
  69. # Allow mixed ARM and thumb code. All C code will generate thumb instructions
  70. # but there is hand-written asm that requires ARM.
  71. ARM_FLAGS += -mthumb-interwork
  72. # Indicate that we're using thumb.
  73. ARM_FLAGS += -DUSE_THUMB
  74. CC_LIB_POST = thumb2
  75. else
  76. # Generate ARM-only code.
  77. ARM_FLAGS += -marm
  78. CC_LIB_POST =
  79. endif
  80. # Use NEON SIMD instructions for floating point. Alternatively can specify
  81. # VFP which gives IEEE 754-compliance (unlike NEON which can have errors).
  82. ARM_FLAGS += -mfpu=neon
  83. # Specify these options with NEON.
  84. ARM_FLAGS += -ftree-vectorize
  85. ARM_FLAGS += -fno-math-errno
  86. ARM_FLAGS += -funsafe-math-optimizations
  87. ARM_FLAGS += -fno-signed-zeros
  88. # Use float-abi=softfp for soft floating point api with HW instructions.
  89. # Alternatively, float-abi=hard for hw float instructions and pass float args in float regs.
  90. ARM_FLAGS += -mfloat-abi=softfp
  91. # Build common flags shared by C and C++.
  92. COMMON_FLAGS += $(ARM_FLAGS)
  93. # Add debug flags for debug builds.
  94. ifeq "$(DEBUG)" "1"
  95. COMMON_FLAGS += $(CDEBUG)
  96. endif
  97. # C flags. Set C99 mode.
  98. CFLAGS += $(COMMON_FLAGS)
  99. CFLAGS += $(C99_FLAGS)
  100. # C++ flags. Disable exceptions and RTTI.
  101. CXXFLAGS += $(COMMON_FLAGS)
  102. CXXFLAGS += -fno-exceptions -fno-rtti
  103. #-------------------------------------------------------------------------------
  104. # Include paths
  105. #-------------------------------------------------------------------------------
  106. # Link against libc and libgcc. Specify paths to libc in newlib build
  107. # directory. Need to specify libgcc since our linker does not link
  108. # against anything, even compiler libs because of -nostdlib.
  109. LDADD += -lm -lstdc++ -lc -lgcc
  110. # These include paths have to be quoted because they may contain spaces,
  111. # particularly under cygwin.
  112. LDINC += -L '$(LIBGCC_LDPATH)' -L '$(LIBC_LDPATH)'
  113. # Indicate gcc and newlib std includes as -isystem so gcc tags and
  114. # treats them as system directories.
  115. SYSTEM_INC = \
  116. -isystem '$(CC_INCLUDE)' \
  117. -isystem '$(CC_INCLUDE_FIXED)' \
  118. -isystem '$(LIBC_INCLUDE)'
  119. INCLUDES += \
  120. -I$(SDK_ROOT)/sdk \
  121. -I$(SDK_ROOT)/sdk/include \
  122. -I$(SDK_ROOT)/sdk/include/$(TARGET) \
  123. -I$(SDK_ROOT)/sdk/drivers \
  124. -I$(SDK_ROOT)/sdk/common \
  125. -I$(SDK_ROOT)/sdk/core \
  126. -I$(SDK_ROOT)/sdk/utility \
  127. -I$(BOARD_ROOT) \
  128. -I$(SDK_ROOT)/board/$(TARGET)/common \
  129. -I$(SDK_ROOT)/board/common \
  130. -I$(LWIP_ROOT)/lwip/src/include \
  131. -I$(LWIP_ROOT)/lwip/src/include/ipv4 \
  132. -I$(LWIP_ROOT)/lwip/src/include/ipv6 \
  133. -I$(LWIP_ROOT)/mx6/include