Module: sip-router
Branch: sr_3.0
Commit: 4950c885cc89f946cecb7f51129f08ec7ddd875d
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4950c885cc89f946cecb7f51129f08ec7ddd875d

Author: Andrei Pelinescu-Onciul <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
Date:   Wed Mar 10 17:30:39 2010 +0100

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]>
(cherry-picked from commit 0b2d2c6e99dac2bd171f1c24bfa6f285f6539273)

---

 Makefile.defs |   61 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/Makefile.defs b/Makefile.defs
index 358e99c..d612d4a 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -115,8 +115,19 @@ ifeq ($(quiet),verbose)
 $(info normal Makefile.defs exec)
 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
+$(call set_if_empty,FLAVOUR,sip-router)
+
+#prefix for various configs and scripts
+#config name/name-prefix for distributed configs
+CFG_NAME=sip-router
+#config name/name-prefix for distributed scripts
+SCR_NAME=sip-router
+#name in source tree
+SRC_NAME=sip-router
 
 ifeq ($(FLAVOUR),sip-router)
 # main binary name
@@ -132,14 +143,6 @@ else # default:
 MAIN_NAME=sip-router
 endif
 
-#prefix for various configs and scripts
-#config name/name-prefix for distributed configs
-CFG_NAME=sip-router
-#config name/name-prefix for distributed scripts
-SCR_NAME=sip-router
-#name in source tree
-SRC_NAME=sip-router
-
 # what to install
 INSTALL_FLAVOUR=$(FLAVOUR)
 
@@ -807,7 +810,7 @@ ifeq                ($(CC_NAME), gcc)
                                CFLAGS=-g -O9 -funroll-loops  -Wcast-align 
$(PROFILE)
                        #if gcc 4.2+
 ifeq                   ($(CC_SHORTVER), 4.2+)
-                                       CPU ?= athlon64
+$(call                         set_if_empty,CPU,athlon64)
                                        CFLAGS+=-m32 -minline-all-stringops \
                                                        -falign-loops \
                                                        -ftree-vectorize \
@@ -817,7 +820,7 @@ ifeq                        ($(CC_SHORTVER), 4.2+)
 else
                        #if gcc 4.0+
 ifeq                   ($(CC_SHORTVER), 4.x)
-                                       CPU ?= athlon64
+$(call                         set_if_empty,CPU,athlon64)
                                        CFLAGS+=-m32 -minline-all-stringops \
                                                        -falign-loops \
                                                        -ftree-vectorize \
@@ -826,7 +829,7 @@ ifeq                        ($(CC_SHORTVER), 4.x)
 else
                        #if gcc 3.4+
 ifeq                   ($(CC_SHORTVER), 3.4)
-                                       CPU ?= athlon
+$(call                         set_if_empty,CPU,athlon)
                                        CFLAGS+=-m32 -minline-all-stringops \
                                                        -falign-loops \
                                                        -mtune=$(CPU) 
@@ -834,7 +837,7 @@ ifeq                        ($(CC_SHORTVER), 3.4)
 else
                        #if gcc 3.0+
 ifeq                   ($(CC_SHORTVER), 3.0)
-                                       CPU ?= athlon
+$(call                         set_if_empty,CPU,athlon)
                                        CFLAGS+=-minline-all-stringops \
                                                        -falign-loops \
                                                        -mcpu=$(CPU)
@@ -882,7 +885,7 @@ ifeq                ($(CC_NAME), gcc)
                                CFLAGS=-g -O9 -funroll-loops  -Wcast-align 
$(PROFILE)
                        #if gcc 4.2+
 ifeq                   ($(CC_SHORTVER), 4.2+)
-                                       CPU ?= opteron
+$(call                         set_if_empty,CPU,opteron)
                                        CFLAGS+=-m64 -minline-all-stringops \
                                                        -falign-loops \
                                                        -ftree-vectorize \
@@ -892,7 +895,7 @@ ifeq                        ($(CC_SHORTVER), 4.2+)
 else
                        #if gcc 4.0+
 ifeq                   ($(CC_SHORTVER), 4.x)
-                                       CPU ?= opteron
+$(call                         set_if_empty,CPU,opteron)
                                        CFLAGS+=-m64 -minline-all-stringops \
                                                        -falign-loops \
                                                        -ftree-vectorize \
@@ -901,14 +904,14 @@ ifeq                      ($(CC_SHORTVER), 4.x)
 else
                        #if gcc 3.4
 ifeq                   ($(CC_SHORTVER), 3.4)
-                                       CPU ?= athlon64
+$(call                         set_if_empty,CPU,athlon64)
                                        CFLAGS+=-m64 -minline-all-stringops \
                                                        -falign-loops 
                                        LDFLAGS+=-m64
 else
                        #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
-                                       CPU ?= athlon64
+$(call                         set_if_empty,CPU,athlon64)
                                        CFLAGS+=-minline-all-stringops \
                                                        -falign-loops 
                                                        #-mcpu=$(CPU) \ # not 
