rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | ## |
| 2 | # @file Makefile.config |
| 3 | # |
| 4 | # @brief This file contains the global default tool arguments, |
| 5 | # which could be appended or overwrited by each module |
| 6 | # |
| 7 | # @author Howard Chen |
| 8 | ## |
| 9 | |
| 10 | ## |
| 11 | # @brief option flags for gcc/tcc |
| 12 | # @param CC : option for c compiler |
| 13 | # @param CXX : option for c++ compiler |
| 14 | # @param WALL : option for warning message |
| 15 | # @param DEBUG : option for debugging format |
| 16 | # @param MOPTS : option for specific target |
| 17 | # @param INCLUDE_ADD : INCLUDE ADD-ON |
| 18 | # @param LDFLAGS_ADD : LDFLAGS ADD-ON |
| 19 | # @param SYS_LIBS : SYSTEM library add for image linking |
| 20 | # @param STARTUP : startup code (if any) |
| 21 | ## |
| 22 | |
| 23 | GCC = $(CROSS)gcc |
| 24 | CC = $(GCC) |
| 25 | CXX = $(CROSS)g++ |
| 26 | ## |
| 27 | # -------------[ config for native ]------------------------------ |
| 28 | ## |
| 29 | ifeq ($(CROSS),) |
| 30 | ifeq ($(strip $(LINUX)),2) |
| 31 | #Linux kernel space |
| 32 | #MOPTS ?= -m32 -fno-builtin -D__KERNEL__ -I../linux/include -DMODULE -DMODVERSIONS -include ../linux/include/linux/modversions.h |
| 33 | MOPTS ?= -m32 -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 34 | CONFIG += -DLINUX |
| 35 | else |
| 36 | WALL ?= -Wall |
| 37 | DEBUGS ?= -g |
| 38 | MOPTS ?= -m32 |
| 39 | ifeq ($(strip $(LINUX)),1) |
| 40 | CONFIG += -DLINUX |
| 41 | endif |
| 42 | SYS_LIBS?= pthread rt |
| 43 | RUN ?= ./ |
| 44 | endif |
| 45 | DEF_ASFLAGS=-m32 |
| 46 | endif |
| 47 | |
| 48 | ifeq ($(strip $(CROSS)),arm-none-linux-) |
| 49 | ifeq ($(strip $(LINUX)),2) |
| 50 | #Linux kernel space |
| 51 | MOPTS ?= -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 52 | CONFIG += -DLINUX |
| 53 | else |
| 54 | WALL ?= -Wall |
| 55 | DEBUGS ?= -g |
| 56 | THUMB ?=-mthumb |
| 57 | MOPTS ?= -fcall-saved-r10 -march=armv5te -ffunction-sections -fdata-sections -mthumb-interwork -msoft-float |
| 58 | CONFIG += -DLINUX |
| 59 | SYS_LIBS?= pthread rt |
| 60 | RUN ?= |
| 61 | DEF_ASFLAGS = $(DEBUGS) |
| 62 | endif |
| 63 | DEF_ASFLAGS = -msoft-float -mthumb-interwork |
| 64 | endif |
| 65 | |
| 66 | ifeq ($(strip $(CROSS)),mipsel-linux-) |
| 67 | ifeq ($(strip $(LINUX)),2) |
| 68 | #Linux kernel space |
| 69 | MOPTS ?= -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 70 | CONFIG += -DLINUX |
| 71 | else |
| 72 | WALL ?= -Wall |
| 73 | DEBUGS ?= -g |
| 74 | #THUMB ?=-mthumb |
| 75 | #MOPTS ?= -fcall-saved-r10 -march=armv5te -ffunction-sections -fdata-sections -mthumb-interwork -msoft-float |
| 76 | CONFIG += -DLINUX |
| 77 | SYS_LIBS?= pthread rt |
| 78 | RUN ?= |
| 79 | DEF_ASFLAGS = $(DEBUGS) |
| 80 | endif |
| 81 | DEF_ASFLAGS = -msoft-float -mdsp -mdspr2 |
| 82 | endif |
| 83 | |
| 84 | ifeq ($(strip $(CROSS)),arm-linux-) |
| 85 | ifeq ($(strip $(LINUX)),2) |
| 86 | #Linux kernel space |
| 87 | MOPTS ?= -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 88 | CONFIG += -DLINUX |
| 89 | else |
| 90 | WALL ?= -Wall |
| 91 | DEBUGS ?= -g |
| 92 | THUMB ?=-mthumb |
| 93 | ifeq ($(PLATFORM),mt6280) |
| 94 | MOPTS ?= -fcall-saved-r10 -march=armv5te -ffunction-sections -fdata-sections -mthumb-interwork |
| 95 | else |
| 96 | ifeq ($(PLATFORM),mt6290) |
| 97 | MOPTS ?= -fcall-saved-r10 -march=armv7-a -ffunction-sections -fdata-sections -mthumb |
| 98 | else |
| 99 | ifeq ($(PLATFORM),mt6297) |
| 100 | MOPTS ?= -fcall-saved-r10 -march=armv7-a -ffunction-sections -fdata-sections -mthumb |
| 101 | else |
| 102 | ifeq ($(PLATFORM),qemu) |
| 103 | MOPTS ?= -fcall-saved-r10 -march=armv7-a -ffunction-sections -fdata-sections -mthumb |
| 104 | else |
| 105 | MOPTS ?= -fcall-saved-r10 -march=armv6zk -ffunction-sections -fdata-sections -mthumb-interwork -mfpu=vfp -mfloat-abi=softfp |
| 106 | endif |
| 107 | endif |
| 108 | endif |
| 109 | endif |
| 110 | CONFIG += -DLINUX -DBOARD_VER_$(BOARD_VER) -DREL_TYPE_$(REL_TYPE) |
| 111 | SYS_LIBS?= pthread rt |
| 112 | RUN ?= |
| 113 | DEF_ASFLAGS = $(DEBUGS) |
| 114 | endif |
| 115 | ifeq ($(PLATFORM),mt6280) |
| 116 | DEF_ASFLAGS = -mthumb-interwork |
| 117 | else |
| 118 | DEF_ASFLAGS = -mfpu=vfp -mfloat-abi=softfp -mthumb-interwork |
| 119 | endif |
| 120 | endif |
| 121 | |
| 122 | ifeq ($(strip $(CROSS)),aarch64-linux-) |
| 123 | ifeq ($(strip $(LINUX)),2) |
| 124 | #Linux kernel space |
| 125 | MOPTS ?= -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 126 | CONFIG += -DLINUX |
| 127 | else |
| 128 | WALL ?= -Wall |
| 129 | DEBUGS ?= -g |
| 130 | MOPTS ?= -march=armv8-a -ffunction-sections -fdata-sections |
| 131 | CONFIG += -DLINUX |
| 132 | SYS_LIBS?= pthread rt |
| 133 | RUN ?= |
| 134 | DEF_ASFLAGS = $(DEBUGS) |
| 135 | endif |
| 136 | endif |
| 137 | |
| 138 | ifeq ($(strip $(CROSS)),aarch64-poky-linux-) |
| 139 | INCLUDE_ADD += $(BB_INCLUDE_ADD) |
| 140 | LDFLAGS_ADD += $(BB_LDFLAGS_ADD) ${BB_LDPATH_ADD} |
| 141 | MOPTS += $(BB_CFLAGS_ADD) |
| 142 | ifeq ($(strip $(LINUX)),2) |
| 143 | #Linux kernel space |
| 144 | MOPTS += -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 145 | CONFIG += -DLINUX |
| 146 | else |
| 147 | WALL ?= -Wall |
| 148 | DEBUGS ?= -g |
| 149 | MOPTS += -march=armv8-a -ffunction-sections -fdata-sections |
| 150 | CONFIG += -DLINUX |
| 151 | SYS_LIBS?= pthread rt |
| 152 | RUN ?= |
| 153 | DEF_ASFLAGS = $(DEBUGS) |
| 154 | endif |
| 155 | endif |
| 156 | |
| 157 | ifneq ($(filter arm-poky-linux-gnueabi- arm-pokymllib32-linux-gnueabi-, $(strip $(CROSS))),) |
| 158 | INCLUDE_ADD += $(BB_INCLUDE_ADD) |
| 159 | LDFLAGS_ADD += $(BB_LDFLAGS_ADD) ${BB_LDPATH_ADD} |
| 160 | MOPTS += $(BB_CFLAGS_ADD) |
| 161 | ifeq ($(strip $(LINUX)),2) |
| 162 | #Linux kernel space |
| 163 | MOPTS ?= -fno-builtin -D__KERNEL__ -DMODULE -DMODVERSIONS |
| 164 | CONFIG += -DLINUX |
| 165 | else |
| 166 | WALL ?= -Wall |
| 167 | DEBUGS ?= -g |
| 168 | THUMB ?=-mthumb |
| 169 | MOPTS ?= -fcall-saved-r10 -march=armv7-a -ffunction-sections -fdata-sections -mthumb-interwork -mfpu=vfp -mfloat-abi=softfp -mtune=cortex-a7 |
| 170 | CONFIG += -DLINUX |
| 171 | ifeq ($(strip $(PACKAGE_ARCH)),$(filter $(strip $(PACKAGE_ARCH)), cortexa7hf-vfp-vfpv4-neon cortexa7hf-neon-vfpv4)) |
| 172 | MOPTS += -fcall-saved-r10 -march=armv7-a -ffunction-sections -fdata-sections -mthumb-interwork -mfpu=neon-vfpv4 -mfloat-abi=hard -mtune=cortex-a7 |
| 173 | CONFIG += -mhard-float |
| 174 | endif |
| 175 | ifeq ($(strip $(PACKAGE_ARCH)),$(filter $(strip $(PACKAGE_ARCH)), cortexa53hf-neon-fp-armv8)) |
| 176 | MOPTS += -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53 -ffunction-sections -fdata-sections |
| 177 | CONFIG += -mhard-float |
| 178 | endif |
| 179 | SYS_LIBS?= pthread rt |
| 180 | RUN ?= |
| 181 | DEF_ASFLAGS = $(DEBUGS) |
| 182 | endif |
| 183 | DEF_ASFLAGS = -mfpu=vfp -mfloat-abi=softfp -mthumb-interwork |
| 184 | |
| 185 | endif |
| 186 | |
| 187 | |
| 188 | ## |
| 189 | # ------------- config for arm-none-eabi- --------------------------------- |
| 190 | # @param THUMB thumb-mode switch |
| 191 | # @param ARM arm-mode switch |
| 192 | # @param EL little-endian switch |
| 193 | # @param EB big-endian switch |
| 194 | # @param COMPILER rvds/gcc switch |
| 195 | # @param INIT initial scheme |
| 196 | ## |
| 197 | ifeq ($(strip $(CROSS)),arm-none-eabi-) |
| 198 | RUN ?=mdebug 192.168.0.8 9000 |
| 199 | ifeq ($(strip $(COMPILER)),RVDS) |
| 200 | CC = tcc |
| 201 | CXX = tcc |
| 202 | endif |
| 203 | |
| 204 | ifeq ($(strip $(COMPILER)),RVDS) |
| 205 | WALL ?= |
| 206 | DEBUG ?=-g |
| 207 | THUMB ?=--thumb |
| 208 | ARM ?=--arm |
| 209 | EL ?=--littleend |
| 210 | EB ?=--bigend |
| 211 | MOPTS ?=--cpu arm9 |
| 212 | else |
| 213 | WALL ?=-Wall |
| 214 | DEBUGS ?=-gstabs |
| 215 | THUMB ?=-mthumb |
| 216 | ARM ?=-marm |
| 217 | EL ?=-mlittle-endian |
| 218 | EB ?=-mbig-endian |
| 219 | MOPTS ?=-fcall-saved-r10 -mthumb-interwork -march=armv5te -msoft-float -ffunction-sections -fdata-sections |
| 220 | endif |
| 221 | |
| 222 | ifeq ($(strip $(COMPILER)),RVDS) |
| 223 | INCLUDE_ADD += -I /usr/local/ARM/RVCT/Data/2.2/349/include/unix/ |
| 224 | endif |
| 225 | ifeq ($(strip $(NEWLIB)),1) |
| 226 | CONFIG += -DNEWLIB |
| 227 | endif |
| 228 | LD_SCRIPT ?= -Tlink.ld |
| 229 | INIT ?= base_init |
| 230 | SYS_LIBS ?= gcc c |
| 231 | SYS_LIBS += $(INIT) |
| 232 | LDFLAGS_ADD += -nostartfiles -nodefaultlibs -Wl,--gc-sections $(LD_SCRIPT) |
| 233 | STARTUP ?= $(ROOT)/lib/startup.o |
| 234 | DEF_ASFLAGS = -msoft-float -mthumb-interwork |
| 235 | endif |
| 236 | |
| 237 | ## |
| 238 | # -------------[ config for arm-none-elf- ]------------------------------ |
| 239 | # @param THUMB thumb-mode switch |
| 240 | # @param ARM arm-mode switch |
| 241 | # @param EL little-endian switch |
| 242 | # @param EB big-endian switch |
| 243 | # @param NEWLIB use toolchain supported newlib |
| 244 | # @param INIT initial scheme |
| 245 | ## |
| 246 | ifeq ($(strip $(CROSS)),arm-none-elf-) |
| 247 | |
| 248 | WALL ?=-Wall |
| 249 | DEBUGS ?=-g |
| 250 | THUMB ?=-mthumb |
| 251 | ARM ?=-marm |
| 252 | EL ?=-mlittle-endian |
| 253 | EB ?=-mbig-endian |
| 254 | MOPTS ?=-fcall-saved-r10 -mthumb-interwork -march=armv5te -msoft-float -ffunction-sections -fdata-sections |
| 255 | NEWLIB ?= 1 |
| 256 | RUN ?=mdebug 192.168.0.8 9000 |
| 257 | ifeq ($(strip $(NEWLIB)),1) |
| 258 | CONFIG += -D NEWLIB |
| 259 | SYS_LIBS ?= gcc c |
| 260 | SYS_LIBS += $(INIT) |
| 261 | LD_SCRIPT ?= -Tlink.ld |
| 262 | LDFLAGS_ADD += -nostartfiles -nodefaultlibs -Wl,--gc-sections $(LD_SCRIPT) |
| 263 | INIT ?= base_init |
| 264 | STARTUP ?= $(ROOT)/lib/startup.o -l$(INIT) |
| 265 | else |
| 266 | INCLUDE_ADD += -I $(ROOT)/include/ecos |
| 267 | SYS_LIBS ?= |
| 268 | LD_SCRIPT = -Tecos.ld # note , application with ecos must use ecos.ld |
| 269 | LDFLAGS_ADD +=-nostdlib -nodefaultlibs -nostartfiles -Wl,--gc-sections $(LD_SCRIPT) |
| 270 | endif |
| 271 | DEF_ASFLAGS = $(DEBUGS) -msoft-float -mthumb-interwork |
| 272 | CXXFLAGS_ADD = -fno-rtti -fno-exceptions |
| 273 | endif |
| 274 | |
| 275 | ## |
| 276 | # -------------[ config for i586-mingw32msvc-]------------------------------ |
| 277 | ## |
| 278 | ifeq ($(strip $(CROSS)),i586-mingw32msvc-) |
| 279 | WALL ?=-Wall |
| 280 | DEBUGS ?=-g |
| 281 | MOPTS ?=-m32 |
| 282 | SYS_LIBS ?= ws2_32 iberty |
| 283 | LDFLAGS_ADD += |
| 284 | RUN ?= |
| 285 | endif |
| 286 | |
| 287 | |
| 288 | ## |
| 289 | # @param DEF_INCLUDE: default include path |
| 290 | # @param DEF_CFLAGS: default compiler options |
| 291 | # (debugger information/ warning/ little-endian) |
| 292 | # |
| 293 | # @param DEF_ASFLAGS: default assembler options (debugger information) |
| 294 | # |
| 295 | # @param DEF_LDFLAGS: default linker options ( link with each libary specified |
| 296 | # in the $(DEP_LIBS) variable and specify the $(PREFIX)/lib and current |
| 297 | # directory as the library search path |
| 298 | ## |
| 299 | CROSS_SUP ?= arm-none-eabi- |
| 300 | ROOT ?= $(PREFIX)/$(CROSS:%-=%) |
| 301 | STRICT ?= 0 |
| 302 | ifeq ($(strip $(STRICT)),1) |
| 303 | DEF_CFLAGS = $(DEBUGS) $(MOPTS) $(WALL) -Werror |
| 304 | else |
| 305 | DEF_CFLAGS = $(DEBUGS) $(MOPTS) $(WALL) |
| 306 | endif |
| 307 | |
| 308 | DEF_INCLUDE = -I include -I $(ROOT)/include $(INCLUDE_ADD) |
| 309 | |
| 310 | SIM_LIBS ?= $(patsubst $(NAME),,$(patsubst basegltarget,baseglsim,$(DEP_LIBS))) |
| 311 | |
| 312 | ifeq ($(strip $(DEP_LIBS_AUTO)),1) |
| 313 | _DEP_LIBS?=$(shell wimac_dep.sh $(NAME) "$(DEP_LIBS)" "$(DEP_LIBS_EX)") |
| 314 | else |
| 315 | _DEP_LIBS?=$(DEP_LIBS) |
| 316 | endif |
| 317 | |
| 318 | DEP_LIBS_LD = -L. -L $(ROOT)/lib \ |
| 319 | -Xlinker --start-group -Xlinker -l$(NAME) \ |
| 320 | $(foreach _LIB, $(_DEP_LIBS), -Xlinker -l$(_LIB)) \ |
| 321 | $(foreach _LIB, $(SYS_LIBS), -Xlinker -l$(_LIB)) \ |
| 322 | -Xlinker --end-group |
| 323 | |
| 324 | DEF_LDFLAGS = $(STARTUP) $(LDFLAGS_ADD) $(DEBUGS) $(MOPTS) $(DEP_LIBS_LD) |
| 325 | |
| 326 | HEXPAD=0 |
| 327 | |
| 328 | #ifeq ($(strip $(NAME)),base) |
| 329 | #else |
| 330 | #include $(PREFIX)/.Makefile |
| 331 | #endif |