From ddfa2f3cef3e9bcf25a8f5d584d3978d7c63d58b Mon Sep 17 00:00:00 2001 From: kpfleming Date: Tue, 21 Jul 2009 13:48:38 +0000 Subject: Merged revisions 207680 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r207680 | kpfleming | 2009-07-21 08:28:04 -0500 (Tue, 21 Jul 2009) | 18 lines Merged revisions 207647 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r207647 | kpfleming | 2009-07-21 08:04:44 -0500 (Tue, 21 Jul 2009) | 12 lines Ensure that user-provided CFLAGS and LDFLAGS are honored. This commit changes the build system so that user-provided flags (in ASTCFLAGS and ASTLDFLAGS) are supplied to the compiler/linker *after* all flags provided by the build system itself, so that the user can effectively override the build system's flags if desired. In addition, ASTCFLAGS and ASTLDFLAGS can now be provided *either* in the environment before running 'make', or as variable assignments on the 'make' command line. As a result, the use of COPTS and LDOPTS is no longer necessary, so they are no longer documented, but are still supported so as not to break existing build systems that supply them when building Asterisk. ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@207684 f38db490-d61c-443f-a65b-d21fe96a405b --- Makefile | 76 +++++++++++++++++++++++++++++----------------------------------- 1 file changed, 34 insertions(+), 42 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 044956a16..d0ac05267 100644 --- a/Makefile +++ b/Makefile @@ -13,29 +13,23 @@ # All Makefiles use the following variables: # -# ASTCFLAGS - compiler options -# ASTLDFLAGS - linker flags (not libraries) +# ASTCFLAGS - compiler options provided by the user (if any) +# _ASTCFLAGS - compiler options provided by the build system +# ASTLDFLAGS - linker flags (not libraries) provided by the user (if any) +# _ASTLDFLAGS - linker flags (not libraries) provided by the build system # LIBS - additional libraries, at top-level for all links, # on a single object just for that object # SOLINK - linker flags used only for creating shared objects (.so files), # used for all .so links # -# Initial values for ASTCFLAGS and ASTLDFLAGS can be specified in the +# Values for ASTCFLAGS and ASTLDFLAGS can be specified in the # environment when running make, as follows: # # $ ASTCFLAGS="-Werror" make ... # -# note that this is different from +# or as a variable value on the make command line itself: # # $ make ASTCFLAGS="-Werror" ... -# -# If you need to pass compiler/linker flags as 'make' variables, please use -# -# $ make COPTS="..." LDOPTS="..." ... -# -# -# You can add the path of local module subdirs from the command line with -# make LOCAL_MOD_SUBDIRS= .... export ASTTOPDIR # Top level dir, used in subdirs' Makefiles export ASTERISKVERSION @@ -171,7 +165,7 @@ HTTP_DOCSDIR=/var/www/html HTTP_CGIDIR=/var/www/cgi-bin # Uncomment this to use the older DSP routines -#ASTCFLAGS+=-DOLD_DSP_ROUTINES +#_ASTCFLAGS+=-DOLD_DSP_ROUTINES # If the file .asterisk.makeopts is present in your home directory, you can # include all of your favorite menuselect options so that every time you download @@ -221,59 +215,59 @@ ifeq ($(OSARCH),linux-gnu) endif endif -ifeq ($(findstring -save-temps,$(ASTCFLAGS)),) - ifeq ($(findstring -pipe,$(ASTCFLAGS)),) - ASTCFLAGS+=-pipe +ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),) + ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),) + _ASTCFLAGS+=-pipe endif endif -ifeq ($(findstring -Wall,$(ASTCFLAGS)),) - ASTCFLAGS+=-Wall +ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),) + _ASTCFLAGS+=-Wall endif -ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) +_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) ifeq ($(AST_DEVMODE),yes) - ASTCFLAGS+=-Werror - ASTCFLAGS+=-Wunused - ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT) - ASTCFLAGS+=$(AST_FORTIFY_SOURCE) - ASTCFLAGS+=-Wundef - ASTCFLAGS+=-Wmissing-format-attribute - ASTCFLAGS+=-Wformat=2 + _ASTCFLAGS+=-Werror + _ASTCFLAGS+=-Wunused + _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT) + _ASTCFLAGS+=$(AST_FORTIFY_SOURCE) + _ASTCFLAGS+=-Wundef + _ASTCFLAGS+=-Wmissing-format-attribute + _ASTCFLAGS+=-Wformat=2 endif ifneq ($(findstring BSD,$(OSARCH)),) - ASTCFLAGS+=-I/usr/local/include - ASTLDFLAGS+=-L/usr/local/lib + _ASTCFLAGS+=-I/usr/local/include + _ASTLDFLAGS+=-L/usr/local/lib endif -ifeq ($(findstring -march,$(ASTCFLAGS)),) +ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),) ifneq ($(PROC),ultrasparc) - ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) + _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) endif endif ifeq ($(PROC),ppc) - ASTCFLAGS+=-fsigned-char + _ASTCFLAGS+=-fsigned-char endif ifeq ($(OSARCH),FreeBSD) # -V is understood by BSD Make, not by GNU make. BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk) - ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi) + _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi) endif ifeq ($(OSARCH),NetBSD) - ASTCFLAGS+=-pthread -I/usr/pkg/include + _ASTCFLAGS+=-pthread -I/usr/pkg/include endif ifeq ($(OSARCH),OpenBSD) - ASTCFLAGS+=-pthread + _ASTCFLAGS+=-pthread endif ifeq ($(OSARCH),SunOS) - ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 + _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 endif ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .) @@ -286,9 +280,7 @@ ifneq ($(wildcard .svn),) ASTERISKVERSIONNUM:=999999 endif -# XXX MALLOC_DEBUG is probably unused, Makefile.moddir_rules adds the -# value directly to ASTCFLAGS -ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS) +_ASTCFLAGS+=$(OPTIONS) MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs tests main res $(LOCAL_MOD_SUBDIRS) OTHER_SUBDIRS:=utils agi @@ -303,7 +295,7 @@ MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs) MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree) ifneq ($(findstring darwin,$(OSARCH)),) - ASTCFLAGS+=-D__Darwin__ + _ASTCFLAGS+=-D__Darwin__ SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace else # These are used for all but Darwin @@ -404,10 +396,10 @@ res: main endif $(MOD_SUBDIRS): - +@ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all + @_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all $(OTHER_SUBDIRS): - +@ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all + @_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all defaults.h: makeopts @build_tools/make_defaults_h > $@.tmp @@ -465,7 +457,7 @@ distclean: $(SUBDIRS_DIST_CLEAN) _clean rm -f build_tools/menuselect-deps datafiles: _all - if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" bash build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi + if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" bash build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi # Should static HTTP be installed during make samples or even with its own target ala # webvoicemail? There are portions here that *could* be customized but might also be # improved a lot. I'll put it here for now. -- cgit v1.2.3