소스 검색

make: fix CPU reset in some conditions

In some cases like trying to build a package with debug config
(e.g. make cfg mode=debug; .... ; make deb), the CPU make variable
was reset resulting in a build failure. This happens because in
the debug config CPU is not set and hence is  saved as empty.
Trying to build a package will start a sub-make which will try to
re-do the config without debugging (make cfg), but the CPU
variable with and empty value will be inherited from the
environment and thus the CPU?=something lines won't have any
effect.
The fix replaces CPU?=something with
$(call set_if_empty,CPU,something)
This works around having an empty CPU in the environment.

Reported-by: Jan Janak  <[email protected]>
Andrei Pelinescu-Onciul 15 년 전
부모
커밋
0b2d2c6e99
1개의 변경된 파일24개의 추가작업 그리고 21개의 파일을 삭제
  1. 24 21
      Makefile.defs

+ 24 - 21
Makefile.defs

@@ -115,8 +115,11 @@ ifeq ($(quiet),verbose)
 $(info normal Makefile.defs exec)
 $(info normal Makefile.defs exec)
 endif # verbose
 endif # verbose
 
 
+# usage: $(call set_if_empty,VAR,value)
+set_if_empty=$(if $($(1)),,$(eval override $(1)=$(2)))
+
 # flavour: sip-router, ser or kamailio
 # flavour: sip-router, ser or kamailio
-FLAVOUR?=sip-router
+$(call	set_if_empty,FLAVOUR,sip-router)
 
 
 #prefix for various configs and scripts
 #prefix for various configs and scripts
 #config name/name-prefix for distributed configs
 #config name/name-prefix for distributed configs
@@ -816,7 +819,7 @@ ifeq		($(CC_NAME), gcc)
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
 			#if gcc 4.2+
 			#if gcc 4.2+
 ifeq			($(CC_SHORTVER), 4.2+)
 ifeq			($(CC_SHORTVER), 4.2+)
-					CPU ?= athlon64
+$(call				set_if_empty,CPU,athlon64)
 					CFLAGS+=-m32 -minline-all-stringops \
 					CFLAGS+=-m32 -minline-all-stringops \
 							-falign-loops \
 							-falign-loops \
 							-ftree-vectorize \
 							-ftree-vectorize \
@@ -826,7 +829,7 @@ ifeq			($(CC_SHORTVER), 4.2+)
 else
 else
 			#if gcc 4.0+
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 ifeq			($(CC_SHORTVER), 4.x)
-					CPU ?= athlon64
+$(call				set_if_empty,CPU,athlon64)
 					CFLAGS+=-m32 -minline-all-stringops \
 					CFLAGS+=-m32 -minline-all-stringops \
 							-falign-loops \
 							-falign-loops \
 							-ftree-vectorize \
 							-ftree-vectorize \
@@ -835,7 +838,7 @@ ifeq			($(CC_SHORTVER), 4.x)
 else
 else
 			#if gcc 3.4+
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 ifeq			($(CC_SHORTVER), 3.4)
-					CPU ?= athlon
+$(call				set_if_empty,CPU,athlon)
 					CFLAGS+=-m32 -minline-all-stringops \
 					CFLAGS+=-m32 -minline-all-stringops \
 							-falign-loops \
 							-falign-loops \
 							-mtune=$(CPU) 
 							-mtune=$(CPU) 
@@ -843,7 +846,7 @@ ifeq			($(CC_SHORTVER), 3.4)
 else
 else
 			#if gcc 3.0+
 			#if gcc 3.0+
 ifeq			($(CC_SHORTVER), 3.0)
 ifeq			($(CC_SHORTVER), 3.0)
-					CPU ?= athlon
+$(call				set_if_empty,CPU,athlon)
 					CFLAGS+=-minline-all-stringops \
 					CFLAGS+=-minline-all-stringops \
 							-falign-loops \
 							-falign-loops \
 							-mcpu=$(CPU)
 							-mcpu=$(CPU)
@@ -891,7 +894,7 @@ ifeq		($(CC_NAME), gcc)
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
 			#if gcc 4.2+
 			#if gcc 4.2+
 ifeq			($(CC_SHORTVER), 4.2+)
 ifeq			($(CC_SHORTVER), 4.2+)
