Browse code

makefile: use separate CFLAGS & LDFLAGS for utils

- added UTILS_CFLAGS and UTILS_LDFLAGS (Makefile.defs and saved in
the config)
- use UTILS_CFLAGS and UTILS_LDFLAGS when compiling the utils
(fixes a bug when an util compiled by a module will be compiled
with the module flags)

Andrei Pelinescu-Onciul authored on 08/10/2009 15:45:44
Showing 2 changed files
... ...
@@ -1528,7 +1528,7 @@ endif # CC_NAME=suncc
1528 1528
 endif # CC_NAME=icc
1529 1529
 endif # CC_NAME=gcc
1530 1530
 
1531
-#*FLAGS used for compiling the modules
1531
+#CFLAGS used for compiling the modules, libraries and utils
1532 1532
 ifeq	($(CC_NAME), gcc)
1533 1533
 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1534 1534
 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
... ...
@@ -1542,6 +1542,9 @@ ifeq	($(CC_NAME), suncc)
1542 1542
 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
1543 1543
 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
1544 1544
 endif
1545
+UTILS_CFLAGS=$(CFLAGS)
1546
+# LDFLAGS uses for compiling the utils
1547
+UTILS_LDFLAGS=$(LDFLAGS)
1545 1548
 
1546 1549
 ifeq ($(LEX),)
1547 1550
 	LEX=flex
... ...
@@ -1891,7 +1894,7 @@ export exported_vars
1891 1894
 saved_fixed_vars:=	MAIN_NAME  CFG_NAME SCR_NAME \
1892 1895
 		RELEASE OS ARCH \
1893 1896
 		C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
1894
-		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1897
+		MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
1895 1898
 		LIB_SUFFIX LIB_PREFIX \
1896 1899
 		LIBS \
1897 1900
 		LEX YACC YACC_FLAGS \
... ...
@@ -1903,7 +1906,7 @@ saved_fixed_vars:=	MAIN_NAME  CFG_NAME SCR_NAME \
1903 1906
 # variable changeable at compile time
1904 1907
 # extra: prefix DESTDIR BASEDIR basedirt
1905 1908
 saved_chg_vars:=\
1906
-		CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS	\
1909
+		CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
1907 1910
 		BASEDIR basedir DESTDIR \
1908 1911
 		PREFIX prefix\
1909 1912
 		cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
... ...
@@ -40,7 +40,7 @@ override static_modules=
40 40
 override static_modules_path=
41 41
 
42 42
 # temporary def (visible only in the util makefile, not exported)
43
-DEFS +=
43
+DEFS += -DMOD_NAME="utils/$(UTIL_NAME)"
44 44
 
45 45
 ifneq ($(makefile_defs_included),1)
46 46
 $(error "the local makefile does not include Makefile.defs!")
... ...
@@ -63,6 +63,10 @@ include $(COREPATH)/Makefile.sources
63 63
 # the rest of makefile and try only to remake the config
64 64
 ifeq ($(makefile_defs),1)
65 65
 
66
+# set CFLAGS & LDFLAGS
67
+CFLAGS:=$(UTILS_CFLAGS)
68
+LDFLAGS:=$(UTILS_LDFLAGS)
69
+
66 70
 err_fail?=1
67 71
 
68 72
 include $(COREPATH)/Makefile.dirs