Description: respect $(CPPFLAGS) and $(LDFLAGS) in makefile
LDFLAGS overwritten otherwise; CPPFLAGS not considered so far
Authors: Christoph Feenders <debian@echti.de>, Kamal Mostafa <kamal@whence.com>
Last-Update: <2014-02-10>

--- cwirc-2.0.0/Makefile
+++ cwirc-2.0.0/Makefile
@@ -60,9 +60,9 @@
 XCHAT_PLUGIN_INCLUDE_PATH=xchat
 
 XCHAT_INC=-I$(XCHAT_PLUGIN_INCLUDE_PATH)
-CFLAGS=-Wall -Wstrict-prototypes -O2 -D$(TARGET_OS)
+CFLAGS:=$(CFLAGS) -Wall -Wstrict-prototypes -O2 -D$(TARGET_OS)
 GTK_CFLAGS=`pkg-config --cflags gtk+-2.0`
-LDFLAGS=-lm ${EXTRA_LDFLAGS}
+LDFLAGS:=$(LDFLAGS) -lm ${EXTRA_LDFLAGS}
 GTK_LDFLAGS=`pkg-config --libs gtk+-2.0`
 
 all:			missing_settings				\
@@ -116,7 +116,7 @@
 			cwirc.h						\
 			cwframe.h					\
 			ipc.h
-			$(CC) $(CFLAGS) $(XCHAT_INC) -fPIC -c -o $@ plugin.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) $(XCHAT_INC) -fPIC -c -o $@ plugin.c
 
 frontend.o:		frontend.c					\
 			types.h						\
@@ -127,7 +127,7 @@
 			gui.h						\
 			extension.h					\
 			ipc.h
-			$(CC) $(CFLAGS) $(XCHAT_INC) -c -o $@ frontend.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) $(XCHAT_INC) -c -o $@ frontend.c
 
 io.o:			io.c						\
 			types.h						\
@@ -139,7 +139,7 @@
 			propagation.h					\
 			extension.h					\
 			ipc.h
-			$(CC) $(CFLAGS) -c -o $@ io.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ io.c
 
 gui.o:			gui.c						\
 			types.h						\
@@ -157,35 +157,35 @@
 			sidetone.xpm					\
 			straightkey.xpm					\
 			iambickey.xpm
-			$(CC) $(CFLAGS) $(GTK_CFLAGS) -c -o $@ gui.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) $(GTK_CFLAGS) -c -o $@ gui.c
 
 keyer.o:		keyer.c						\
 			types.h						\
 			keyer.h
-			$(CC) $(CFLAGS) -c -o $@ keyer.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ keyer.c
 
 grid.o:			grid.c						\
 			grid.h
-			$(CC) $(CFLAGS) -c -o $@ grid.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ grid.c
 
 grid.shared.o:		grid.c						\
 			grid.h
-			$(CC) $(CFLAGS) -fPIC -c -o $@ grid.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c -o $@ grid.c
 
 propagation.o:		propagation.c					\
 			propagation.h
-			$(CC) $(CFLAGS) -c -o $@ propagation.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ propagation.c
 
 propagation.shared.o:	propagation.c					\
 			propagation.h
-			$(CC) $(CFLAGS) -fPIC -c -o $@ propagation.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c -o $@ propagation.c
 
 cwsound.o:		cwsound.c					\
 			types.h						\
 			cwsound.h					\
 			sounder_down.h					\
 			sounder_up.h
-			$(CC) $(CFLAGS) -c -o $@ cwsound.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ cwsound.c
 
 cwframe.o:		cwframe.c					\
 			types.h						\
@@ -195,7 +195,7 @@
 			propagation.h					\
 			io.h						\
 			ipc.h
-			$(CC) $(CFLAGS) -c -o $@ cwframe.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ cwframe.c
 
 cwframe.shared.o:	cwframe.c					\
 			types.h						\
@@ -205,22 +205,22 @@
 			propagation.h					\
 			io.h						\
 			ipc.h
-			$(CC) $(CFLAGS) -fPIC -c -o $@ cwframe.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c -o $@ cwframe.c
 
 cwdecoder.o:		cwdecoder.c					\
 			types.h						\
 			cwdecoder.h					\
 			morsecodes.h					\
 			cwirc.h
-			$(CC) $(CFLAGS) -c -o $@ cwdecoder.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ cwdecoder.c
 
 ipc.o:			ipc.c						\
 			ipc.h
-			$(CC) $(CFLAGS) -c -o $@ ipc.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ ipc.c
 
 ipc.shared.o:		ipc.c						\
 			ipc.h
-			$(CC) $(CFLAGS) -fPIC -c -o $@ ipc.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c -o $@ ipc.c
 
 rcfile.o:		rcfile.c					\
 			types.h						\
@@ -229,7 +229,7 @@
 			grid.h						\
 			io.h						\
 			cwdecoder.h
-			$(CC) $(CFLAGS) -c -o $@ rcfile.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ rcfile.c
 
 extension.o:		extension.c					\
 			types.h						\
@@ -237,7 +237,7 @@
 			extension.h					\
 			ipc.h						\
 			common.h
-			$(CC) $(CFLAGS) -c -o $@ extension.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ extension.c
 
 sounder_down.h:		sounder_down.wav				\
 			mksndinclude
@@ -249,7 +249,7 @@
 
 mksndinclude:		mksndinclude.c					\
 			types.h
-			$(CC) $(CFLAGS) -o $@ mksndinclude.c
+			$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ mksndinclude.c $(LDFLAGS)
 
 common.h:
 			echo "#define FRONTEND \"$(FRONTEND)\"" > $@