-					CPU ?= opteron
+$(call				set_if_empty,CPU,opteron)
 					CFLAGS+=-m64 -minline-all-stringops \
 					CFLAGS+=-m64 -minline-all-stringops \
 							-falign-loops \
 							-falign-loops \
 							-ftree-vectorize \
 							-ftree-vectorize \
@@ -901,7 +904,7 @@ ifeq			($(CC_SHORTVER), 4.2+)
 else
 else
 			#if gcc 4.0+
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 ifeq			($(CC_SHORTVER), 4.x)
-					CPU ?= opteron
+$(call				set_if_empty,CPU,opteron)
 					CFLAGS+=-m64 -minline-all-stringops \
 					CFLAGS+=-m64 -minline-all-stringops \
 							-falign-loops \
 							-falign-loops \
 							-ftree-vectorize \
 							-ftree-vectorize \
@@ -910,14 +913,14 @@ ifeq			($(CC_SHORTVER), 4.x)
 else
 else
 			#if gcc 3.4
 			#if gcc 3.4
 ifeq			($(CC_SHORTVER), 3.4)
 ifeq			($(CC_SHORTVER), 3.4)
-					CPU ?= athlon64
+$(call				set_if_empty,CPU,athlon64)
 					CFLAGS+=-m64 -minline-all-stringops \
 					CFLAGS+=-m64 -minline-all-stringops \
 							-falign-loops 
 							-falign-loops 
 					LDFLAGS+=-m64
 					LDFLAGS+=-m64
 else
 else
 			#if gcc 3.0
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 ifeq			($(CC_SHORTVER), 3.0)
-					CPU ?= athlon64
+$(call				set_if_empty,CPU,athlon64)
 					CFLAGS+=-minline-all-stringops \
 					CFLAGS+=-minline-all-stringops \
 							-falign-loops 
 							-falign-loops 
 							#-mcpu=$(CPU) \ # not working on all x86_64 gccs
 							#-mcpu=$(CPU) \ # not working on all x86_64 gccs
@@ -968,7 +971,7 @@ ifeq		($(CC_NAME), gcc)
 					#-Wmissing-prototypes 
 					#-Wmissing-prototypes 
 				#if gcc 4.2+
 				#if gcc 4.2+
 ifeq			($(CC_SHORTVER), 4.2+)
 ifeq			($(CC_SHORTVER), 4.2+)
-					CPU ?= ultrasparc
+$(call				set_if_empty,CPU,ultrasparc)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+=-m64 -mcpu=ultrasparc  \
 					CFLAGS+=-m64 -mcpu=ultrasparc  \
 							-mtune=$(CPU) \
 							-mtune=$(CPU) \
@@ -982,7 +985,7 @@ ifeq			($(CC_SHORTVER), 4.2+)
 else
 else
 				#if gcc 4.x
 				#if gcc 4.x
 ifeq			($(CC_SHORTVER), 4.x)
 ifeq			($(CC_SHORTVER), 4.x)
-					CPU ?= ultrasparc
+$(call				set_if_empty,CPU,ultrasparc)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+=-m64 -mcpu=ultrasparc  \
 					CFLAGS+=-m64 -mcpu=ultrasparc  \
 							-mtune=$(CPU) \
 							-mtune=$(CPU) \
@@ -991,14 +994,14 @@ ifeq			($(CC_SHORTVER), 4.x)
 else
 else
 				#if gcc 3.4
 				#if gcc 3.4
 ifeq			($(CC_SHORTVER), 3.4)
 ifeq			($(CC_SHORTVER), 3.4)
-					CPU ?= ultrasparc
+$(call				set_if_empty,CPU,ultrasparc)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
 					CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
 					LDFLAGS+=-m64
 					LDFLAGS+=-m64
 else
 else
 				#if gcc 3.0
 				#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 ifeq			($(CC_SHORTVER), 3.0)
-					CPU ?= ultrasparc
+$(call				set_if_empty,CPU,ultrasparc)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)   \
 					CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)   \
 					# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
 					# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