working on all x86_64 gccs
@@ -959,7 +962,7 @@ ifeq                ($(CC_NAME), gcc)
                                        #-Wmissing-prototypes 
                                #if gcc 4.2+
 ifeq                   ($(CC_SHORTVER), 4.2+)
-                                       CPU ?= ultrasparc
+$(call                         set_if_empty,CPU,ultrasparc)
                                        #use 32bit for now
                                        CFLAGS+=-m64 -mcpu=ultrasparc  \
                                                        -mtune=$(CPU) \
@@ -973,7 +976,7 @@ ifeq                        ($(CC_SHORTVER), 4.2+)
 else
                                #if gcc 4.x
 ifeq                   ($(CC_SHORTVER), 4.x)
-                                       CPU ?= ultrasparc
+$(call                         set_if_empty,CPU,ultrasparc)
                                        #use 32bit for now
                                        CFLAGS+=-m64 -mcpu=ultrasparc  \
                                                        -mtune=$(CPU) \
@@ -982,14 +985,14 @@ ifeq                      ($(CC_SHORTVER), 4.x)
 else
                                #if gcc 3.4
 ifeq                   ($(CC_SHORTVER), 3.4)
-                                       CPU ?= ultrasparc
+$(call                         set_if_empty,CPU,ultrasparc)
                                        #use 32bit for now
                                        CFLAGS+=-m64 -mcpu=ultrasparc 
-mtune=$(CPU)
                                        LDFLAGS+=-m64
 else
                                #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
-                                       CPU ?= ultrasparc
+$(call                         set_if_empty,CPU,ultrasparc)
                                        #use 32bit for now
                                        CFLAGS+=-m64 -mcpu=ultrasparc 
-mtune=$(CPU)   \
                                        # -mcpu=v9 or ultrasparc? # -mtune 
implied by -mcpu
@@ -1050,7 +1053,7 @@ ifeq              ($(CC_NAME), gcc)
                                        #-Wmissing-prototypes 
                                #if gcc 4.2+
 ifeq                   ($(CC_SHORTVER), 4.2+)
-                                       CPU ?= v8 
+$(call                         set_if_empty,CPU,v8)
                                        #use 32bit for now
                                        CFLAGS+= -mtune=$(CPU) \
                                                        -fno-strict-overflow \
@@ -1058,20 +1061,20 @@ ifeq                    ($(CC_SHORTVER), 4.2+)
 else
                                #if gcc 4.x
 ifeq                   ($(CC_SHORTVER), 4.x)
-                                       CPU ?= v8 
+$(call                         set_if_empty,CPU,v8)
                                        #use 32bit for now
                                        CFLAGS+= -mtune=$(CPU) \
                                                        -ftree-vectorize
 else
                                #if gcc 3.4
 ifeq                   ($(CC_SHORTVER), 3.4)
-                                       CPU ?= v8
+$(call                         set_if_empty,CPU,v8)
                                        #use 32bit for now
                                        CFLAGS+= -mtune=$(CPU)
 else
                                #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
-                                       CPU ?= v8 
+$(call                         set_if_empty,CPU,v8)
                                        #use 32bit for now
                                        CFLAGS+= -mtune=$(CPU)   \
                                        #-mno-epilogue #try to inline function 
exit code
@@ -1391,14 +1394,14 @@ ifeq            ($(CC_NAME), gcc)
                                CFLAGS= -O9 -funroll-loops -fsigned-char 
$(PROFILE)
                        #if gcc 4.2+
 ifeq                   ($(CC_SHORTVER), 4.2+)
-                                       CPU ?= powerpc
+$(call                         set_if_empty,CPU,powerpc)
                                        CFLAGS+=-ftree-vectorize \
                                                        -fno-strict-overflow \
                                                        -mtune=$(CPU) -maltivec
 else
                        #if gcc 4.0+
 ifeq                   ($(CC_SHORTVER), 4.x)
-                                       CPU ?= powerpc
+$(call                         set_if_empty,CPU,powerpc)
                                        CFLAGS+=-ftree-vectorize \
                                                        -mtune=$(CPU) -maltivec
 else
@@ -1440,14 +1443,14 @@ ifeq            ($(CC_NAME), gcc)
                                CFLAGS= -O9 -funroll-loops -fsigned-char 
$(PROFILE)
                        #if gcc 4.2+
 ifeq                   ($(CC_SHORTVER), 4.2+)
-                                       CPU ?= powerpc64
+$(call                         set_if_empty,CPU,powerpc64)
                                        CFLAGS+=-ftree-vectorize \
                                                        -fno-strict-overflow \
                                                        -mtune=$(CPU) -maltivec
 else
                        #if gcc 4.0+
 ifeq                   ($(CC_SHORTVER), 4.x)
-                                       CPU ?= powerpc64
+$(call                         set_if_empty,CPU,powerpc64)
                                        CFLAGS+=-ftree-vectorize \
                                                        -mtune=$(CPU) -maltivec
 else


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to