Make.config (8575B)
1 # 2 # Copyright 2017 Broadcom 3 # 4 # This program is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License, version 2, as 6 # published by the Free Software Foundation (the "GPL"). 7 # 8 # This program is distributed in the hope that it will be useful, but 9 # WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 # General Public License version 2 (GPLv2) for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # version 2 (GPLv2) along with this source code. 15 # 16 # $Id: Make.config,v 1.3 Broadcom SDK $ 17 # $Copyright: (c) 2005 Broadcom Corp. 18 # All Rights Reserved.$ 19 # 20 21 ifneq ($(strip $(override-target)),) 22 override TARGET=$(override-target) 23 endif 24 25 export TARGET 26 27 # 28 # Set up the target name, and the target base variables. 29 # 30 # target = The full name of the target such as vxworks-bmw 31 # targetbase = 1st part of target (e.g. vxworks) 32 # targetplat = 2nd part of target (e.g. x86) if any; otherwise same as 1st 33 # 34 target = ${TARGET} 35 targetsplt = $(subst -, , ${target}) # change hyphens to spaces 36 targetbase = $(word 1,${targetsplt}) 37 targetplat = $(subst ${targetbase}-,,${TARGET}) 38 39 # 40 # Common configuration for all platforms 41 # (Additional platform-dependent configurations are in Makefile.xxx) 42 # 43 44 # 45 # THIS FILE SHOULD NOT BE MODIFIED LOCALLY, to override, add a file 46 # $SDK/make/Make.local that sets your local settings, and/or provide 47 # a path to your settings using the MAKE_LOCAL variable. If 48 # either of these files exists, their values will override those in this makefile. 49 # 50 ifdef MAKE_LOCAL 51 -include ${MAKE_LOCAL} 52 endif 53 54 -include ${SDK}/make/Make.local 55 56 ifdef ALL_CHIPS 57 ESW_CHIPS = 1 58 endif # ALL_CHIPS 59 60 # 61 # By default, turn off the "changing directory" message. 62 # 63 MAKEFLAGS += --no-print-directory 64 65 # 66 # Use gmake by default 67 # 68 69 include ${SDK}/make/Make.tools 70 include ${SDK}/make/Makefile.${target} 71 72 # use QUIET=1 to control printing of compilation lines 73 ifdef QUIET 74 Q:=@ 75 else 76 Q:= 77 endif 78 79 # 80 # Suffix to add to the "target" files to allow local builds with different 81 # flags. Set "target_suffix" to XXX to cause the build to put built objects 82 # in ${target}${target_suffix}. This allows things like building a debug 83 # version with different flags. This may also be set in another Makefile. 84 # 85 86 #target_suffix := 87 88 # 89 # Optional suffix to add to the build directory and output binary files 90 # to allow multiple builds to co-exist for various reasons. 91 # 92 #chip_suffix := -$(shell echo $(CHIP) | tr A-Z a-z) 93 94 # 95 # Combined suffixes 96 # 97 all_suffix = ${chip_suffix}${target_suffix} 98 99 # 100 # Default location to place binaries and make depend files for building 101 # purposes. 102 # 103 ifeq "$(HOSTTYPE)" "Windows2000PC" 104 BLDROOTWITHDRIVE = ${SDK}/build/${target}${all_suffix}${bldroot_suffix} 105 BLDROOT = ${SDK_NO_DRIVE_NAME}/build/${target}${all_suffix}${bldroot_suffix} 106 else # ifeq "$(HOSTTYPE)" "Windows2000PC" 107 108 ifndef SDKBUILD 109 SDKBUILD :=build 110 endif 111 112 BLDROOT = ${SDK}/${SDKBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${target}${all_suffix}${bldroot_suffix} 113 114 endif # ifeq "$(HOSTTYPE)" "Windows2000PC" 115 116 # This is needed because we cannot include Make.vxworks before Make.config 117 ifndef DEST_DIR_SUFFIX 118 export DEST_DIR_SUFFIX :=$(subst $(realpath $(SDK))/systems,,$(realpath $(CURDIR)/$(dir ($(firstword $(MAKEFILE_LIST)))))) 119 ifeq ($(MAKELEVEL),0) 120 endif 121 endif 122 123 ifeq ($(DEST_DIR),) 124 export DEST_DIR :=${SDK}/${SDKBUILD}$(if ${BLDCONFIG},/${BLDCONFIG})$(DEST_DIR_SUFFIX) 125 endif 126 127 ifdef LOCALDIR 128 BLDDIR = ${BLDROOT}/${LOCALDIR} 129 ifeq "$(HOSTTYPE)" "Windows2000PC" 130 BLDDIRWITHDRIVE = ${BLDROOTWITHDRIVE}/${LOCALDIR} 131 endif 132 else # ifdef LOCALDIR 133 BLDDIR = ${BLDROOT} 134 ifeq "$(HOSTTYPE)" "Windows2000PC" 135 BLDDIRWITHDRIVE = ${BLDROOTWITHDRIVE} 136 endif 137 endif # ifdef LOCALDIR 138 139 LIBDIR = ${BLDROOT} 140 141 # 142 # Export directory, where build objects used by the outside world are 143 # placed (exported header files, libs, bins) 144 # 145 EXPDIR = ${SDK}/export/${target}${all_suffix} 146 147 # 148 # Standard include paths 149 # 150 INCDIR = ${SDK}/include 151 152 # 153 # Compilation Flags 154 # 155 # Flags may be added to (see below) 156 # 157 158 INCFLAGS = -I${INCDIR} -I${SDK}/systems 159 160 CFLAGS += ${INCFLAGS} 161 CXXFLAGS += ${INCFLAGS} 162 CPPFLAGS += ${INCFLAGS} 163 164 # 165 # Debug #ifdef control 166 # 167 # Compiling out #ifdef DEBUG code saves about 1.3% on executable size. 168 # It is recommended to leave debug enabled when developing applications. 169 # 170 ifndef DEBUG_IFDEFS 171 DEBUG_IFDEFS=TRUE 172 endif 173 174 ifeq ($(DEBUG_IFDEFS),TRUE) 175 CFLAGS += -DBROADCOM_DEBUG 176 CXXFLAGS += -DBROADCOM_DEBUG 177 CPPFLAGS += -DBROADCOM_DEBUG 178 endif 179 180 # 181 # Debug symbol information control 182 # 183 ifndef DEBUG_SYMBOLS 184 DEBUG_SYMBOLS=TRUE 185 endif 186 187 ifeq ($(DEBUG_SYMBOLS),TRUE) 188 CFLAGS += -g 189 CXXFLAGS += -g 190 CPPFLAGS += -g 191 endif 192 193 # 194 # If DEBUG_CFLAGS is set, add its contents to CFLAGS. 195 # May be useful for setting on the command line or adding to Make.local. 196 # Example: gmake DEBUG_CFLAGS=-save-temps system.c 197 # 198 199 ifneq ($(DEBUG_CFLAGS),) 200 CFLAGS += $(DEBUG_CFLAGS) 201 CXXFLAGS += $(DEBUG_CFLAGS) 202 CPPFLAGS += $(DEBUG_CFLAGS) 203 endif 204 205 # 206 # Optimization level 207 # 208 # Set DEBUG_OPTIMIZE to TRUE (default) to use a normal optimization 209 # determined by OPTFLAGS_DEFAULT in the platform Makefile. 210 # Set DEBUG_OPTIMIZE to FALSE to use no optimization, 211 # strongly recommended when using any debugger. 212 # Set DEBUG_OPTIMIZE to any other option string to request specific 213 # optimization flags (for example -O2). 214 # 215 ifndef DEBUG_OPTIMIZE 216 DEBUG_OPTIMIZE=TRUE 217 endif 218 219 ifeq ($(DEBUG_OPTIMIZE),TRUE) 220 OPTFLAGS += $(OPTFLAGS_DEFAULT) 221 else 222 ifneq ($(DEBUG_OPTIMIZE),FALSE) 223 OPTFLAGS += $(DEBUG_OPTIMIZE) 224 endif 225 endif 226 227 # 228 # Debug assertion control. 229 # 230 # Compiling out assert() saves about 1.1% on executable size, 231 # however doing so is VERY MUCH discouraged. 232 # 233 ifndef DEBUG_ASSERTS 234 DEBUG_ASSERTS=TRUE 235 endif 236 237 ifeq ($(DEBUG_ASSERTS),FALSE) 238 CFLAGS += -DNDEBUG 239 CXXFLAGS += -DNDEBUG 240 CPPFLAGS += -DNDEBUG 241 endif 242 243 # 244 # GCC pedantic mode. 245 # 246 ifeq ($(DEBUG_PEDANTIC),TRUE) 247 CFGFLAGS += -D__PEDANTIC__ 248 CFLAGS += --pedantic 249 CXXFLAGS += --pedantic 250 endif 251 252 # 253 # In each directory, build a list of local sources, objects, and headers 254 # 255 LSRCS = $(wildcard *.c *.cpp *.s *.cc *.C) 256 LOBJS = $(addsuffix .o, $(basename ${LSRCS})) 257 BOBJS = $(addprefix ${BLDDIR}/,${LOBJS}) 258 LHDRS = $(wildcard *.h *.H) 259 LDOTIS = $(wildcard *.i) 260 261 262 # 263 # Rule to create object file (build) directory 264 # 265 266 .PHONY: all install clean distclean 267 268 .PRECIOUS: ${BLDDIR}/.tree 269 270 %/.tree: 271 @$(ECHO) 'Creating build directory $(dir $@)' 272 @$(MKDIR) $(dir $@) 273 @$(ECHO) "Build Directory for ${LOCALDIR} Created" > $@ 274 275 # Rule allowing build through CPP only, creates .E file from .c file. 276 277 %.E: %.c 278 $Q${CC} -E ${CFLAGS} $< | sed -e '/^ *$$/d' -e p -e d > $@ 279 280 # Rule allowing build through source only, creates .s file from .c file. 281 282 %.s: %.c 283 $Q${CC} -S ${CFLAGS} $< 284 285 # 286 # Default Build rules for .c --> .o, leaving the binary in BLDDIR/X.o, 287 # even if file not built from directory of source. 288 # 289 ifeq ($(FAST),1) 290 ${BLDDIR}/%.o: %.c 291 else 292 ifdef GENERATE_C_FILES 293 ${BLDDIR}/%.o: %.c 294 else 295 ${BLDDIR}/%.o: %.c 296 endif 297 endif 298 ifdef QUIET 299 @${ECHO} Compiling ${LOCALDIR}/$< 300 endif 301 ifdef LOCAL_D_FILE 302 $Q$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< --write-user-dependencies 303 -@/bin/cp $*.d $(BLDDIR)/$*.d 304 -@/bin/rm -f $*.d 305 else 306 $Q$(CC) -MD -MF $(BLDDIR)/$*.d $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< 307 endif 308 @/bin/cp $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp;\ 309 /bin/sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ 310 -e '/^$$/ d' -e 's/$$/ :/' \ 311 < $(BLDDIR)/$*.d >> $(BLDDIR)/$*.tmp; \ 312 /bin/sed \ 313 -e 's| \([0-9a-zA-Z]\)| '$(SDK)/$(LOCALDIR)'\/\1|g' \ 314 -e 's|^\([0-9a-zA-Z]\)|'$(SDK)/$(LOCALDIR)'/\1|g' \ 315 -e 's| \(\.\.\/\)| '$(SDK)/$(LOCALDIR)'\/\1|g' \ 316 -e 's|'$(SDK)'|'$$\{SDK\}'|g' \ 317 -e 's/\w*\/\.\.\/*//g' \ 318 -e 's/\w*\/\.\.\/*//g' \ 319 -e 's/\w*\/\.\.\/*//g' \ 320 < $(BLDDIR)/$*.tmp > $(BLDDIR)/$*.P; \ 321 /bin/rm -f $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp 322 323 ${BLDDIR}/%.o: %.s 324 ifdef QUIET 325 @${ECHO} Assembling ${LOCALDIR}/$< 326 endif 327 $Q${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c $< -o $@ 328 329 ${BLDDIR}/%.o: %.cpp 330 ifdef QUIET 331 @${ECHO} Compiling ${LOCALDIR}/$< 332 endif 333 $Q${CXX} -c ${CXXFLAGS} -c $< -o $@ 334 335 ${BLDDIR}/%.o: %.cc ${BLDDIR}/.tree 336 ifdef QUIET 337 @${ECHO} Compiling ${LOCALDIR}/$< 338 endif 339 $Q${CXX} -c ${CXXFLAGS} -c $< -o $@ 340 341 # 342 # Cause "make foo.o" in any subdirectory to put the object in the build 343 # directory instead of the local directory. 344 # 345 %.o: ${BLDDIR}/%.o 346 @ 347 348 # 349 # List of directories where built objects live. 350 # (we are not making the export directories for now) 351 # 352 #DIRS = ${BLDDIR} ${EXPDIR}/lib ${EXPDIR}/bin ${EXPDIR}/include 353 DIRS = ${BLDDIR} 354 355 ifeq (C_COMPILER,$(MAKECMDGOALS)) 356 C_COMPILER: 357 @echo $(CC) 358 endif