@@ -1059,7 +1062,7 @@ ifeq		($(CC_NAME), gcc)
 					#-Wmissing-prototypes 
 					#-Wmissing-prototypes 
 				#if gcc 4.2+
 				#if gcc 4.2+
 ifeq			($(CC_SHORTVER), 4.2+)
 ifeq			($(CC_SHORTVER), 4.2+)
-					CPU ?= v8 
+$(call				set_if_empty,CPU,v8)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+= -mtune=$(CPU) \
 					CFLAGS+= -mtune=$(CPU) \
 							-fno-strict-overflow \
 							-fno-strict-overflow \
@@ -1067,20 +1070,20 @@ ifeq			($(CC_SHORTVER), 4.2+)
 else
 else
 				#if gcc 4.x
 				#if gcc 4.x
 ifeq			($(CC_SHORTVER), 4.x)
 ifeq			($(CC_SHORTVER), 4.x)
-					CPU ?= v8 
+$(call				set_if_empty,CPU,v8)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+= -mtune=$(CPU) \
 					CFLAGS+= -mtune=$(CPU) \
 							-ftree-vectorize
 							-ftree-vectorize
 else
 else
 				#if gcc 3.4
 				#if gcc 3.4
 ifeq			($(CC_SHORTVER), 3.4)
 ifeq			($(CC_SHORTVER), 3.4)
-					CPU ?= v8
+$(call				set_if_empty,CPU,v8)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+= -mtune=$(CPU)
 					CFLAGS+= -mtune=$(CPU)
 else
 else
 				#if gcc 3.0
 				#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 ifeq			($(CC_SHORTVER), 3.0)
-					CPU ?= v8 
+$(call				set_if_empty,CPU,v8)
 					#use 32bit for now
 					#use 32bit for now
 					CFLAGS+= -mtune=$(CPU)   \
 					CFLAGS+= -mtune=$(CPU)   \
 					#-mno-epilogue #try to inline function exit code
 					#-mno-epilogue #try to inline function exit code
@@ -1400,14 +1403,14 @@ ifeq		($(CC_NAME), gcc)
 				CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
 				CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
 			#if gcc 4.2+
 			#if gcc 4.2+
 ifeq			($(CC_SHORTVER), 4.2+)
 ifeq			($(CC_SHORTVER), 4.2+)
-					CPU ?= powerpc
+$(call				set_if_empty,CPU,powerpc)
 					CFLAGS+=-ftree-vectorize \
 					CFLAGS+=-ftree-vectorize \
 							-fno-strict-overflow \
 							-fno-strict-overflow \
 							-mtune=$(CPU) -maltivec
 							-mtune=$(CPU) -maltivec
 else
 else
 			#if gcc 4.0+
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 ifeq			($(CC_SHORTVER), 4.x)
-					CPU ?= powerpc
+$(call				set_if_empty,CPU,powerpc)
 					CFLAGS+=-ftree-vectorize \
 					CFLAGS+=-ftree-vectorize \
 							-mtune=$(CPU) -maltivec
 							-mtune=$(CPU) -maltivec
 else
 else
@@ -1449,14 +1452,14 @@ ifeq		($(CC_NAME), gcc)
 				CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
 				CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
 			#if gcc 4.2+
 			#if gcc 4.2+
 ifeq			($(CC_SHORTVER), 4.2+)
 ifeq			($(CC_SHORTVER), 4.2+)
-					CPU ?= powerpc64
+$(call				set_if_empty,CPU,powerpc64)
 					CFLAGS+=-ftree-vectorize \
 					CFLAGS+=-ftree-vectorize \
 							-fno-strict-overflow \
 							-fno-strict-overflow \
 							-mtune=$(CPU) -maltivec
 							-mtune=$(CPU) -maltivec
 else
 else
 			#if gcc 4.0+
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 ifeq			($(CC_SHORTVER), 4.x)
-					CPU ?= powerpc64
+$(call				set_if_empty,CPU,powerpc64)
 					CFLAGS+=-ftree-vectorize \
 					CFLAGS+=-ftree-vectorize \
 							-mtune=$(CPU) -maltivec
 							-mtune=$(CPU) -maltivec
 else
 else