From 5830cc5b0cd3fd7f3ad86824dc718b4cfc1d4117 Mon Sep 17 00:00:00 2001
Author: Simon Ruderich <simon@ruderich.org>
Bug-Debian: http://bugs.debian.org/664086
Subject: pass BUILD_CFLGAS and BUILD_LDFLAGS to menuselect

Allow menuselect to get its set of CFLAGS and LDFLAGS through the
environment of Make:

  make BUILD_CFLAGS="whatever" BUILD_LDFLAGS="whatever"

Also keep menuselect from steping over them on its own.

Commited to upstream trunk (asterisk r366002, menuselect r1033).
Will be included in asterisk 11.

---
 Makefile |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/Makefile
+++ b/Makefile
@@ -884,7 +884,9 @@ nmenuselect: menuselect/nmenuselect menu
 	-@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
 
 # options for make in menuselect/
-MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
+MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" \
+		CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
+		$(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
 
 menuselect/menuselect: menuselect/makeopts
 	+$(MAKE_MENUSELECT) menuselect
--- a/menuselect/Makefile
+++ b/menuselect/Makefile
@@ -22,7 +22,7 @@ endif
 
 # Basic set of sources and flags/libraries/includes
 OBJS:=menuselect.o strcompat.o
-CFLAGS:=-g -c -D_GNU_SOURCE -Wall
+CFLAGS+=-g -c -D_GNU_SOURCE -Wall
 
 ifeq ($(MENUSELECT_DEBUG),yes)
   CFLAGS += -DMENUSELECT_DEBUG
@@ -64,14 +64,14 @@ all: $(ALL_TGTS)
 $(OBJS) $(C_OBJS) $(N_OBJS) $(G_OBJS) $(M_OBJS): autoconfig.h menuselect.h
 
 makeopts autoconfig.h: autoconfig.h.in makeopts.in
-	@./configure $(CONFIGURE_SILENT) CC= LD= AR= CFLAGS=
+	@./configure $(CONFIGURE_SILENT)
 
 $(ALL_TGTS): mxml/libmxml.a
 
 ifdef C_OBJS
 menuselect_curses.o: CFLAGS+=$(C_INCLUDE)
 cmenuselect: $(OBJS) $(C_OBJS)
-	$(CC) -o $@ $^ $(C_LIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(C_LIBS)
 else
 cmenuselect:
 endif
@@ -79,7 +79,7 @@ endif
 ifdef G_OBJS
 menuselect_gtk.o: CFLAGS+=$(G_INCLUDE)
 gmenuselect: $(OBJS) $(G_OBJS)
-	$(CC) -o $@ $^ $(G_LIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(G_LIBS)
 else
 gmenuselect:
 endif
@@ -87,13 +87,13 @@ endif
 ifdef N_OBJS
 menuselect_newt.o: CFLAGS+=$(N_INCLUDE)
 nmenuselect: $(OBJS) $(N_OBJS)
-	$(CC) -o $@ $^ $(N_LIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(N_LIBS)
 else
 nmenuselect:
 endif
 
 menuselect: $(OBJS) $(M_OBJS)
-	$(CC) -o $@ $^ $(M_LIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(M_LIBS)
 
 mxml/libmxml.a:
 	@if test ! -f mxml/Makefile ; then cd mxml && ./configure ; fi
